Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_avalancheproof.py
Show All 12 Lines | |||||
) | ) | ||||
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 ( | ||||
AvalancheDelegation, | AvalancheDelegation, | ||||
AvalancheDelegationLevel, | AvalancheDelegationLevel, | ||||
AvalancheProof, | AvalancheProof, | ||||
FromHex, | FromHex, | ||||
) | ) | ||||
from test_framework.p2p import P2PInterface | from test_framework.p2p import P2PInterface, p2p_lock | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.test_node import ErrorMatch | from test_framework.test_node import ErrorMatch | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
append_config, | append_config, | ||||
assert_equal, | assert_equal, | ||||
wait_until, | wait_until, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
conflicting_utxo = node.buildavalancheproof( | conflicting_utxo = node.buildavalancheproof( | ||||
proof_sequence + 1, proof_expiration, proof_master, stakes) | proof_sequence + 1, proof_expiration, proof_master, stakes) | ||||
assert_raises_rpc_error(-8, "The proof has conflicting utxo with an existing proof", | assert_raises_rpc_error(-8, "The proof has conflicting utxo with an existing proof", | ||||
node.sendavalancheproof, conflicting_utxo) | node.sendavalancheproof, conflicting_utxo) | ||||
# Good proof | # Good proof | ||||
assert node.verifyavalancheproof(proof) | assert node.verifyavalancheproof(proof) | ||||
peer = node.add_p2p_connection(P2PInterface()) | |||||
proofid = FromHex(AvalancheProof(), proof).proofid | proofid = FromHex(AvalancheProof(), proof).proofid | ||||
node.sendavalancheproof(proof) | node.sendavalancheproof(proof) | ||||
assert proofid in get_proof_ids(node) | assert proofid in get_proof_ids(node) | ||||
# TODO Once implemented we expect the sendavalancheproof to trigger the | def inv_found(): | ||||
# sending of an inv message with our proof: | with p2p_lock: | ||||
# | return peer.last_message.get( | ||||
# def inv_found(): | "inv") and peer.last_message["inv"].inv[-1].hash == proofid | ||||
# with p2p_lock: | wait_until(inv_found) | ||||
# return peer.last_message.get( | |||||
# "inv") and peer.last_message["inv"].inv[-1].hash == proofid | |||||
# wait_until(inv_found) | |||||
self.log.info("Bad proof should be rejected at startup") | self.log.info("Bad proof should be rejected at startup") | ||||
self.stop_node(0) | self.stop_node(0) | ||||
node.assert_start_raises_init_error( | node.assert_start_raises_init_error( | ||||
self.extra_args[0] + [ | self.extra_args[0] + [ | ||||
"-avasessionkey=0", | "-avasessionkey=0", | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |