Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche.py
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | def set_test_params(self): | ||||
['-enableavalanche=1', '-avacooldown=0'], | ['-enableavalanche=1', '-avacooldown=0'], | ||||
['-enableavalanche=1', '-avacooldown=0', '-noparkdeepreorg', '-maxreorgdepth=-1']] | ['-enableavalanche=1', '-avacooldown=0', '-noparkdeepreorg', '-maxreorgdepth=-1']] | ||||
self.supports_cli = False | self.supports_cli = False | ||||
self.rpc_timeout = 120 | self.rpc_timeout = 120 | ||||
def run_test(self): | def run_test(self): | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
self.log.info("Check the node is signalling the avalanche service.") | |||||
assert_equal( | |||||
int(node.getnetworkinfo()['localservices'], 16) & NODE_AVALANCHE, | |||||
NODE_AVALANCHE) | |||||
# Build a fake quorum of nodes. | # Build a fake quorum of nodes. | ||||
def get_node(): | def get_node(): | ||||
n = TestNode() | n = TestNode() | ||||
node.add_p2p_connection( | node.add_p2p_connection( | ||||
n, services=NODE_NETWORK | NODE_AVALANCHE) | n, services=NODE_NETWORK | NODE_AVALANCHE) | ||||
n.wait_for_verack() | n.wait_for_verack() | ||||
# Get our own node id so we can use it later. | # Get our own node id so we can use it later. | ||||
▲ Show 20 Lines • Show All 195 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) | ||||
self.log.info( | |||||
"Check the node is signalling the avalanche service bit only if there is a proof.") | |||||
assert_equal( | |||||
int(node.getnetworkinfo()['localservices'], 16) & NODE_AVALANCHE, | |||||
0) | |||||
# Restart the node | # Restart the node | ||||
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", | ||||
]) | ]) | ||||
assert_equal( | |||||
int(node.getnetworkinfo()['localservices'], 16) & NODE_AVALANCHE, | |||||
NODE_AVALANCHE) | |||||
self.log.info("Test the avahello signature") | self.log.info("Test the avahello signature") | ||||
quorum = get_quorum() | quorum = get_quorum() | ||||
poll_node = quorum[0] | poll_node = quorum[0] | ||||
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)) | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
AvalancheTest().main() | AvalancheTest().main() |