mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-26 01:33:02 +01:00
wtclient: demo "tower has unacked updates" bug
In this commit, we demonstrate the situation where a client has persisted CommittedUpdates but has not yet recieved Acks for them from the tower. If this happens and the client attempts to remove the tower, it will with the "tower has unacked updates" error.
This commit is contained in:
parent
552ef4bf81
commit
af1506bff1
@ -2223,6 +2223,82 @@ var clientTests = []clientTest{
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
// Assert that a client is unable to remove a tower if there
|
||||
// are persisted un-acked updates. This is a bug that will be
|
||||
// fixed in a future commit.
|
||||
name: "cant remove due to un-acked updates (no client restart)",
|
||||
cfg: harnessCfg{
|
||||
localBalance: localBalance,
|
||||
remoteBalance: remoteBalance,
|
||||
policy: wtpolicy.Policy{
|
||||
TxPolicy: defaultTxPolicy,
|
||||
MaxUpdates: 5,
|
||||
},
|
||||
},
|
||||
fn: func(h *testHarness) {
|
||||
const (
|
||||
numUpdates = 5
|
||||
chanID = 0
|
||||
)
|
||||
|
||||
// Generate numUpdates retributions and back a few of
|
||||
// them up to the main tower.
|
||||
hints := h.advanceChannelN(chanID, numUpdates)
|
||||
h.backupStates(chanID, 0, numUpdates/2, nil)
|
||||
|
||||
// Wait for all these updates to be populated in the
|
||||
// server's database.
|
||||
h.server.waitForUpdates(hints[:numUpdates/2], waitTime)
|
||||
|
||||
// Now stop the server and restart it with the
|
||||
// NoAckUpdates set to true.
|
||||
h.server.restart(func(cfg *wtserver.Config) {
|
||||
cfg.NoAckUpdates = true
|
||||
})
|
||||
|
||||
// Back up the remaining tasks. This will bind the
|
||||
// backup tasks to the session with the server. The
|
||||
// client will also persist the updates.
|
||||
h.backupStates(chanID, numUpdates/2, numUpdates, nil)
|
||||
|
||||
tower, err := h.clientDB.LoadTower(
|
||||
h.server.addr.IdentityKey,
|
||||
)
|
||||
require.NoError(h.t, err)
|
||||
|
||||
// Wait till the updates have been persisted.
|
||||
err = wait.Predicate(func() bool {
|
||||
var numCommittedUpdates int
|
||||
countUpdates := func(_ *wtdb.ClientSession,
|
||||
update *wtdb.CommittedUpdate) {
|
||||
|
||||
numCommittedUpdates++
|
||||
}
|
||||
|
||||
_, err := h.clientDB.ListClientSessions(
|
||||
&tower.ID, wtdb.WithPerCommittedUpdate(
|
||||
countUpdates,
|
||||
),
|
||||
)
|
||||
require.NoError(h.t, err)
|
||||
|
||||
return numCommittedUpdates == 1
|
||||
|
||||
}, waitTime)
|
||||
require.NoError(h.t, err)
|
||||
|
||||
// Now attempt to remove the tower. This will fail due
|
||||
// the tower having "un-acked" updates. This is a bug
|
||||
// that will be fixed in a future commit.
|
||||
err = h.client.RemoveTower(
|
||||
h.server.addr.IdentityKey, nil,
|
||||
)
|
||||
require.ErrorContains(
|
||||
h.t, err, "tower has unacked updates",
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// TestClient executes the client test suite, asserting the ability to backup
|
||||
|
Loading…
x
Reference in New Issue
Block a user