Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_avalancheproof.py
Show All 11 Lines | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import ( | ||||
assert_equal, | assert_equal, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
) | ) | ||||
AVALANCHE_MAX_PROOF_STAKES = 1000 | AVALANCHE_MAX_PROOF_STAKES = 1000 | ||||
PROOF_DUST_THRESHOLD = 1.0 | |||||
"""Minimum amount per UTXO in a proof (in coins, not in satoshis)""" | |||||
def add_interface_node(test_node) -> str: | def add_interface_node(test_node) -> str: | ||||
"""Create a mininode, connect it to test_node, return the nodeid | """Create a mininode, connect it to test_node, return the nodeid | ||||
of the mininode as registered by test_node. | of the mininode as registered by test_node. | ||||
""" | """ | ||||
n = P2PInterface() | n = P2PInterface() | ||||
test_node.add_p2p_connection(n) | test_node.add_p2p_connection(n) | ||||
n.wait_for_verack() | n.wait_for_verack() | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.log.info("Bad proof should be rejected at startup") | self.log.info("Bad proof should be rejected at startup") | ||||
no_stake = node.buildavalancheproof( | no_stake = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, proof_master, []) | proof_sequence, proof_expiration, proof_master, []) | ||||
dust = node.buildavalancheproof( | dust = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, proof_master, | proof_sequence, proof_expiration, proof_master, | ||||
get_stakes(node, [blockhashes[0]], addrkey0.key, amount="0")) | get_stakes(node, [blockhashes[0]], addrkey0.key, amount="0")) | ||||
dust2 = node.buildavalancheproof( | |||||
proof_sequence, proof_expiration, proof_master, | |||||
get_stakes(node, [blockhashes[0]], addrkey0.key, | |||||
amount=f"{PROOF_DUST_THRESHOLD * 0.9999}")) | |||||
duplicate_stake = node.buildavalancheproof( | duplicate_stake = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, proof_master, | proof_sequence, proof_expiration, proof_master, | ||||
get_stakes(node, [blockhashes[0]] * 2, addrkey0.key)) | get_stakes(node, [blockhashes[0]] * 2, addrkey0.key)) | ||||
bad_sig = ("0b000000000000000c0000000000000021030b4c866585dd868a9d62348" | bad_sig = ("0b000000000000000c0000000000000021030b4c866585dd868a9d62348" | ||||
"a9cd008d6a312937048fff31670e7e920cfc7a7440105c5f72f5d6da3085" | "a9cd008d6a312937048fff31670e7e920cfc7a7440105c5f72f5d6da3085" | ||||
"583e75ee79340eb4eff208c89988e7ed0efb30b87298fa30000000000f20" | "583e75ee79340eb4eff208c89988e7ed0efb30b87298fa30000000000f20" | ||||
"52a0100000003000000210227d85ba011276cf25b51df6a188b75e604b3" | "52a0100000003000000210227d85ba011276cf25b51df6a188b75e604b3" | ||||
Show All 11 Lines | def run_test(self): | ||||
], | ], | ||||
expected_msg="Error: " + message, | expected_msg="Error: " + message, | ||||
) | ) | ||||
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(dust2, | |||||
"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") | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
AvalancheProofTest().main() | AvalancheProofTest().main() |