lnd/channeldb/migration33/migration_test.go
Elle Mouton bfe4a08341
channeldb/migration33: migrate MC store pairs to default namespace
In this commit, the mission control store is migrated such that all
existing pairs which are currently stored directly in the top level
results bucket are now instead moved to a "default" namespace bucket.

Note that this migration is not yet invoked in this commit. The
migration will be invoked in the same commit that starts writing and
reading the new format.
2024-10-01 13:50:50 +02:00

42 lines
1.0 KiB
Go

package migration33
import (
"testing"
"github.com/lightningnetwork/lnd/channeldb/migtest"
"github.com/lightningnetwork/lnd/kvdb"
)
var (
// before represents the structure of the MC store before the migration.
before = map[string]interface{}{
"key1": "result1",
"key2": "result2",
"key3": "result3",
"key4": "result4",
}
// after represents the expected structure of the store after the
// migration. It should be identical to before except all the kv pairs
// are now under a new default namespace key.
after = map[string]interface{}{
string(defaultMCNamespaceKey): before,
}
)
// TestMigrateMCStoreNameSpacedResults tests that the MC store results are
// correctly moved to be under a new default namespace bucket.
func TestMigrateMCStoreNameSpacedResults(t *testing.T) {
before := func(tx kvdb.RwTx) error {
return migtest.RestoreDB(tx, resultsKey, before)
}
after := func(tx kvdb.RwTx) error {
return migtest.VerifyDB(tx, resultsKey, after)
}
migtest.ApplyMigration(
t, before, after, MigrateMCStoreNameSpacedResults, false,
)
}