What changed, and why it matters
This change only adjusts internal test code to fix timing-related flakiness in two watchtower client tests. It does not modify production code, so it has no direct security impact on running LND nodes.
No security action required; treat as routine test reliability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies watchtower/wtclient/client_test.go to add synchronization channels and wait predicates in two test cases (testRemoveLockedAddr and testTowerSwitch). These changes ensure tests wait for dial/session negotiation before asserting lock state, and retry RemoveTower when addresses are temporarily locked. No production logic in the wtclient package or elsewhere is changed.
Changed components
watchtower/wtclient/client_test.goInspect captured patch +29 / −4
diff --git a/watchtower/wtclient/client_test.go b/watchtower/wtclient/client_test.go
index e842876..1b50600 100644
--- a/watchtower/wtclient/client_test.go
+++ b/watchtower/wtclient/client_test.go
@@ -1811,8 +1811,10 @@ var clientTests = []clientTest{
require.NoError(h.t, err)
cancel := make(chan struct{})
+ dialStarted := make(chan struct{})
h.net.registerConnCallback(
h.server.addr, func(peer wtserver.Peer) {
+ close(dialStarted)
select {
case <-h.quit:
case <-cancel:
@@ -1847,6 +1849,16 @@ var clientTests = []clientTest{
err = h.clientMgr.AddTower(towerAddr)
require.NoError(h.t, err)
+ // Wait for the dial to start so that we know the
+ // session negotiation has begun and the address is
+ // locked.
+ select {
+ case <-dialStarted:
+
+ case <-time.After(waitTime):
+ h.t.Fatal("timeout waiting for dial to start")
+ }
+
// Assert that if the client attempts to remove the
// tower's first address, then it will error due to
// address currently being locked for session
@@ -2354,10 +2366,23 @@ var clientTests = []clientTest{
}, waitTime)
require.NoError(h.t, err)
- // Now remove the tower.
- err = h.clientMgr.RemoveTower(
- h.server.addr.IdentityKey, nil,
- )
+ // Now remove the tower. We use wait.Predicate here
+ // because the address may still be locked by an active
+ // session.
+ err = wait.Predicate(func() bool {
+ err := h.clientMgr.RemoveTower(
+ h.server.addr.IdentityKey, nil,
+ )
+ if err != nil {
+ require.ErrorIs(
+ h.t, err, wtclient.ErrAddrInUse,
+ )
+
+ return false
+ }
+
+ return true
+ }, waitTime)
require.NoError(h.t, err)
// Add a new tower.
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.