Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_avalancheproof.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2021 The Bitcoin developers | # Copyright (c) 2021 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test building avalanche proofs and using them to add avalanche peers.""" | """Test building avalanche proofs and using them to add avalanche peers.""" | ||||
import base64 | import base64 | ||||
from decimal import Decimal | from decimal import Decimal | ||||
from test_framework.address import ADDRESS_BCHREG_UNSPENDABLE | from test_framework.address import ADDRESS_ECREG_UNSPENDABLE | ||||
from test_framework.avatools import ( | from test_framework.avatools import ( | ||||
create_coinbase_stakes, | create_coinbase_stakes, | ||||
create_stakes, | create_stakes, | ||||
get_proof_ids, | get_proof_ids, | ||||
wait_for_proof, | wait_for_proof, | ||||
) | ) | ||||
from test_framework.key import ECKey, bytes_to_wif | from test_framework.key import ECKey, bytes_to_wif | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert_equal(raw_proof['orphan'], False) | assert_equal(raw_proof['orphan'], False) | ||||
assert_raises_rpc_error(-8, "Proof not found", | assert_raises_rpc_error(-8, "Proof not found", | ||||
node.getrawavalancheproof, '0' * 64) | node.getrawavalancheproof, '0' * 64) | ||||
# Orphan the proof by sending the stake | # Orphan the proof by sending the stake | ||||
raw_tx = node.createrawtransaction( | raw_tx = node.createrawtransaction( | ||||
[{"txid": stakes[-1]["txid"], "vout": 0}], | [{"txid": stakes[-1]["txid"], "vout": 0}], | ||||
{ADDRESS_BCHREG_UNSPENDABLE: stakes[-1] | {ADDRESS_ECREG_UNSPENDABLE: stakes[-1] | ||||
["amount"] - Decimal('10000')} | ["amount"] - Decimal('10000')} | ||||
) | ) | ||||
signed_tx = node.signrawtransactionwithkey(raw_tx, [addrkey0.key]) | signed_tx = node.signrawtransactionwithkey(raw_tx, [addrkey0.key]) | ||||
node.sendrawtransaction(signed_tx["hex"]) | node.sendrawtransaction(signed_tx["hex"]) | ||||
node.generate(1) | node.generate(1) | ||||
wait_until(lambda: proofid not in get_proof_ids(node)) | wait_until(lambda: proofid not in get_proof_ids(node)) | ||||
raw_proof = node.getrawavalancheproof("{:064x}".format(proofid)) | raw_proof = node.getrawavalancheproof("{:064x}".format(proofid)) | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |