Skip to content

Commit 4f4bf77

Browse files
committed
pytest: fix test_onchain_unwatch under valgrind.
valgrind slowed things down so the HTLC was resolved, so we didn't use an anchor. Make that case consistent. ``` def test_onchain_unwatch(node_factory, bitcoind, chainparams): """Onchaind should not watch random spends""" # We track channel balances, to verify that accounting is ok. coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') l1, l2 = node_factory.line_graph(2, opts={'plugin': coin_mvt_plugin}) channel_id = first_channel_id(l1, l2) l1.pay(l2, 200000000) l1.rpc.dev_fail(l2.info['id']) l1.daemon.wait_for_log('Failing due to dev-fail command') l1.wait_for_channel_onchain(l2.info['id']) # Make sure we see anchor too > l1.bitcoin.generate_block(1, wait_for_mempool=2) tests/test_closing.py:1769: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ contrib/pyln-testing/pyln/testing/utils.py:477: in generate_block wait_for(lambda: len(self.rpc.getrawmempool()) >= wait_for_mempool) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ success = <function BitcoinD.generate_block.<locals>.<lambda> at 0x7f23f909c310> timeout = 180 def wait_for(success, timeout=TIMEOUT): start_time = time.time() interval = 0.25 while not success(): time_left = start_time + timeout - time.time() if time_left <= 0: > raise ValueError("Timeout while waiting for {}".format(success)) E ValueError: Timeout while waiting for <function BitcoinD.generate_block.<locals>.<lambda> at 0x7f23f909c310> ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent 4f58651 commit 4f4bf77

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/test_closing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,12 +1759,16 @@ def test_onchain_unwatch(node_factory, bitcoind, chainparams):
17591759
channel_id = first_channel_id(l1, l2)
17601760

17611761
l1.pay(l2, 200000000)
1762+
# If the HTLC isn't completely removed, we will use an anchor to bump
1763+
# the commitment tx. Under valgrind we tend to resolve the HTLC
1764+
# before getting to dev_fail. Unify the cases by waiting a bit.
1765+
wait_for(lambda: only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['htlcs'] == [])
17621766

17631767
l1.rpc.dev_fail(l2.info['id'])
17641768
l1.daemon.wait_for_log('Failing due to dev-fail command')
17651769
l1.wait_for_channel_onchain(l2.info['id'])
17661770

1767-
l1.bitcoin.generate_block(1)
1771+
l1.bitcoin.generate_block(1, wait_for_mempool=1)
17681772
l1.daemon.wait_for_log(' to ONCHAIN')
17691773
l2.daemon.wait_for_log(' to ONCHAIN')
17701774

@@ -1785,11 +1789,7 @@ def test_onchain_unwatch(node_factory, bitcoind, chainparams):
17851789
l1.rpc.withdraw(l1.rpc.newaddr()['bech32'], 'all')
17861790
bitcoind.generate_block(1)
17871791

1788-
# We see *two* of these: one for anchor spend as well!
1789-
if chainparams['elements']:
1790-
l1.daemon.wait_for_log("but we don't care")
1791-
else:
1792-
l1.daemon.wait_for_logs(["but we don't care"] * 2)
1792+
l1.daemon.wait_for_log("but we don't care")
17931793

17941794
# And lightningd should respect that!
17951795
assert not l1.daemon.is_in_log("Can't unwatch txid")

0 commit comments

Comments
 (0)