Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_avalancheproof.py
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
proof_master = get_hex_pubkey(privkey) | proof_master = get_hex_pubkey(privkey) | ||||
proof_sequence = 11 | proof_sequence = 11 | ||||
proof_expiration = 12 | proof_expiration = 12 | ||||
proof = node.buildavalancheproof( | proof = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, proof_master, | proof_sequence, proof_expiration, proof_master, | ||||
get_stakes(node, [blockhashes[0]], addrkey0.key)) | get_stakes(node, [blockhashes[0]], addrkey0.key)) | ||||
# Restart the node, making sure it is initially in IBD mode | # Restart the node, making sure it is initially in IBD mode | ||||
avamasterkey = "cND2ZvtabDbJ1gucx9GWH6XT9kgTAqfb6cotPt5Q5CyxVDhid2EN" | |||||
minchainwork = int(node.getblockchaininfo()["chainwork"], 16) + 1 | 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), | f"-avaproof={proof}", | ||||
"-avamasterkey=cND2ZvtabDbJ1gucx9GWH6XT9kgTAqfb6cotPt5Q5CyxVDhid2EN", | f"-avamasterkey={avamasterkey}", | ||||
"-minimumchainwork=0x{:x}".format(minchainwork), | f"-minimumchainwork=0x{minchainwork:x}", | ||||
]) | ]) | ||||
self.log.info( | self.log.info( | ||||
"The proof verification should be delayed until IBD is complete") | "The proof verification should be delayed until IBD is complete") | ||||
assert node.getblockchaininfo()["initialblockdownload"] is True | assert node.getblockchaininfo()["initialblockdownload"] is True | ||||
# Our proof cannot be verified during IBD, so we should have no peer | # Our proof cannot be verified during IBD, so we should have no peer | ||||
assert not node.getavalanchepeerinfo() | assert not node.getavalanchepeerinfo() | ||||
# Mining a few more blocks should cause us to leave IBD | # Mining a few more blocks should cause us to leave IBD | ||||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
"583e75ee79340eb4eff208c89988e7ed0efb30b87298fa30000000000f20" | "583e75ee79340eb4eff208c89988e7ed0efb30b87298fa30000000000f20" | ||||
"52a0100000003000000210227d85ba011276cf25b51df6a188b75e604b3" | "52a0100000003000000210227d85ba011276cf25b51df6a188b75e604b3" | ||||
"8770a462b2d0e9fb2fc839ef5d3faf07f001dd38e9b4a43d07d5d449cc0" | "8770a462b2d0e9fb2fc839ef5d3faf07f001dd38e9b4a43d07d5d449cc0" | ||||
"f7d2888d96b82962b3ce516d1083c0e031773487fc3c4f2e38acd1db974" | "f7d2888d96b82962b3ce516d1083c0e031773487fc3c4f2e38acd1db974" | ||||
"1321b91a79b82d1c2cfd47793261e4ba003cf5") | "1321b91a79b82d1c2cfd47793261e4ba003cf5") | ||||
self.stop_node(0) | self.stop_node(0) | ||||
init_error_msg = "Error: Failed to initialize avalanche" | |||||
debug_msg_head = "Failed basic avaproof verification: " | |||||
def check_proof_init_error(proof, message): | def check_proof_init_error(proof, message): | ||||
with node.assert_debug_log([debug_msg_head + message]): | |||||
node.assert_start_raises_init_error( | node.assert_start_raises_init_error( | ||||
self.extra_args[0] + [ | self.extra_args[0] + [ | ||||
"-avaproof={}".format(proof), | f"-avaproof={proof}", | ||||
"-avamasterkey=cND2ZvtabDbJ1gucx9GWH6XT9kgTAqfb6cotPt5Q5CyxVDhid2EN", | f"-avamasterkey={avamasterkey}", | ||||
], | ], | ||||
expected_msg="Error: " + message, | expected_msg=init_error_msg, | ||||
) | ) | ||||
check_proof_init_error(no_stake, | check_proof_init_error(no_stake, | ||||
"the avalanche proof has no stake") | "the avalanche proof has no stake") | ||||
check_proof_init_error(dust, | check_proof_init_error(dust, | ||||
"the avalanche proof stake is too low") | "the avalanche proof stake is too low") | ||||
check_proof_init_error(duplicate_stake, | check_proof_init_error(duplicate_stake, | ||||
"the avalanche proof has duplicated stake") | "the avalanche proof has duplicated stake") | ||||
check_proof_init_error(bad_sig, | check_proof_init_error(bad_sig, | ||||
"the avalanche proof has invalid stake signatures") | "the avalanche proof has invalid stake signatures") | ||||
# The too many utxos case creates a proof which is that large that it | # The too many utxos case creates a proof which is that large that it | ||||
# cannot fit on the command line | # cannot fit on the command line | ||||
append_config(node.datadir, ["avaproof={}".format(too_many_utxos)]) | append_config(node.datadir, ["avaproof={}".format(too_many_utxos)]) | ||||
with node.assert_debug_log( | |||||
[debug_msg_head + "the avalanche proof has too many utxos"]): | |||||
node.assert_start_raises_init_error( | node.assert_start_raises_init_error( | ||||
self.extra_args[0] + [ | self.extra_args[0] + [ | ||||
"-avamasterkey=cND2ZvtabDbJ1gucx9GWH6XT9kgTAqfb6cotPt5Q5CyxVDhid2EN", | f"-avamasterkey={avamasterkey}", | ||||
], | ], | ||||
expected_msg="Error: the avalanche proof has too many utxos", | expected_msg=init_error_msg, | ||||
match=ErrorMatch.PARTIAL_REGEX, | match=ErrorMatch.PARTIAL_REGEX, | ||||
) | ) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
AvalancheProofTest().main() | AvalancheProofTest().main() |