mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Test raw transaction peg-in
This commit is contained in:
parent
ac6f052a6d
commit
5a4d61169b
2 changed files with 22 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ from test_framework.util import (
|
|||
assert_equal,
|
||||
bytes_to_hex_str,
|
||||
hex_str_to_bytes,
|
||||
find_vout_for_address
|
||||
)
|
||||
from test_framework import util
|
||||
from test_framework.messages import (
|
||||
|
|
@ -218,6 +219,7 @@ class FedPegTest(BitcoinTestFramework):
|
|||
addr = addrs["mainchain_address"]
|
||||
assert_equal(sidechain.decodescript(addrs["claim_script"])["type"], "witness_v0_keyhash")
|
||||
txid1 = parent.sendtoaddress(addr, 24)
|
||||
vout = find_vout_for_address(parent, txid1, addr)
|
||||
# 10+2 confirms required to get into mempool and confirm
|
||||
assert_equal(sidechain.getsidechaininfo()["pegin_confirmation_depth"], 10)
|
||||
parent.generate(1)
|
||||
|
|
@ -278,6 +280,18 @@ class FedPegTest(BitcoinTestFramework):
|
|||
raw_pegin = sidechain.createrawpegin(raw, proof)['hex']
|
||||
signed_pegin = sidechain.signrawtransactionwithwallet(raw_pegin)
|
||||
|
||||
# Find the address that the peg-in used
|
||||
outputs = []
|
||||
for pegin_vout in sidechain.decoderawtransaction(raw_pegin)['vout']:
|
||||
if pegin_vout['scriptPubKey']['type'] == 'witness_v0_keyhash':
|
||||
outputs.append({pegin_vout['scriptPubKey']['addresses'][0]: pegin_vout['value']})
|
||||
elif pegin_vout['scriptPubKey']['type'] == 'fee':
|
||||
outputs.append({"fee": pegin_vout['value']})
|
||||
|
||||
# Check the createrawtransaction makes the same unsigned peg-in transaction
|
||||
raw_pegin2 = sidechain.createrawtransaction([{"txid":txid1, "vout": vout, "pegin_bitcoin_tx": raw, "pegin_txout_proof": proof, "pegin_claim_script": addrs["claim_script"]}], outputs)
|
||||
assert_equal(raw_pegin, raw_pegin2)
|
||||
|
||||
sample_pegin_struct = FromHex(CTransaction(), signed_pegin["hex"])
|
||||
# Round-trip peg-in transaction using python serialization
|
||||
assert_equal(signed_pegin["hex"], sample_pegin_struct.serialize().hex())
|
||||
|
|
|
|||
|
|
@ -524,6 +524,14 @@ class PSBTTest(BitcoinTestFramework):
|
|||
# Some Confidential-Assets-specific tests
|
||||
self.run_ca_tests()
|
||||
|
||||
# Check that peg-ins are disallowed
|
||||
assert_raises_rpc_error(-8, 'pegin_ arguments provided but this command does not support peg-ins', self.nodes[0].createpsbt, [{"txid": "0000000000000000000000000000000000000000000000000000000000000000", "vout": 0, "pegin_bitcoin_tx": "00"}], [{self.nodes[0].getnewaddress(): 1}])
|
||||
assert_raises_rpc_error(-8, 'pegin_ arguments provided but this command does not support peg-ins', self.nodes[0].createpsbt, [{"txid": "0000000000000000000000000000000000000000000000000000000000000000", "vout": 0, "pegin_txout_proof": "00"}], [{self.nodes[0].getnewaddress(): 1}])
|
||||
assert_raises_rpc_error(-8, 'pegin_ arguments provided but this command does not support peg-ins', self.nodes[0].createpsbt, [{"txid": "0000000000000000000000000000000000000000000000000000000000000000", "vout": 0, "pegin_claim_script": "00"}], [{self.nodes[0].getnewaddress(): 1}])
|
||||
assert_raises_rpc_error(-8, 'pegin_ arguments provided but this command does not support peg-ins', self.nodes[0].walletcreatefundedpsbt, [{"txid": "0000000000000000000000000000000000000000000000000000000000000000", "vout": 0, "pegin_bitcoin_tx": "00"}], [{self.nodes[0].getnewaddress(): 1}])
|
||||
assert_raises_rpc_error(-8, 'pegin_ arguments provided but this command does not support peg-ins', self.nodes[0].walletcreatefundedpsbt, [{"txid": "0000000000000000000000000000000000000000000000000000000000000000", "vout": 0, "pegin_txout_proof": "00"}], [{self.nodes[0].getnewaddress(): 1}])
|
||||
assert_raises_rpc_error(-8, 'pegin_ arguments provided but this command does not support peg-ins', self.nodes[0].walletcreatefundedpsbt, [{"txid": "0000000000000000000000000000000000000000000000000000000000000000", "vout": 0, "pegin_claim_script": "00"}], [{self.nodes[0].getnewaddress(): 1}])
|
||||
|
||||
# Tests added in the 0.18 rebase don't pass on Elements yet.
|
||||
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue