From 2c46da387c4b353719cb85ca3427844a31de0b49 Mon Sep 17 00:00:00 2001 From: archipelago Date: Thu, 9 Jul 2026 17:30:49 -0400 Subject: [PATCH] fix(tests): lnd.newaddress settles across ALL transient post-restart codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run B failed the same probe with LND_ERROR (gRPC 'waiting to start' maps there) — the 7b77462d window only matched WALLET_LOCKED, one of four phases a cascade-restarted lnd passes through. Retry every code except LND_WALLET_UNINITIALIZED (no wallet — never self-heals) within a bounded 180s window; persistent failures still fail after it. lnd verified healthy minutes after both failures. Co-Authored-By: Claude Fable 5 --- tests/lifecycle/bats/bitcoin-receive.bats | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/lifecycle/bats/bitcoin-receive.bats b/tests/lifecycle/bats/bitcoin-receive.bats index 2949bdd6..e41f3419 100644 --- a/tests/lifecycle/bats/bitcoin-receive.bats +++ b/tests/lifecycle/bats/bitcoin-receive.bats @@ -72,18 +72,22 @@ _lnd_running() { _lnd_running || skip "lnd not running" # The bitcoin bounce in bitcoin-knots.bats cascade-restarts lnd (24fd97ed). - # After a restart lnd's gRPC comes up seconds before the auto-unlocker gets - # through (its UnlockWallet calls log "waiting to start" until then), so - # LND_WALLET_LOCKED inside that window is the node settling, not broken — - # retry up to 120s. Any other error, or a wallet still locked after the - # window, fails immediately below. - local deadline=$((SECONDS + 120)) err addr + # Depending on where the probe lands in lnd's startup it sees a different + # transient code — REST unreachable, gRPC "waiting to start" (mapped to + # LND_ERROR), wallet locked until the auto-unlocker gets through, or a + # post-unlock sync phase. All of those are the node settling, not broken — + # retry up to 180s (run A caught WALLET_LOCKED, run B caught LND_ERROR + # while lnd was seconds into its restart; both self-healed within a couple + # of minutes). Only LND_WALLET_UNINITIALIZED (no wallet — never self-heals) + # fails immediately, and anything still erroring after the window fails + # loudly below. + local deadline=$((SECONDS + 180)) err addr while :; do run rpc_call lnd.newaddress [ "$status" -eq 0 ] err=$(echo "$output" | jq -r '.error.message // .error // empty') addr=$(echo "$output" | jq -r '.result.address // empty') - [[ "$err" == *LND_WALLET_LOCKED* && $SECONDS -lt $deadline ]] || break + [[ -n "$err" && "$err" != *LND_WALLET_UNINITIALIZED* && $SECONDS -lt $deadline ]] || break sleep 10 done