channeldb/db: properly reinit wallet during Wipe

Previously we wouldn't recreate some of the top level buckets that are
now considered expected with our migration logic. This bug was
preexisting, but never surfaced because the other TLB buckets were not
touched by this unit test.
This commit is contained in:
Conner Fromknecht
2020-12-10 17:08:56 -08:00
parent 08bb8abaa3
commit 08ee754a6d
2 changed files with 14 additions and 11 deletions

View File

@@ -19,6 +19,7 @@ import (
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/shachain"
"github.com/stretchr/testify/require"
)
func TestOpenWithCreate(t *testing.T) {
@@ -96,16 +97,13 @@ func TestWipe(t *testing.T) {
t.Fatalf("unable to wipe channeldb: %v", err)
}
// Check correct errors are returned
_, err = cdb.FetchAllOpenChannels()
if err != ErrNoActiveChannels {
t.Fatalf("fetching open channels: expected '%v' instead got '%v'",
ErrNoActiveChannels, err)
}
_, err = cdb.FetchClosedChannels(false)
if err != ErrNoClosedChannels {
t.Fatalf("fetching closed channels: expected '%v' instead got '%v'",
ErrNoClosedChannels, err)
}
openChannels, err := cdb.FetchAllOpenChannels()
require.NoError(t, err, "fetching open channels")
require.Equal(t, 0, len(openChannels))
closedChannels, err := cdb.FetchClosedChannels(false)
require.NoError(t, err, "fetching closed channels")
require.Equal(t, 0, len(closedChannels))
}
// TestFetchClosedChannelForID tests that we are able to properly retrieve a