Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_compactproofs.py
Show First 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | def test_send_outbound_getavaproofs(self): | ||||
# Now the node will request from all its peers at each time period | # Now the node will request from all its peers at each time period | ||||
outbounds_getavaproofs = count_outbounds_getavaproofs() | outbounds_getavaproofs = count_outbounds_getavaproofs() | ||||
num_outbound_avapeers = len(outbound_avapeers) | num_outbound_avapeers = len(outbound_avapeers) | ||||
node.mockscheduler(AVALANCHE_MAX_PERIODIC_NETWORKING_INTERVAL) | node.mockscheduler(AVALANCHE_MAX_PERIODIC_NETWORKING_INTERVAL) | ||||
self.wait_until(lambda: count_outbounds_getavaproofs() | self.wait_until(lambda: count_outbounds_getavaproofs() | ||||
== outbounds_getavaproofs + num_outbound_avapeers) | == outbounds_getavaproofs + num_outbound_avapeers) | ||||
outbounds_getavaproofs += num_outbound_avapeers | outbounds_getavaproofs += num_outbound_avapeers | ||||
self.log.info("Empty avaproofs will not trigger any request") | |||||
for p in outbound_avapeers: | for p in outbound_avapeers: | ||||
with node.assert_debug_log(["received: avaproofs"], ["Ignoring unsollicited avaproofs"]): | |||||
p.send_message(build_msg_avaproofs([])) | p.send_message(build_msg_avaproofs([])) | ||||
with p2p_lock: | with p2p_lock: | ||||
# Only this peer actually sent a proof | |||||
assert_equal( | |||||
responding_outbound_avapeer.message_count.get( | |||||
"avaproofsreq", 0), 1) | |||||
assert_equal(sum([p.message_count.get("avaproofsreq", 0) | |||||
for p in outbound_avapeers]), 1) | |||||
# Sanity checks | |||||
assert all([p.message_count.get( | assert all([p.message_count.get( | ||||
"getavaproofs", 0) == 0 for p in non_avapeers]) | "getavaproofs", 0) == 0 for p in non_avapeers]) | ||||
assert all([p.message_count.get( | assert all([p.message_count.get( | ||||
"getavaproofs", 0) == 0 for p in inbound_avapeers]) | "getavaproofs", 0) == 0 for p in inbound_avapeers]) | ||||
def test_send_manual_getavaproofs(self): | def test_send_manual_getavaproofs(self): | ||||
self.log.info( | self.log.info( | ||||
"Check we send a getavaproofs message to our manually connected peers that support avalanche") | "Check we send a getavaproofs message to our manually connected peers that support avalanche") | ||||
▲ Show 20 Lines • Show All 481 Lines • Show Last 20 Lines |