Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_avalancheproof.py
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
node.delegateavalancheproof, | node.delegateavalancheproof, | ||||
proof, | proof, | ||||
bytes_to_wif(privkey.get_bytes()), | bytes_to_wif(privkey.get_bytes()), | ||||
random_pubkey, | random_pubkey, | ||||
delegation, | delegation, | ||||
) | ) | ||||
# Test invalid proofs | # Test invalid proofs | ||||
self.log.info("Bad proof should be rejected at startup") | |||||
dust = node.buildavalancheproof( | dust = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, proof_master, | proof_sequence, proof_expiration, proof_master, | ||||
create_coinbase_stakes(node, [blockhashes[0]], addrkey0.key, amount="0")) | create_coinbase_stakes(node, [blockhashes[0]], addrkey0.key, amount="0")) | ||||
dust_amount = Decimal(f"{PROOF_DUST_THRESHOLD * 0.9999:.4f}") | dust_amount = Decimal(f"{PROOF_DUST_THRESHOLD * 0.9999:.4f}") | ||||
dust2 = node.buildavalancheproof( | dust2 = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, proof_master, | proof_sequence, proof_expiration, proof_master, | ||||
create_coinbase_stakes(node, [blockhashes[0]], addrkey0.key, | create_coinbase_stakes(node, [blockhashes[0]], addrkey0.key, | ||||
amount=str(dust_amount))) | amount=str(dust_amount))) | ||||
duplicate_stake = node.buildavalancheproof( | duplicate_stake = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, proof_master, | proof_sequence, proof_expiration, proof_master, | ||||
create_coinbase_stakes(node, [blockhashes[0]] * 2, addrkey0.key)) | create_coinbase_stakes(node, [blockhashes[0]] * 2, addrkey0.key)) | ||||
bad_sig = ("0b000000000000000c0000000000000021030b4c866585dd868a9d62348" | bad_sig = ("0b000000000000000c0000000000000021030b4c866585dd868a9d62348" | ||||
"a9cd008d6a312937048fff31670e7e920cfc7a7440105c5f72f5d6da3085" | "a9cd008d6a312937048fff31670e7e920cfc7a7440105c5f72f5d6da3085" | ||||
"583e75ee79340eb4eff208c89988e7ed0efb30b87298fa30000000000f20" | "583e75ee79340eb4eff208c89988e7ed0efb30b87298fa30000000000f20" | ||||
"52a0100000003000000210227d85ba011276cf25b51df6a188b75e604b3" | "52a0100000003000000210227d85ba011276cf25b51df6a188b75e604b3" | ||||
"8770a462b2d0e9fb2fc839ef5d3faf07f001dd38e9b4a43d07d5d449cc0" | "8770a462b2d0e9fb2fc839ef5d3faf07f001dd38e9b4a43d07d5d449cc0" | ||||
"f7d2888d96b82962b3ce516d1083c0e031773487fc3c4f2e38acd1db974" | "f7d2888d96b82962b3ce516d1083c0e031773487fc3c4f2e38acd1db974" | ||||
"1321b91a79b82d1c2cfd47793261e4ba003cf5") | "1321b91a79b82d1c2cfd47793261e4ba003cf5") | ||||
self.log.info("Check the verifyavalancheproof RPC") | |||||
assert_raises_rpc_error(-8, "Proof must be an hexadecimal string", | |||||
node.verifyavalancheproof, "f00") | |||||
assert_raises_rpc_error(-8, "Proof has invalid format", | |||||
node.verifyavalancheproof, "f00d") | |||||
def check_verifyavalancheproof_failure(proof, message): | |||||
assert_raises_rpc_error(-8, "The proof is invalid: " + message, | |||||
node.verifyavalancheproof, proof) | |||||
check_verifyavalancheproof_failure(no_stake, "no-stake") | |||||
check_verifyavalancheproof_failure(dust, "amount-below-dust-threshold") | |||||
check_verifyavalancheproof_failure(duplicate_stake, "duplicated-stake") | |||||
check_verifyavalancheproof_failure(bad_sig, "invalid-signature") | |||||
if self.is_wallet_compiled(): | |||||
check_verifyavalancheproof_failure( | |||||
too_many_utxos, "too-many-utxos") | |||||
# Good proof | |||||
assert node.verifyavalancheproof(proof) | |||||
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", | ||||
], | ], | ||||
expected_msg="Error: the avalanche session key is invalid", | expected_msg="Error: the avalanche session key is invalid", | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |