Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_avalancheproof.py
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
expect_orphan=True) | expect_orphan=True) | ||||
self.log.info("Connect to an up-to-date node to unorphan the proof") | self.log.info("Connect to an up-to-date node to unorphan the proof") | ||||
connect_nodes(self.nodes[1], node) | connect_nodes(self.nodes[1], node) | ||||
self.sync_all() | self.sync_all() | ||||
wait_for_proof(self.nodes[1], f"{proofobj.proofid:0{64}x}", | wait_for_proof(self.nodes[1], f"{proofobj.proofid:0{64}x}", | ||||
expect_orphan=False) | expect_orphan=False) | ||||
if self.is_wallet_compiled(): | |||||
self.log.info( | |||||
"A proof using the maximum number of stakes is accepted...") | |||||
new_blocks = node.generate(AVALANCHE_MAX_PROOF_STAKES // 10 + 1) | |||||
# confirm the coinbase UTXOs | |||||
node.generate(101) | |||||
too_many_stakes = create_stakes( | |||||
node, new_blocks, AVALANCHE_MAX_PROOF_STAKES + 1) | |||||
maximum_stakes = too_many_stakes[:-1] | |||||
good_proof = node.buildavalancheproof( | |||||
proof_sequence, proof_expiration, | |||||
proof_master, maximum_stakes) | |||||
peerid1 = add_interface_node(node) | |||||
assert node.addavalanchenode(peerid1, proof_master, good_proof) | |||||
self.log.info( | |||||
"A proof using too many stakes should be rejected...") | |||||
too_many_utxos = node.buildavalancheproof( | |||||
proof_sequence, proof_expiration, | |||||
proof_master, too_many_stakes) | |||||
peerid2 = add_interface_node(node) | |||||
assert not node.addavalanchenode( | |||||
peerid2, proof_master, too_many_utxos) | |||||
self.log.info("Generate delegations for the proof") | self.log.info("Generate delegations for the proof") | ||||
# Stack up a few delegation levels | # Stack up a few delegation levels | ||||
def gen_privkey(): | def gen_privkey(): | ||||
pk = ECKey() | pk = ECKey() | ||||
pk.generate() | pk.generate() | ||||
return pk | return pk | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
"583e75ee79340eb4eff208c89988e7ed0efb30b87298fa30000000000f20" | "583e75ee79340eb4eff208c89988e7ed0efb30b87298fa30000000000f20" | ||||
"52a0100000003000000210227d85ba011276cf25b51df6a188b75e604b3" | "52a0100000003000000210227d85ba011276cf25b51df6a188b75e604b3" | ||||
"8770a462b2d0e9fb2fc839ef5d3faf07f001dd38e9b4a43d07d5d449cc0" | "8770a462b2d0e9fb2fc839ef5d3faf07f001dd38e9b4a43d07d5d449cc0" | ||||
"f7d2888d96b82962b3ce516d1083c0e031773487fc3c4f2e38acd1db974" | "f7d2888d96b82962b3ce516d1083c0e031773487fc3c4f2e38acd1db974" | ||||
"1321b91a79b82d1c2cfd47793261e4ba003cf5") | "1321b91a79b82d1c2cfd47793261e4ba003cf5") | ||||
self.log.info( | self.log.info( | ||||
"Check the verifyavalancheproof and sendavalancheproof RPCs") | "Check the verifyavalancheproof and sendavalancheproof RPCs") | ||||
if self.is_wallet_compiled(): | |||||
self.log.info( | |||||
"Check a proof with the maximum number of UTXO is valid") | |||||
new_blocks = node.generate(AVALANCHE_MAX_PROOF_STAKES // 10 + 1) | |||||
# confirm the coinbase UTXOs | |||||
node.generate(101) | |||||
too_many_stakes = create_stakes( | |||||
node, new_blocks, AVALANCHE_MAX_PROOF_STAKES + 1) | |||||
maximum_stakes = too_many_stakes[:-1] | |||||
good_proof = node.buildavalancheproof( | |||||
proof_sequence, proof_expiration, | |||||
proof_master, maximum_stakes) | |||||
too_many_utxos = node.buildavalancheproof( | |||||
proof_sequence, proof_expiration, | |||||
proof_master, too_many_stakes) | |||||
assert node.verifyavalancheproof(good_proof) | |||||
for rpc in [node.verifyavalancheproof, node.sendavalancheproof]: | for rpc in [node.verifyavalancheproof, node.sendavalancheproof]: | ||||
assert_raises_rpc_error(-22, "Proof must be an hexadecimal string", | assert_raises_rpc_error(-22, "Proof must be an hexadecimal string", | ||||
rpc, "f00") | rpc, "f00") | ||||
assert_raises_rpc_error(-22, "Proof has invalid format", | assert_raises_rpc_error(-22, "Proof has invalid format", | ||||
rpc, "f00d") | rpc, "f00d") | ||||
def check_rpc_failure(proof, message): | def check_rpc_failure(proof, message): | ||||
assert_raises_rpc_error(-8, "The proof is invalid: " + message, | assert_raises_rpc_error(-8, "The proof is invalid: " + message, | ||||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |