mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-01 02:51:37 +02:00
chanbackup: add new updateBackupFile method, write fresh backup on startup
In this commit, we modify the sub-swapper to update the set of backups files time it's tarted. We do this to ensure that each time we start, we're up to sync with the current set of open channels. This also ensure that we'll create a new back up file if this is the first time we're starting up with this new feature.
This commit is contained in:
@ -131,17 +131,23 @@ func TestSubSwapperIdempotentStartStop(t *testing.T) {
|
||||
|
||||
keyRing := &mockKeyRing{}
|
||||
|
||||
var (
|
||||
swapper mockSwapper
|
||||
chanNotifier mockChannelNotifier
|
||||
)
|
||||
var chanNotifier mockChannelNotifier
|
||||
|
||||
subSwapper, err := NewSubSwapper(nil, &chanNotifier, keyRing, &swapper)
|
||||
swapper := newMockSwapper()
|
||||
subSwapper, err := NewSubSwapper(nil, &chanNotifier, keyRing, swapper)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to init subSwapper: %v", err)
|
||||
}
|
||||
|
||||
subSwapper.Start()
|
||||
if err := subSwapper.Start(); err != nil {
|
||||
t.Fatalf("unable to start swapper: %v", err)
|
||||
}
|
||||
|
||||
// The swapper should write the initial channel state as soon as it's
|
||||
// active.
|
||||
backupSet := make(map[wire.OutPoint]Single)
|
||||
assertExpectedBackupSwap(t, swapper, subSwapper, keyRing, backupSet)
|
||||
|
||||
subSwapper.Start()
|
||||
|
||||
subSwapper.Stop()
|
||||
@ -188,6 +194,10 @@ func TestSubSwapperUpdater(t *testing.T) {
|
||||
}
|
||||
defer subSwapper.Stop()
|
||||
|
||||
// The swapper should write the initial channel state as soon as it's
|
||||
// active.
|
||||
assertExpectedBackupSwap(t, swapper, subSwapper, keyRing, backupSet)
|
||||
|
||||
// Now that the sub-swapper is active, we'll notify to add a brand new
|
||||
// channel to the channel state.
|
||||
newChannel, err := genRandomOpenChannelShell()
|
||||
|
Reference in New Issue
Block a user