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 ] }