Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_compactproofs.py
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | class CompactProofsTest(BitcoinTestFramework): | ||||
def test_send_outbound_getavaproofs(self): | def test_send_outbound_getavaproofs(self): | ||||
self.log.info( | self.log.info( | ||||
"Check we send a getavaproofs message to our avalanche outbound peers") | "Check we send a getavaproofs message to our avalanche outbound peers") | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
p2p_idx = 0 | p2p_idx = 0 | ||||
non_avapeers = [] | non_avapeers = [] | ||||
for i in range(4): | for _ in range(4): | ||||
peer = P2PInterface() | peer = P2PInterface() | ||||
node.add_outbound_p2p_connection( | node.add_outbound_p2p_connection( | ||||
peer, | peer, | ||||
p2p_idx=p2p_idx, | p2p_idx=p2p_idx, | ||||
connection_type="outbound-full-relay", | connection_type="outbound-full-relay", | ||||
services=NODE_NETWORK, | services=NODE_NETWORK, | ||||
) | ) | ||||
non_avapeers.append(peer) | non_avapeers.append(peer) | ||||
p2p_idx += 1 | p2p_idx += 1 | ||||
inbound_avapeers = [ | inbound_avapeers = [ | ||||
node.add_p2p_connection( | node.add_p2p_connection( | ||||
AvaP2PInterface()) for _ in range(4)] | AvaP2PInterface()) for _ in range(4)] | ||||
outbound_avapeers = [] | outbound_avapeers = [] | ||||
for i in range(4): | # With the service bit set | ||||
peer = P2PInterface() | for _ in range(4): | ||||
peer = AvaP2PInterface() | |||||
node.add_outbound_p2p_connection( | node.add_outbound_p2p_connection( | ||||
peer, | peer, | ||||
p2p_idx=p2p_idx, | p2p_idx=p2p_idx, | ||||
connection_type="avalanche", | connection_type="avalanche", | ||||
services=NODE_NETWORK | NODE_AVALANCHE, | services=NODE_NETWORK | NODE_AVALANCHE, | ||||
) | ) | ||||
outbound_avapeers.append(peer) | outbound_avapeers.append(peer) | ||||
p2p_idx += 1 | p2p_idx += 1 | ||||
# Without the service bit set | |||||
for _ in range(4): | |||||
peer = AvaP2PInterface() | |||||
node.add_outbound_p2p_connection( | |||||
peer, | |||||
p2p_idx=p2p_idx, | |||||
connection_type="outbound-full-relay", | |||||
services=NODE_NETWORK, | |||||
) | |||||
outbound_avapeers.append(peer) | |||||
p2p_idx += 1 | |||||
def all_peers_received_getavaproofs(): | def all_peers_received_getavaproofs(): | ||||
with p2p_lock: | with p2p_lock: | ||||
return all([p.last_message.get("getavaproofs") | return all([p.last_message.get("getavaproofs") | ||||
for p in outbound_avapeers]) | for p in outbound_avapeers]) | ||||
self.wait_until(all_peers_received_getavaproofs) | self.wait_until(all_peers_received_getavaproofs) | ||||
with p2p_lock: | with p2p_lock: | ||||
Show All 23 Lines | def test_send_outbound_getavaproofs(self): | ||||
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]) | ||||
self.log.info( | self.log.info( | ||||
"After the first avaproofs has been received, all the peers are requested periodically") | "After the first avaproofs has been received, all the peers are requested periodically") | ||||
responding_outbound_avapeer = P2PInterface() | responding_outbound_avapeer = AvaP2PInterface() | ||||
node.add_outbound_p2p_connection( | node.add_outbound_p2p_connection( | ||||
responding_outbound_avapeer, | responding_outbound_avapeer, | ||||
p2p_idx=p2p_idx, | p2p_idx=p2p_idx, | ||||
connection_type="avalanche", | connection_type="avalanche", | ||||
services=NODE_NETWORK | NODE_AVALANCHE, | services=NODE_NETWORK | NODE_AVALANCHE, | ||||
) | ) | ||||
p2p_idx += 1 | p2p_idx += 1 | ||||
responding_outbound_avapeer_id = node.getpeerinfo()[-1]['id'] | responding_outbound_avapeer_id = node.getpeerinfo()[-1]['id'] | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | def test_request_missing_proofs(self): | ||||
with p2p_lock: | with p2p_lock: | ||||
return peer.last_message.get("avaproofsreq") | return peer.last_message.get("avaproofsreq") | ||||
p2p_idx = 0 | p2p_idx = 0 | ||||
def add_avalanche_p2p_outbound(): | def add_avalanche_p2p_outbound(): | ||||
nonlocal p2p_idx | nonlocal p2p_idx | ||||
peer = P2PInterface() | peer = AvaP2PInterface() | ||||
node.add_outbound_p2p_connection( | node.add_outbound_p2p_connection( | ||||
peer, | peer, | ||||
p2p_idx=p2p_idx, | p2p_idx=p2p_idx, | ||||
connection_type="avalanche", | connection_type="avalanche", | ||||
services=NODE_NETWORK | NODE_AVALANCHE, | services=NODE_NETWORK | NODE_AVALANCHE, | ||||
) | ) | ||||
p2p_idx += 1 | p2p_idx += 1 | ||||
▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines |