mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-07 19:30:46 +02:00
wtclient: use the new filter options to fix the demo'd bug
In this commit, we use the newly added session listing options to ensure that we only see a session as exhausted if it does not have any un-acked updates on disk. This fixes the bug previously demonstrated.
This commit is contained in:
@@ -2418,13 +2418,13 @@ var clientTests = []clientTest{
|
||||
},
|
||||
},
|
||||
{
|
||||
// Demonstrate that a client is un-able to remove a tower if
|
||||
// there are persisted un-acked updates in a session that is
|
||||
// not loaded as a candidate session on start-up.
|
||||
//
|
||||
// NOTE: This is a bug and will be fixed in a followup commit.
|
||||
name: "can't remove tower with un-acked update in " +
|
||||
"non-candidate session",
|
||||
// Previously we would not load a session into memory if its
|
||||
// seq num was equal to it's max-updates. This meant that we
|
||||
// would then not properly handle any committed updates for the
|
||||
// session meaning that we would then not remove the tower if
|
||||
// needed. This test demonstrates that this has been fixed.
|
||||
name: "can remove tower with an un-acked update in " +
|
||||
"an exhausted session after a restart",
|
||||
cfg: harnessCfg{
|
||||
localBalance: localBalance,
|
||||
remoteBalance: remoteBalance,
|
||||
@@ -2462,8 +2462,7 @@ var clientTests = []clientTest{
|
||||
// update which will cause a CommittedUpdate to be
|
||||
// persisted which will also mean that the SeqNum of the
|
||||
// session is now equal to MaxUpdates of the session
|
||||
// policy. This means that on start-up of the client,
|
||||
// the session will not be loaded as a candidate.
|
||||
// policy.
|
||||
h.backupStates(chanID, numUpdates-1, numUpdates, nil)
|
||||
|
||||
tower, err := h.clientDB.LoadTower(
|
||||
@@ -2493,19 +2492,27 @@ var clientTests = []clientTest{
|
||||
require.NoError(h.t, err)
|
||||
|
||||
// Now restart the client. On restart, the previous
|
||||
// session will no longer be loaded as a candidate since
|
||||
// it is now seen as exhausted.
|
||||
// session should still be loaded even though it is
|
||||
// exhausted since it has an un-acked update.
|
||||
require.NoError(h.t, h.clientMgr.Stop())
|
||||
h.startClient()
|
||||
|
||||
// Attempt to remove the tower. This will fail due to
|
||||
// there still being un-acked updates for the tower
|
||||
// since these are only (currently) properly handled for
|
||||
// sessions loaded as candidate sessions on start-up.
|
||||
// Now remove the tower.
|
||||
err = h.clientMgr.RemoveTower(
|
||||
h.server.addr.IdentityKey, nil,
|
||||
)
|
||||
require.ErrorIs(h.t, err, wtdb.ErrTowerUnackedUpdates)
|
||||
require.NoError(h.t, err)
|
||||
|
||||
// Add a new tower.
|
||||
server2 := newServerHarness(
|
||||
h.t, h.net, towerAddr2Str, nil,
|
||||
)
|
||||
server2.start()
|
||||
h.addTower(server2.addr)
|
||||
|
||||
// Now we assert that the backups are backed up to the
|
||||
// new tower.
|
||||
server2.waitForUpdates(hints[numUpdates-1:], waitTime)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user