Skip to content

Commit 0dc33f0

Browse files
committed
pytest: fix flake in test_anchorspend_using_to_remote
With recent changes, particularly using postgres, we can finish the HTLC before we force close, so the test fails. Insert an explicit hangup here so we reliably get the result we expect: ``` @pytest.mark.parametrize("anchors", [False, True]) @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd anchors not supportd') def test_anchorspend_using_to_remote(node_factory, bitcoind, anchors): """Make sure we can use `to_remote` output of previous close to spend anchor""" # Try with old output from both anchor and non-anchor channel. l4_opts = {} if anchors is False: l4_opts['dev-force-features'] = "-23" l1, l2, l3, l4 = node_factory.get_nodes(4, opts=[{}, {}, {'disconnect': ['-WIRE_UPDATE_FULFILL_HTLC']}, l4_opts]) # Give l2 some funds, from a to-remote output. It will have to spend # this to use anchor. node_factory.join_nodes([l4, l2]) # l4 unilaterally closes, l2 gets to-remote with its output. l4.rpc.pay(l2.rpc.invoice(100000000, 'test', 'test')['bolt11']) > wait_for(lambda: only_one(l4.rpc.listpeerchannels()['channels'])['htlcs'] != []) tests/test_closing.py:4183: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ success = <function test_anchorspend_using_to_remote.<locals>.<lambda> at 0x7f8293e7fe20> 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 test_anchorspend_using_to_remote.<locals>.<lambda> at 0x7f8293e7fe20> ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent ae320cd commit 0dc33f0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/test_closing.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,7 +4165,10 @@ def test_closing_ignore_fee_limits(node_factory, bitcoind, executor):
41654165
def test_anchorspend_using_to_remote(node_factory, bitcoind, anchors):
41664166
"""Make sure we can use `to_remote` output of previous close to spend anchor"""
41674167
# Try with old output from both anchor and non-anchor channel.
4168-
l4_opts = {}
4168+
4169+
# We want l2 to process the WIRE_UPDATE_FULFILL_HTLC, so l4 drops
4170+
# on WIRE_REVOKE_AND_ACK after that.
4171+
l4_opts = {'disconnect': ['-WIRE_REVOKE_AND_ACK*2']}
41694172
if anchors is False:
41704173
l4_opts['dev-force-features'] = "-23"
41714174

@@ -4178,11 +4181,12 @@ def test_anchorspend_using_to_remote(node_factory, bitcoind, anchors):
41784181
# this to use anchor.
41794182
node_factory.join_nodes([l4, l2])
41804183

4181-
# l4 unilaterally closes, l2 gets to-remote with its output.
4184+
# l4 disconnects after receiving fulfill. It then unilaterally
4185+
# closes, l2 gets to-remote with its output.
41824186
l4.rpc.pay(l2.rpc.invoice(100000000, 'test', 'test')['bolt11'])
41834187
wait_for(lambda: only_one(l4.rpc.listpeerchannels()['channels'])['htlcs'] != [])
41844188

4185-
l4.rpc.disconnect(l2.info['id'], force=True)
4189+
wait_for(lambda: only_one(l4.rpc.listpeers()['peers'])['connected'] is False)
41864190
close = l4.rpc.close(l2.info['id'], 1)
41874191
bitcoind.generate_block(1, wait_for_mempool=only_one(close['txids']))
41884192
wait_for(lambda: len(l2.rpc.listfunds()['outputs']) == 1)

0 commit comments

Comments
 (0)