itest: add wallet_synced field integration test
What changed, and why it matters
This commit only adds a new automated integration test that checks whether the wallet_synced field in GetInfoResponse correctly reports whether the wallet has caught up to the latest blockchain blocks. It does not change production code, fix a bug, or introduce any user-facing behavior change.
No security action needed. This is a test-only addition. Reviewers may optionally run the new integration test to confirm it passes in CI.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a new test file itest/lnd_wallet_sync_test.go and registers a new ‘wallet sync’ test case group in itest/list_on_test.go. The test starts an LND node, confirms wallet_synced is true after initial sync, stops the node, mines 40 blocks, restarts the node, and asserts that wallet_synced remains false while the node is behind the chain tip and eventually becomes true once synced. No production logic is modified.
Changed components
itest/lnd_wallet_sync_test.goitest/list_on_test.goInspect captured patch +74 / −0
diff --git a/itest/list_on_test.go b/itest/list_on_test.go
index 3dc3ac9..42471e9 100644
--- a/itest/list_on_test.go
+++ b/itest/list_on_test.go
@@ -842,6 +842,9 @@ func init() {
allTestCases = appendPrefixed(
"wallet", allTestCases, walletTestCases,
)
+ allTestCases = appendPrefixed(
+ "wallet sync", allTestCases, walletSyncTestCases,
+ )
allTestCases = appendPrefixed(
"coop close with external delivery", allTestCases,
coopCloseWithExternalTestCases,
diff --git a/itest/lnd_wallet_sync_test.go b/itest/lnd_wallet_sync_test.go
new file mode 100644
index 0000000..7b6de9a
--- /dev/null
+++ b/itest/lnd_wallet_sync_test.go
@@ -0,0 +1,71 @@
+package itest
+
+import (
+ "time"
+
+ "github.com/lightningnetwork/lnd/lntest"
+ "github.com/stretchr/testify/require"
+)
+
+// walletSyncTestCases defines a set of tests for the wallet_synced field
+// in GetInfoResponse.
+var walletSyncTestCases = []*lntest.TestCase{
+ {
+ Name: "wallet synced",
+ TestFunc: runTestWalletSynced,
+ },
+}
+
+// runTestWalletSynced tests that the wallet_synced field in GetInfoResponse
+// correctly reflects the wallet's sync state. It verifies that wallet_synced
+// is false while the wallet is catching up to new blocks, and becomes true
+// once fully synced.
+func runTestWalletSynced(ht *lntest.HarnessTest) {
+ // Create a test node.
+ alice := ht.NewNodeWithCoins("Alice", nil)
+
+ // Verify wallet starts synced.
+ resp := alice.RPC.GetInfo()
+ require.True(ht, resp.WalletSynced)
+ ht.Logf("Alice wallet_synced=%v", resp.WalletSynced)
+
+ // Stop Alice to create a clear sync gap while we mine blocks.
+ require.NoError(ht, alice.Stop(), "failed to stop Alice")
+
+ // Mine blocks while Alice is offline.
+ const numBlocks = 40
+ ht.Miner().MineBlocks(numBlocks)
+ _, minerHeight := ht.Miner().GetBestBlock()
+
+ // Restart Alice without waiting for full chain sync.
+ require.NoError(
+ ht, alice.Start(ht.Context()), "failed to restart Alice",
+ )
+
+ // While Alice is behind the miner height, wallet_synced must be false.
+ deadline := time.Now().Add(lntest.DefaultTimeout)
+ for {
+ resp := alice.RPC.GetInfo()
+ if int32(resp.BlockHeight) >= minerHeight {
+ break
+ }
+
+ require.Falsef(ht, resp.WalletSynced,
+ "wallet_synced=true while behind "+
+ "(nodeHeight=%v, minerHeight=%v)",
+ resp.BlockHeight, minerHeight)
+
+ if time.Now().After(deadline) {
+ require.Fail(ht, "timed out waiting for "+
+ "node to catch up")
+ }
+
+ time.Sleep(50 * time.Millisecond)
+ }
+
+ // Final verification that wallet_synced is true.
+ require.Eventually(ht, func() bool {
+ return alice.RPC.GetInfo().WalletSynced
+ }, lntest.DefaultTimeout, 200*time.Millisecond,
+ "wallet should be synced after waiting")
+}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.