Skip to content

Commit 7df7b12

Browse files
committed
splice: Wait for mempool in tests
In some cases the CI is so quick and / or slow that the mempool doesn’t have the transaction by the time we’re looking for it. Move the mempool check into a wait_for.
1 parent f6134b8 commit 7df7b12

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

tests/test_splicing.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def test_splice(node_factory, bitcoind):
3030
l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
3131
l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
3232

33+
wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
3334
mempool = bitcoind.rpc.getrawmempool(True)
34-
assert len(list(mempool.keys())) == 1
3535
assert result['txid'] in list(mempool.keys())
3636

3737
bitcoind.generate_block(6, wait_for_mempool=1)
@@ -68,8 +68,8 @@ def test_splice_rbf(node_factory, bitcoind):
6868
l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
6969
l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
7070

71+
wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
7172
mempool = bitcoind.rpc.getrawmempool(True)
72-
assert len(list(mempool.keys())) == 1
7373
assert result['txid'] in list(mempool.keys())
7474

7575
inv = l2.rpc.invoice(10**2, '1', 'no_1')
@@ -249,8 +249,8 @@ def test_splice_out(node_factory, bitcoind):
249249
l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
250250
l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
251251

252+
wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
252253
mempool = bitcoind.rpc.getrawmempool(True)
253-
assert len(list(mempool.keys())) == 1
254254
assert result['txid'] in list(mempool.keys())
255255

256256
bitcoind.generate_block(6, wait_for_mempool=1)
@@ -307,8 +307,8 @@ def test_invalid_splice(node_factory, bitcoind):
307307
result = l1.rpc.signpsbt(result['psbt'])
308308
result = l1.rpc.splice_signed(chan_id, result['signed_psbt'])
309309

310+
wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
310311
mempool = bitcoind.rpc.getrawmempool(True)
311-
assert len(list(mempool.keys())) == 1
312312
assert result['txid'] in list(mempool.keys())
313313

314314
bitcoind.generate_block(6, wait_for_mempool=1)
@@ -357,8 +357,7 @@ def test_commit_crash_splice(node_factory, bitcoind):
357357
l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
358358
l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
359359

360-
mempool = bitcoind.rpc.getrawmempool(True)
361-
assert len(list(mempool.keys())) == 1
360+
wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
362361

363362
bitcoind.generate_block(6, wait_for_mempool=1)
364363

@@ -407,8 +406,8 @@ def test_splice_stuck_htlc(node_factory, bitcoind, executor):
407406
l2.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
408407
l1.daemon.wait_for_log(r'CHANNELD_NORMAL to CHANNELD_AWAITING_SPLICE')
409408

409+
wait_for(lambda: len(list(bitcoind.rpc.getrawmempool(True).keys())) == 1)
410410
mempool = bitcoind.rpc.getrawmempool(True)
411-
assert len(list(mempool.keys())) == 1
412411
assert result['txid'] in list(mempool.keys())
413412

414413
bitcoind.generate_block(1, wait_for_mempool=1)

0 commit comments

Comments
 (0)