mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
bfe4a08341
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.
42 lines
1.0 KiB
Go
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,
|
|
)
|
|
}
|