Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_getavaaddr.py
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
class AvaAddrTest(BitcoinTestFramework): | class AvaAddrTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = False | self.setup_clean_chain = False | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [['-enableavalanche=1', | self.extra_args = [['-enableavalanche=1', | ||||
'-enableavalanchepeerdiscovery=1', | '-enableavalanchepeerdiscovery=1', | ||||
'-enableavalancheproofreplacement=1', | |||||
'-avaproofstakeutxoconfirmations=1', | '-avaproofstakeutxoconfirmations=1', | ||||
'-avacooldown=0', '-whitelist=noban@127.0.0.1']] | '-avacooldown=0', '-whitelist=noban@127.0.0.1']] | ||||
def check_all_peers_received_getavaaddr_once(self, avapeers): | def check_all_peers_received_getavaaddr_once(self, avapeers): | ||||
def received_all_getavaaddr(avapeers): | def received_all_getavaaddr(avapeers): | ||||
with p2p_lock: | with p2p_lock: | ||||
return all([p.last_message.get("getavaaddr") | return all([p.last_message.get("getavaaddr") | ||||
for p in avapeers]) | for p in avapeers]) | ||||
▲ Show 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | def getavaaddr_noquorum(self): | ||||
assert all([address in expected_addresses for address in addresses]) | assert all([address in expected_addresses for address in addresses]) | ||||
# Add more nodes so we reach the mininum quorum stake amount. | # Add more nodes so we reach the mininum quorum stake amount. | ||||
for _ in range(4): | for _ in range(4): | ||||
avapeer = AllYesAvaP2PInterface(node) | avapeer = AllYesAvaP2PInterface(node) | ||||
node.add_p2p_connection(avapeer) | node.add_p2p_connection(avapeer) | ||||
self.wait_until(lambda: node.getavalancheinfo()['active'] is True) | self.wait_until(lambda: node.getavalancheinfo()['active'] is True) | ||||
# From now only a single outbound peer is requested periodically | def is_vote_finalized(proof): | ||||
return node.getrawavalancheproof( | |||||
f"{proof.proofid:0{64}x}").get("finalized", False) | |||||
# Wait until all proofs are finalized | |||||
self.wait_until(lambda: all([is_vote_finalized(p.proof) | |||||
for p in node.p2ps if isinstance(p, AvaP2PInterface)])) | |||||
# Go through a round of getavaaddr requests. We don't know for sure how | |||||
# many will be sent as it depends on whether the peers responded fast | |||||
# enough during the polling phase. | |||||
total_getavaaddr = total_getavaaddr_msg() | |||||
node.mockscheduler(MAX_GETAVAADDR_DELAY) | |||||
self.wait_until(lambda: total_getavaaddr_msg() >= total_getavaaddr + 1) | |||||
# But from now only a single outbound peer is requested periodically | |||||
total_getavaaddr = total_getavaaddr_msg() | total_getavaaddr = total_getavaaddr_msg() | ||||
node.mockscheduler(MAX_GETAVAADDR_DELAY) | node.mockscheduler(MAX_GETAVAADDR_DELAY) | ||||
self.wait_until(lambda: total_getavaaddr_msg() == total_getavaaddr + 1) | self.wait_until(lambda: total_getavaaddr_msg() == total_getavaaddr + 1) | ||||
# And no more | # And no more | ||||
for p in avapeers: | for p in avapeers: | ||||
p.sync_send_with_ping() | p.sync_send_with_ping() | ||||
assert_equal(total_getavaaddr_msg(), total_getavaaddr + 1) | assert_equal(total_getavaaddr_msg(), total_getavaaddr + 1) | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |