Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_proof_inventory.py
| Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | def test_unbroadcast(self): | ||||
| # It should no longer be broadcasted | # It should no longer be broadcasted | ||||
| peers = add_peers(3) | peers = add_peers(3) | ||||
| node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY + 1) | node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY + 1) | ||||
| peers[-1].sync_with_ping() | peers[-1].sync_with_ping() | ||||
| assert not proof_inv_received(peers) | assert not proof_inv_received(peers) | ||||
| def test_local_proof_broadcast(self): | |||||
| node = self.nodes[0] | |||||
| privkey, proof = gen_proof(node) | |||||
| proofid_hex = "{:064x}".format(proof.proofid) | |||||
| [node.stop_node() for node in self.nodes[1:]] | |||||
| self.restart_node(0, self.extra_args[0] + [ | |||||
| "-avaproof={}".format(proof.serialize().hex()), | |||||
| "-avamasterkey={}".format(bytes_to_wif(privkey.get_bytes())), | |||||
| ]) | |||||
| peers = [] | |||||
| for _ in range(10): | |||||
| peers.append(node.add_p2p_connection(ProofInvStoreP2PInterface())) | |||||
| with p2p_lock: | |||||
| assert all([p.proof_invs_counter == 0 for p in peers]) | |||||
| # Mine a block so the proof gets validated | |||||
| node.generate(1) | |||||
| wait_for_proof(node, proofid_hex) | |||||
| node.mockscheduler(MAX_INITIAL_BROADCAST_DELAY + 1) | |||||
| def proof_inv_received(): | |||||
| with p2p_lock: | |||||
| return all(p.last_message.get( | |||||
| "inv") and p.last_message["inv"].inv[-1].hash == proof.proofid for p in peers) | |||||
| self.wait_until(proof_inv_received) | |||||
| 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_proof_relay() | self.test_proof_relay() | ||||
| self.test_manually_sent_proof() | self.test_manually_sent_proof() | ||||
| # Run these tests last because they need to disconnect the nodes | # Run these tests last because they need to disconnect the nodes | ||||
| self.test_unbroadcast() | self.test_unbroadcast() | ||||
| self.test_ban_invalid_proof() | self.test_ban_invalid_proof() | ||||
| self.test_local_proof_broadcast() | |||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||
| ProofInventoryTest().main() | ProofInventoryTest().main() | ||||