diff --git a/test/functional/abc_p2p_proof_inventory.py b/test/functional/abc_p2p_proof_inventory.py --- a/test/functional/abc_p2p_proof_inventory.py +++ b/test/functional/abc_p2p_proof_inventory.py @@ -122,7 +122,7 @@ msg.proof = orphan peer.send_message(msg) - wait_for_proof(node, orphan_proofid, expect_orphan=True) + wait_for_proof(node, orphan_proofid, expect_status="orphan") def test_ban_invalid_proof(self): node = self.nodes[0] @@ -251,7 +251,7 @@ self.wait_until(lambda: proof_inv_received(peers)) # Sanity check our node knows the proof, and it is valid - wait_for_proof(node, proofid_hex, expect_orphan=False) + wait_for_proof(node, proofid_hex) # Mature the utxo then spend it node.generate(100) diff --git a/test/functional/abc_rpc_avalancheproof.py b/test/functional/abc_rpc_avalancheproof.py --- a/test/functional/abc_rpc_avalancheproof.py +++ b/test/functional/abc_rpc_avalancheproof.py @@ -216,11 +216,11 @@ self.connect_nodes(1, node.index) self.sync_all() self.nodes[1].generate(1) - wait_for_proof(self.nodes[1], proofid_hex, expect_orphan=True) + wait_for_proof(self.nodes[1], proofid_hex, expect_status="orphan") # Mine another block to make the orphan mature self.nodes[1].generate(1) - wait_for_proof(self.nodes[0], proofid_hex, expect_orphan=False) + wait_for_proof(self.nodes[0], proofid_hex) self.log.info( "Generate delegations for the proof, verify and decode them") @@ -490,7 +490,10 @@ msg = msg_avaproof() msg.proof = conflicting_proofobj peer.send_message(msg) - wait_for_proof(node, conflicting_proofid_hex) + wait_for_proof( + node, + conflicting_proofid_hex, + expect_status="conflicting") raw_proof = node.getrawavalancheproof(conflicting_proofid_hex) assert_equal(raw_proof['proof'], conflicting_proof) diff --git a/test/functional/abc_rpc_getavalancheinfo.py b/test/functional/abc_rpc_getavalancheinfo.py --- a/test/functional/abc_rpc_getavalancheinfo.py +++ b/test/functional/abc_rpc_getavalancheinfo.py @@ -180,7 +180,7 @@ quorum.append(n) n.send_avaproof(_proof) - wait_for_proof(node, f"{_proof.proofid:0{64}x}", timeout=10) + wait_for_proof(node, f"{_proof.proofid:0{64}x}") mock_time += self.conflicting_proof_cooldown node.setmocktime(mock_time) diff --git a/test/functional/p2p_inv_download.py b/test/functional/p2p_inv_download.py --- a/test/functional/p2p_inv_download.py +++ b/test/functional/p2p_inv_download.py @@ -391,7 +391,7 @@ "-avamasterkey={}".format(bytes_to_wif(privkey.get_bytes())), ]) node.generate(1) - wait_for_proof(node, proofid_hex, expect_orphan=True) + wait_for_proof(node, proofid_hex, expect_status="orphan") peer = node.add_p2p_connection(context.p2p_conn()) peer.send_message( diff --git a/test/functional/test_framework/avatools.py b/test/functional/test_framework/avatools.py --- a/test/functional/test_framework/avatools.py +++ b/test/functional/test_framework/avatools.py @@ -35,7 +35,7 @@ ) from .p2p import P2PInterface, p2p_lock from .test_node import TestNode -from .util import assert_equal, satoshi_round, wait_until_helper +from .util import satoshi_round, wait_until_helper from .wallet_util import bytes_to_wif @@ -153,22 +153,23 @@ return [int(peer['proofid'], 16) for peer in node.getavalanchepeerinfo()] -def wait_for_proof(node, proofid_hex, timeout=60, expect_orphan=None): +def wait_for_proof(node, proofid_hex, expect_status="boundToPeer", timeout=60): """ - Wait for the proof to be known by the node. If expect_orphan is set, the - proof should match the orphan state, otherwise it's a don't care parameter. + Wait for the proof to be known by the node. The expect_status is checked + once after the proof is found and can be one of the following: "orphan", + "boundToPeer", "conflicting" or "finalized". """ + ret = {} + def proof_found(): + nonlocal ret try: - wait_for_proof.is_orphan = node.getrawavalancheproof(proofid_hex)[ - "orphan"] + ret = node.getrawavalancheproof(proofid_hex) return True except JSONRPCException: return False wait_until_helper(proof_found, timeout=timeout) - - if expect_orphan is not None: - assert_equal(expect_orphan, wait_for_proof.is_orphan) + assert ret.get(expect_status, False) is True class NoHandshakeAvaP2PInterface(P2PInterface):