Skip to content

Commit 21cd118

Browse files
committed
pytest: fix flake in test_onchain_reestablish_reply
We can ask for the state too fast, before WIRE_ERROR is processed: ``` 2025-01-24T14:17:57.4799255Z ________________________ test_onchain_reestablish_reply ________________________ 2025-01-24T14:17:57.4800383Z [gw2] linux -- Python 3.10.16 /home/runner/.cache/pypoetry/virtualenvs/cln-meta-project-AqJ9wMix-py3.10/bin/python 2025-01-24T14:17:57.4801246Z 2025-01-24T14:17:57.4802068Z node_factory = <pyln.testing.utils.NodeFactory object at 0x7f66ec144400> 2025-01-24T14:17:57.4802645Z bitcoind = <pyln.testing.utils.BitcoinD object at 0x7f66ec145ab0> 2025-01-24T14:17:57.4803483Z executor = <concurrent.futures.thread.ThreadPoolExecutor object at 0x7f66ec146da0> 2025-01-24T14:17:57.4804029Z 2025-01-24T14:17:57.4804340Z def test_onchain_reestablish_reply(node_factory, bitcoind, executor): 2025-01-24T14:17:57.4805013Z l1, l2, l3 = node_factory.line_graph(3, opts={'may_reconnect': True, 2025-01-24T14:17:57.4805572Z 'dev-no-reconnect': None}) 2025-01-24T14:17:57.4805990Z 2025-01-24T14:17:57.4806262Z # Make l1 close unilaterally. 2025-01-24T14:17:57.4806697Z l1.rpc.disconnect(l2.info['id'], force=True) 2025-01-24T14:17:57.4807200Z l1.rpc.close(l2.info['id'], unilateraltimeout=1) 2025-01-24T14:17:57.4807622Z 2025-01-24T14:17:57.4808025Z # l2 doesn't know, reconnection should get REESTABLISH *then* error. 2025-01-24T14:17:57.4808637Z l2.rpc.connect(l1.info['id'], 'localhost', l1.port) 2025-01-24T14:17:57.4809066Z 2025-01-24T14:17:57.4809334Z # We should exchange messages 2025-01-24T14:17:57.4809835Z l2.daemon.wait_for_logs(["peer_out WIRE_CHANNEL_REESTABLISH", 2025-01-24T14:17:57.4810399Z "peer_in WIRE_CHANNEL_REESTABLISH"]) 2025-01-24T14:17:57.4811197Z # It should be OK 2025-01-24T14:17:57.4811642Z l2.daemon.wait_for_log("Reconnected, and reestablished.") 2025-01-24T14:17:57.4812116Z 2025-01-24T14:17:57.4812378Z # Then we get the error, close. 2025-01-24T14:17:57.4812824Z l2.daemon.wait_for_log("peer_in WIRE_ERROR") 2025-01-24T14:17:57.4813576Z > assert only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['state'] == 'AWAITING_UNILATERAL' 2025-01-24T14:17:57.4814446Z E AssertionError: assert 'CHANNELD_NORMAL' == 'AWAITING_UNILATERAL' 2025-01-24T14:17:57.4815014Z E - AWAITING_UNILATERAL 2025-01-24T14:17:57.4815362Z E + CHANNELD_NORMAL ``` ``` 2025-01-24T14:17:57.5760435Z lightningd-2 2025-01-24T14:04:28.398Z DEBUG 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#1: peer_in WIRE_ERROR 2025-01-24T14:17:57.5760674Z lightningd-2 2025-01-24T14:04:28.401Z TRACE lightningd: Calling rpc_command hook of plugin cln-xpay 2025-01-24T14:17:57.5760935Z lightningd-2 2025-01-24T14:04:28.403Z TRACE lightningd: Plugin cln-xpay returned from rpc_command hook call 2025-01-24T14:17:57.5761176Z lightningd-2 2025-01-24T14:04:28.408Z TRACE lightningd: Calling rpc_command hook of plugin cln-xpay 2025-01-24T14:17:57.5761430Z lightningd-2 2025-01-24T14:04:28.414Z TRACE lightningd: Plugin cln-xpay returned from rpc_command hook call 2025-01-24T14:17:57.5762598Z {'github_repository': 'ElementsProject/lightning', 'github_sha': '390503b31e1949cb84e5a5257bf29a1b80d5cd20', 'github_ref': 'refs/pull/8027/merge', 'github_ref_name': 'HEAD', 'github_run_id': 12950414032, 'github_head_ref': 'guilt/fix-flakes12', 'github_run_number': 12051, 'github_base_ref': 'master', 'github_run_attempt': '1', 'testname': 'test_onchain_reestablish_reply', 'start_time': 1737727408, 'end_time': 1737727468, 'outcome': 'fail'} 2025-01-24T14:17:57.5763430Z lightningd-2 2025-01-24T14:04:28.426Z DEBUG 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-channeld-chan#1: billboard perm: Received ERROR channel 69d744488de7ec7f4c018da98a8a9d726ee3b47a97809608e4ce6f17747b5f09: Forcibly closed by `close` command timeout 2025-01-24T14:17:57.5764512Z lightningd-2 2025-01-24T14:04:28.433Z UNUSUAL 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#1: Peer permanent failure in CHANNELD_NORMAL: channeld: received ERROR channel 69d744488de7ec7f4c018da98a8a9d726ee3b47a97809608e4ce6f17747b5f09: Forcibly closed by `close` command timeout (reason=protocol) 2025-01-24T14:17:57.5764997Z lightningd-2 2025-01-24T14:04:28.439Z INFO 0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518-chan#1: State changed from CHANNELD_NORMAL to AWAITING_UNILATERAL ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent f687009 commit 21cd118

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/test_closing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4168,7 +4168,7 @@ def test_onchain_reestablish_reply(node_factory, bitcoind, executor):
41684168

41694169
# Then we get the error, close.
41704170
l2.daemon.wait_for_log("peer_in WIRE_ERROR")
4171-
assert only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['state'] == 'AWAITING_UNILATERAL'
4171+
wait_for(lambda: only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['state'] == 'AWAITING_UNILATERAL')
41724172
# Mine it now so we don't confuse the code below.
41734173
bitcoind.generate_block(1, wait_for_mempool=1)
41744174

0 commit comments

Comments
 (0)