Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_avalancheproof.py
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Invalid hex (odd number of hex digits) | # Invalid hex (odd number of hex digits) | ||||
assert_raises_rpc_error(-22, "Proof must be an hexadecimal string", | assert_raises_rpc_error(-22, "Proof must be an hexadecimal string", | ||||
node.decodeavalancheproof, proof[:-1]) | node.decodeavalancheproof, proof[:-1]) | ||||
# Valid hex but invalid proof | # Valid hex but invalid proof | ||||
assert_raises_rpc_error(-22, "Proof has invalid format", | assert_raises_rpc_error(-22, "Proof has invalid format", | ||||
node.decodeavalancheproof, proof[:-2]) | node.decodeavalancheproof, proof[:-2]) | ||||
# Restart the node, making sure it is initially in IBD mode | # Restart the node with this proof | ||||
minchainwork = int(node.getblockchaininfo()["chainwork"], 16) + 1 | |||||
self.restart_node(0, self.extra_args[0] + [ | self.restart_node(0, self.extra_args[0] + [ | ||||
"-avaproof={}".format(proof), | "-avaproof={}".format(proof), | ||||
"-avamasterkey=cND2ZvtabDbJ1gucx9GWH6XT9kgTAqfb6cotPt5Q5CyxVDhid2EN", | "-avamasterkey=cND2ZvtabDbJ1gucx9GWH6XT9kgTAqfb6cotPt5Q5CyxVDhid2EN", | ||||
"-minimumchainwork=0x{:x}".format(minchainwork), | |||||
]) | ]) | ||||
self.log.info( | self.log.info("The proof is registered at first chaintip update") | ||||
"The proof verification should be delayed until IBD is complete") | assert_equal(len(node.getavalanchepeerinfo()), 0) | ||||
assert node.getblockchaininfo()["initialblockdownload"] is True | |||||
# Our proof cannot be verified during IBD, so we should have no peer | |||||
assert not node.getavalanchepeerinfo() | |||||
# Mining one more block should cause us to leave IBD | |||||
node.generate(1) | node.generate(1) | ||||
# Our proof is now verified and our node is added as a peer | |||||
assert node.getblockchaininfo()["initialblockdownload"] is False | |||||
wait_until(lambda: len(node.getavalanchepeerinfo()) == 1, timeout=5) | wait_until(lambda: len(node.getavalanchepeerinfo()) == 1, timeout=5) | ||||
if self.is_wallet_compiled(): | if self.is_wallet_compiled(): | ||||
self.log.info( | self.log.info( | ||||
"A proof using the maximum number of stakes is accepted...") | "A proof using the maximum number of stakes is accepted...") | ||||
new_blocks = node.generate(AVALANCHE_MAX_PROOF_STAKES // 10 + 1) | new_blocks = node.generate(AVALANCHE_MAX_PROOF_STAKES // 10 + 1) | ||||
# confirm the coinbase UTXOs | # confirm the coinbase UTXOs | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |