From 8893055810001a5f7a8e4c6c23faa09cb5a6f54b Mon Sep 17 00:00:00 2001 From: archipelago Date: Mon, 22 Jun 2026 14:45:36 -0400 Subject: [PATCH] test(gate): retry lnd getinfo for RPC readiness (wallet-unlock lags 'running') MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lnd's RPC isn't ready until its wallet auto-unlocks on (re)start, which lags the container 'running' state — single-shot lncli getinfo raced that window and false-failed (gate tests 60 + 85). Retry up to ~90s like a health probe. lnd is functional (getinfo returns cleanly once ready). Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/lifecycle/bats/lnd.bats | 15 ++++++++++----- tests/lifecycle/bats/required-stack.bats | 7 ++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/lifecycle/bats/lnd.bats b/tests/lifecycle/bats/lnd.bats index 9579ae37..ddd9d3e5 100644 --- a/tests/lifecycle/bats/lnd.bats +++ b/tests/lifecycle/bats/lnd.bats @@ -50,11 +50,16 @@ teardown_file() { skip "lnd not running (state=$state)" fi - # Reuses the exact invocation required-stack.bats uses for parity. - run sh -lc 'podman exec lnd lncli \ - --tlscertpath /root/.lnd/tls.cert \ - --macaroonpath /root/.lnd/data/chain/bitcoin/mainnet/readonly.macaroon \ - --rpcserver localhost:10009 getinfo >/dev/null' + # lnd's RPC readiness LAGS the container "running" state: after a (re)start the + # wallet must auto-unlock before lncli answers, so a single-shot getinfo races + # that window and false-fails. Retry until ready (~90s), like a health probe. + run sh -lc 'for i in $(seq 1 30); do + podman exec lnd lncli \ + --tlscertpath /root/.lnd/tls.cert \ + --macaroonpath /root/.lnd/data/chain/bitcoin/mainnet/readonly.macaroon \ + --rpcserver localhost:10009 getinfo >/dev/null 2>&1 && exit 0 + sleep 3 + done; exit 1' [ "$status" -eq 0 ] } diff --git a/tests/lifecycle/bats/required-stack.bats b/tests/lifecycle/bats/required-stack.bats index bc01ad8b..33474ba3 100644 --- a/tests/lifecycle/bats/required-stack.bats +++ b/tests/lifecycle/bats/required-stack.bats @@ -93,7 +93,12 @@ PY } @test "lnd CLI getinfo succeeds" { - run sh -lc 'timeout 60 podman exec lnd lncli --tlscertpath /root/.lnd/tls.cert --macaroonpath /root/.lnd/data/chain/bitcoin/mainnet/readonly.macaroon --rpcserver localhost:10009 getinfo >/dev/null' + # lnd RPC readiness lags the container "running" state (wallet auto-unlock on + # start), so retry until ready rather than single-shot. See lnd.bats note. + run sh -lc 'for i in $(seq 1 30); do + timeout 20 podman exec lnd lncli --tlscertpath /root/.lnd/tls.cert --macaroonpath /root/.lnd/data/chain/bitcoin/mainnet/readonly.macaroon --rpcserver localhost:10009 getinfo >/dev/null 2>&1 && exit 0 + sleep 3 + done; exit 1' [ "$status" -eq 0 ] }