Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche.py
Show First 20 Lines • Show All 367 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
def has_parked_new_tip(): | def has_parked_new_tip(): | ||||
can_find_block_in_poll(hash_to_find, BLOCK_PARKED) | can_find_block_in_poll(hash_to_find, BLOCK_PARKED) | ||||
return node.getbestblockhash() == fork_tip | return node.getbestblockhash() == fork_tip | ||||
# Because everybody answers no, the node will park that block. | # Because everybody answers no, the node will park that block. | ||||
wait_until(has_parked_new_tip, timeout=15) | wait_until(has_parked_new_tip, timeout=15) | ||||
assert_equal(node.getbestblockhash(), fork_tip) | assert_equal(node.getbestblockhash(), fork_tip) | ||||
# Restart the node and rebuild the quorum | # Restart the node | ||||
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( | |||||
"The proof verification should be delayed until IBD is complete") | |||||
assert node.getblockchaininfo()["initialblockdownload"] is True | |||||
# Our proof cannot be verified during IBD, so we should have no peer | |||||
assert not node.getavalanchepeerinfo() | |||||
# Mining a few more blocks should cause us to leave IBD | |||||
node.generate(2) | |||||
# Our proof is now verified and our node is added as a peer | |||||
assert node.getblockchaininfo()["initialblockdownload"] is False | |||||
assert_equal(len(node.getavalanchepeerinfo()), 1) | |||||
# Rebuild the quorum | |||||
self.log.info("Test the avahello signature") | |||||
quorum = get_quorum() | quorum = get_quorum() | ||||
poll_node = quorum[0] | poll_node = quorum[0] | ||||
# Check the avahello is consistent | |||||
avahello = poll_node.wait_for_avahello().hello | avahello = poll_node.wait_for_avahello().hello | ||||
avakey.set(bytes.fromhex(node.getavalanchekey())) | avakey.set(bytes.fromhex(node.getavalanchekey())) | ||||
assert avakey.verify_schnorr( | assert avakey.verify_schnorr( | ||||
avahello.sig, avahello.get_sighash(poll_node)) | avahello.sig, avahello.get_sighash(poll_node)) | ||||
# Check the maximum number of stakes policy | # Check the maximum number of stakes policy | ||||
blocks = node.generatetoaddress(AVALANCHE_MAX_PROOF_STAKES + 1, | blocks = node.generatetoaddress(AVALANCHE_MAX_PROOF_STAKES + 1, | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |