Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_proof_inventory.py
Show First 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | def test_proof_relay(self): | ||||
proofids = restart_nodes_with_proof(self.nodes) | proofids = restart_nodes_with_proof(self.nodes) | ||||
self.log.info("Nodes should eventually get the proof from their peer") | self.log.info("Nodes should eventually get the proof from their peer") | ||||
self.sync_proofs() | self.sync_proofs() | ||||
for node in self.nodes: | for node in self.nodes: | ||||
assert_equal(set(get_proof_ids(node)), proofids) | assert_equal(set(get_proof_ids(node)), proofids) | ||||
def test_manually_sent_proof(self): | |||||
node0 = self.nodes[0] | |||||
_, proof = self.gen_proof(node0) | |||||
self.log.info( | |||||
"Send a proof via RPC and check all the nodes download it") | |||||
node0.sendavalancheproof(proof.serialize().hex()) | |||||
self.sync_proofs() | |||||
def test_unbroadcast(self): | def test_unbroadcast(self): | ||||
self.log.info("Test broadcasting proofs") | self.log.info("Test broadcasting proofs") | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
# Disconnect the other nodes, or they will request the proof and | |||||
# invalidate the test | |||||
[node.stop_node() for node in self.nodes[1:]] | |||||
def add_peers(count): | def add_peers(count): | ||||
peers = [] | peers = [] | ||||
for i in range(count): | for i in range(count): | ||||
peer = node.add_p2p_connection(ProofInvStoreP2PInterface()) | peer = node.add_p2p_connection(ProofInvStoreP2PInterface()) | ||||
peer.wait_for_verack() | peer.wait_for_verack() | ||||
peers.append(peer) | peers.append(peer) | ||||
return peers | return peers | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | def test_unbroadcast(self): | ||||
assert not proof_inv_received(peers) | assert not proof_inv_received(peers) | ||||
def run_test(self): | def run_test(self): | ||||
self.test_send_proof_inv() | self.test_send_proof_inv() | ||||
self.test_receive_proof() | self.test_receive_proof() | ||||
self.test_ban_invalid_proof() | self.test_ban_invalid_proof() | ||||
self.test_proof_relay() | self.test_proof_relay() | ||||
self.test_manually_sent_proof() | |||||
# Run this test last because it needs to disconnect the nodes | |||||
self.test_unbroadcast() | self.test_unbroadcast() | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
ProofInventoryTest().main() | ProofInventoryTest().main() |