Skip to content

Commit

Permalink
Test funding peg-in psbt
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Dec 4, 2019
1 parent 1ce74e0 commit 00eb6c0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion test/functional/feature_fedpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
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 (
Expand Down Expand Up @@ -317,6 +318,19 @@ def run_test(self):
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()))
Expand Down

0 comments on commit 00eb6c0

Please sign in to comment.