Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_compactproofs.py
Show First 20 Lines • Show All 604 Lines • ▼ Show 20 Lines | def test_no_compactproofs_during_ibs(self): | ||||
# Make sure there is no message sent as part as the periodic network | # Make sure there is no message sent as part as the periodic network | ||||
# messaging either | # messaging either | ||||
node.mockscheduler(AVALANCHE_MAX_PERIODIC_NETWORKING_INTERVAL) | node.mockscheduler(AVALANCHE_MAX_PERIODIC_NETWORKING_INTERVAL) | ||||
peer.sync_send_with_ping() | peer.sync_send_with_ping() | ||||
with p2p_lock: | with p2p_lock: | ||||
assert_equal(peer.message_count.get("getavaproofs", 0), 0) | assert_equal(peer.message_count.get("getavaproofs", 0), 0) | ||||
def test_send_inbound_getavaproofs_until_quorum_is_established(self): | |||||
self.log.info( | |||||
"Check we also request the inbounds until the quorum is established") | |||||
node = self.nodes[0] | |||||
self.restart_node( | |||||
0, | |||||
extra_args=self.extra_args[0] + | |||||
['-avaminquorumstake=1000000']) | |||||
assert_equal(node.getavalancheinfo()['active'], False) | |||||
outbound = HelloAvaP2PInterface() | |||||
node.add_outbound_p2p_connection(outbound, p2p_idx=0) | |||||
inbound = HelloAvaP2PInterface() | |||||
node.add_p2p_connection(inbound) | |||||
inbound.nodeid = node.getpeerinfo()[-1]['id'] | |||||
def count_getavaproofs(peers): | |||||
with p2p_lock: | |||||
return sum([peer.message_count.get("getavaproofs", 0) | |||||
for peer in peers]) | |||||
# Upon connection only the outbound gets a compact proofs message | |||||
assert_equal(count_getavaproofs([inbound]), 0) | |||||
self.wait_until(lambda: count_getavaproofs([outbound]) == 1) | |||||
# Periodic send will include the inbound as well | |||||
current_total = count_getavaproofs([inbound, outbound]) | |||||
while count_getavaproofs([inbound]) == 0: | |||||
node.mockscheduler(AVALANCHE_MAX_PERIODIC_NETWORKING_INTERVAL) | |||||
self.wait_until(lambda: count_getavaproofs( | |||||
[inbound, outbound]) > current_total) | |||||
current_total = count_getavaproofs([inbound, outbound]) | |||||
# Connect the minimum amount of stake | |||||
privkey, proof = gen_proof(node) | |||||
assert node.addavalanchenode( | |||||
inbound.nodeid, | |||||
privkey.get_pubkey().get_bytes().hex(), | |||||
proof.serialize().hex()) | |||||
assert_equal(node.getavalancheinfo()['active'], True) | |||||
# From now only the outbound is requested | |||||
count_inbound = count_getavaproofs([inbound]) | |||||
for _ in range(20): | |||||
node.mockscheduler(AVALANCHE_MAX_PERIODIC_NETWORKING_INTERVAL) | |||||
self.wait_until(lambda: count_getavaproofs( | |||||
[inbound, outbound]) > current_total) | |||||
current_total = count_getavaproofs([inbound, outbound]) | |||||
assert_equal(count_getavaproofs([inbound]), count_inbound) | |||||
def run_test(self): | def run_test(self): | ||||
# Most if the tests only need a single node, let the other ones start | # Most if the tests only need a single node, let the other ones start | ||||
# the node when required | # the node when required | ||||
self.stop_node(1) | self.stop_node(1) | ||||
self.test_send_outbound_getavaproofs() | self.test_send_outbound_getavaproofs() | ||||
self.test_send_manual_getavaproofs() | self.test_send_manual_getavaproofs() | ||||
self.test_respond_getavaproofs() | self.test_respond_getavaproofs() | ||||
self.test_request_missing_proofs() | self.test_request_missing_proofs() | ||||
self.test_send_missing_proofs() | self.test_send_missing_proofs() | ||||
self.test_compact_proofs_download_on_connect() | self.test_compact_proofs_download_on_connect() | ||||
self.test_no_compactproofs_during_ibs() | self.test_no_compactproofs_during_ibs() | ||||
self.test_send_inbound_getavaproofs_until_quorum_is_established() | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
CompactProofsTest().main() | CompactProofsTest().main() |