Skip to content

Commit d573b58

Browse files
committed
tests: fix flaky bwatch 1-block reorg test
The test mined a block and then reorged it, but it did not wait until bwatch had actually seen that block first. Sometimes bwatch was still one block behind. In that case, the replacement block looked like a normal new block, not a reorg, so the test waited forever for "Reorg detected". Wait until bwatch has stored the block before reorging it.
1 parent c9b25bc commit d573b58

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tests/test_plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5463,9 +5463,13 @@ def test_bwatch_reorg_1_block(node_factory, bitcoind):
54635463

54645464
# Mine a few blocks to establish history
54655465
bitcoind.generate_block(5)
5466+
expected_height = bitcoind.rpc.getblockcount()
54665467
# Wait for bwatch to fully catch up (important: bwatch must have the block
54675468
# that will be reorged, otherwise it can't detect the reorg)
5468-
l1.daemon.wait_for_log(r'No block change')
5469+
l1.daemon.wait_for_log(rf'Added block {expected_height} to history', timeout=60)
5470+
wait_for(lambda: any(e['key'][-1] == f"{expected_height:010d}"
5471+
for e in l1.rpc.listdatastore(['bwatch', 'block_history'])['datastore']),
5472+
timeout=60)
54695473

54705474
# Get the actual number of blocks bwatch has stored before reorg
54715475
ds_before = l1.rpc.listdatastore(['bwatch', 'block_history'])

0 commit comments

Comments
 (0)