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 @@ -147,10 +147,7 @@ msg.proof = orphan peer.send_message(msg) - wait_for_proof(node, orphan_proofid) - raw_proof = node.getrawavalancheproof(orphan_proofid) - assert_equal(raw_proof["proof"], orphan_hex) - assert_equal(raw_proof["orphan"], True) + wait_for_proof(node, orphan_proofid, expect_orphan=True) def test_ban_invalid_proof(self): node = self.nodes[0] @@ -258,9 +255,7 @@ wait_until(lambda: proof_inv_received(peers)) # Sanity check our node knows the proof, and it is valid - wait_for_proof(node, proofid_hex) - raw_proof = node.getrawavalancheproof(proofid_hex) - assert_equal(raw_proof["orphan"], False) + wait_for_proof(node, proofid_hex, expect_orphan=False) # Mature the utxo then spend it node.generate(100) 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 @@ -393,8 +393,7 @@ "-avamasterkey={}".format(privkey_wif), ]) node.generate(2) - wait_for_proof(node, proofid_hex) - assert_equal(node.getrawavalancheproof(proofid_hex)["orphan"], True) + wait_for_proof(node, proofid_hex, expect_orphan=True) peer = node.add_p2p_connection(context.p2p_conn()) peer.send_message(msg_inv([CInv(t=context.inv_type, h=proofid)])) 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 @@ -28,6 +28,7 @@ from .p2p import P2PInterface, p2p_lock from .test_node import TestNode from .util import ( + assert_equal, satoshi_round, wait_until, ) @@ -139,15 +140,23 @@ ).proofid for peer in node.getavalanchepeerinfo()] -def wait_for_proof(node, proofid_hex, timeout=60): +def wait_for_proof(node, proofid_hex, timeout=60, expect_orphan=None): + """ + 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. + """ def proof_found(): try: - node.getrawavalancheproof(proofid_hex) + wait_for_proof.is_orphan = node.getrawavalancheproof(proofid_hex)[ + "orphan"] return True except JSONRPCException: return False wait_until(proof_found, timeout=timeout) + if expect_orphan is not None: + assert_equal(expect_orphan, wait_for_proof.is_orphan) + class AvaP2PInterface(P2PInterface): """P2PInterface with avalanche capabilities"""