Test funding peg-in psbt

This commit is contained in:
Andrew Chow 2019-10-23 14:12:48 -04:00
parent 1ce74e07f3
commit 00eb6c0978

View file

@ -14,7 +14,8 @@ from test_framework.util import (
assert_equal,
bytes_to_hex_str,
hex_str_to_bytes,
find_vout_for_address
find_vout_for_address,
assert_greater_than
)
from test_framework import util
from test_framework.messages import (
@ -317,6 +318,19 @@ class FedPegTest(BitcoinTestFramework):
fin_psbt = sidechain.finalizepsbt(signed_psbt['psbt'])
assert_equal(fin_psbt, signed_pegin)
# Try funding a psbt with the peg-in
assert_equal(sidechain.getbalance()['bitcoin'], 50)
out_bal = 0
outputs.append({sidechain.getnewaddress(): 49.999})
for out in outputs:
for val in out.values():
out_bal += Decimal(val)
assert_greater_than(out_bal, 50)
pegin_psbt = sidechain.walletcreatefundedpsbt([{"txid":txid1, "vout": vout, "pegin_bitcoin_tx": raw, "pegin_txout_proof": proof, "pegin_claim_script": addrs["claim_script"]}], outputs)
signed_psbt = sidechain.walletsignpsbt(pegin_psbt['psbt'])
fin_psbt = sidechain.finalizepsbt(signed_psbt['psbt'])
assert fin_psbt['complete']
sample_pegin_struct = FromHex(CTransaction(), signed_pegin["hex"])
# Round-trip peg-in transaction using python serialization
assert_equal(signed_pegin["hex"], bytes_to_hex_str(sample_pegin_struct.serialize()))