Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche.py
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | def get_avapoll_if_available(self): | ||||
return self.avapolls.pop(0) if len(self.avapolls) > 0 else None | return self.avapolls.pop(0) if len(self.avapolls) > 0 else None | ||||
class AvalancheTest(BitcoinTestFramework): | class AvalancheTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 2 | self.num_nodes = 2 | ||||
self.extra_args = [ | self.extra_args = [ | ||||
['-enableavalanche=1', '-avacooldown=0'], | ['-enableavalanche=1', '-avacooldown=0', '-automaticunparking=0'], | ||||
['-enableavalanche=1', '-avacooldown=0', '-noparkdeepreorg', '-maxreorgdepth=-1']] | ['-enableavalanche=1', '-avacooldown=0', '-noparkdeepreorg', '-maxreorgdepth=-1']] | ||||
def run_test(self): | def run_test(self): | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
# Build a fake quorum of nodes. | # Build a fake quorum of nodes. | ||||
quorum = [] | quorum = [] | ||||
for i in range(0, 16): | for i in range(0, 16): | ||||
▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
def has_accepted_new_tip(): | def has_accepted_new_tip(): | ||||
can_find_block_in_poll(hash_to_find) | can_find_block_in_poll(hash_to_find) | ||||
return node.getbestblockhash() == fork_tip | return node.getbestblockhash() == fork_tip | ||||
# Because everybody answers yes, the node will accept that block. | # Because everybody answers yes, the node will accept that block. | ||||
wait_until(has_accepted_new_tip, timeout=15) | wait_until(has_accepted_new_tip, timeout=15) | ||||
assert_equal(node.getbestblockhash(), fork_tip) | assert_equal(node.getbestblockhash(), fork_tip) | ||||
self.log.info("Answer all polls to park...") | |||||
node.generate(1) | |||||
tip_to_park = node.getbestblockhash() | |||||
self.log.info(tip_to_park) | |||||
hash_to_find = int(tip_to_park, 16) | |||||
assert(tip_to_park != fork_tip) | |||||
def has_parked_new_tip(): | |||||
can_find_block_in_poll(hash_to_find, BLOCK_REJECTED) | |||||
return node.getbestblockhash() == fork_tip | |||||
# Because everybody answers no, the node will park that block. | |||||
wait_until(has_parked_new_tip, timeout=15) | |||||
assert_equal(node.getbestblockhash(), fork_tip) | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
AvalancheTest().main() | AvalancheTest().main() |