Skip to content

Commit

Permalink
pytest: be sure that we receive error on datalose failure.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
rustyrussell committed Oct 19, 2023
1 parent 8f0796a commit 771b161
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 2 additions & 3 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 771b161

Please sign in to comment.