From 6b5fc2d1faf94d8290a30bd7007113815c8936ea Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Mon, 20 Nov 2023 14:52:20 +0100 Subject: [PATCH] qa: fix flaky test of unconfirmed spend RBF --- tests/test_chain.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_chain.py b/tests/test_chain.py index 42c607882..aeda76cb0 100644 --- a/tests/test_chain.py +++ b/tests/test_chain.py @@ -397,11 +397,15 @@ def test_conflicting_unconfirmed_spend_txs(lianad, bitcoind): bitcoind.rpc.sendrawtransaction(tx_hex) # We must now detect the coin as being spent by the second transaction. - wait_for( - lambda: get_coin(lianad, spent_coin["outpoint"])["spend_info"] is not None - and get_coin(lianad, spent_coin["outpoint"])["spend_info"]["txid"] - == txid_b.hex() - ) + def is_spent_by(lianad, outpoint, txid): + coins = lianad.rpc.listcoins([], [outpoint])["coins"] + if len(coins) == 0: + return False + coin = coins[0] + if coin["spend_info"] is None: + return False + return coin["spend_info"]["txid"] == txid.hex() + wait_for(lambda: is_spent_by(lianad, spent_coin["outpoint"], txid_b)) def sign_and_broadcast_psbt(lianad, psbt):