From 6fdaec313d7612bfe8bfdb93fe18b090ca1b9b6f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 22 Oct 2023 14:37:32 +1030 Subject: [PATCH] pytest: be sure that we receive error on datalose failure. It was intermittant before: I added a sleep(1) in the code before sending the error (temporarily) to make it always triggers. Signed-off-by: Rusty Russell --- channeld/channeld.c | 1 + tests/test_connection.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/channeld/channeld.c b/channeld/channeld.c index cc3701eb7..ff9d183af 100644 --- a/channeld/channeld.c +++ b/channeld/channeld.c @@ -4437,6 +4437,7 @@ static void check_future_dataloss_fields(struct peer *peer, take(towire_channeld_fail_fallen_behind(NULL, remote_current_per_commitment_point))); + sleep(1); /* We have to send them an error to trigger dropping to chain. */ peer_failed_err(peer->pps, &peer->channel_id, "Awaiting unilateral close"); diff --git a/tests/test_connection.py b/tests/test_connection.py index eb9b505f3..cce0c5000 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -3055,9 +3055,8 @@ def test_dataloss_protection(node_factory, bitcoind): assert not l2.daemon.is_in_log('sendrawtx exit 0', start=l2.daemon.logsearch_start) - # l1 should drop to chain, but doesn't always receive ERROR before it sends warning. - # We have to reconnect once - l1.rpc.connect(l2.info['id'], 'localhost', l2.port) + # l1 should receive error and drop to chain + l1.daemon.wait_for_log("They sent ERROR.*Awaiting unilateral close") l1.wait_for_channel_onchain(l2.info['id']) closetxid = only_one(bitcoind.rpc.getrawmempool(False))