chanbackup/pubsub: add method ManualUpdate

This method inserts channel updates and waits for them to be processed. It will
be used to update channel.backup upon LND shutdown.
This commit is contained in:
Boris Nagaev
2024-07-06 13:07:48 -03:00
parent df84148ed2
commit fb397c11f1
2 changed files with 105 additions and 6 deletions

View File

@@ -277,4 +277,18 @@ func TestSubSwapperUpdater(t *testing.T) {
// Verify that the new set of backups, now has one less after the
// sub-swapper switches the new set with the old.
assertExpectedBackupSwap(t, swapper, subSwapper, keyRing, backupSet)
// Check ManualUpdate method.
channel, err := genRandomOpenChannelShell()
require.NoError(t, err)
single := NewSingle(channel, nil)
backupSet[channel.FundingOutpoint] = single
require.NoError(t, subSwapper.ManualUpdate([]Single{single}))
// Verify that the state of the backup is as expected.
assertExpectedBackupSwap(t, swapper, subSwapper, keyRing, backupSet)
// Check the case ManualUpdate returns an error.
swapper.fail = true
require.Error(t, subSwapper.ManualUpdate([]Single{single}))
}