From a21d16f297a9a549a4344eb8d8a84d4b008f2733 Mon Sep 17 00:00:00 2001 From: Draco Li Date: Fri, 29 Apr 2022 12:08:04 -0400 Subject: [PATCH] e2e test for kava 9 -> kava 10 migration (#1232) * e2e test for kava9 export * fix bad chain id --- migrate/v0_17/migrate.go | 2 +- migrate/v0_17/migrate_test.go | 24 ++++++++++++++++++++++++ migrate/v0_17/testdata/genesis-v17.json | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/migrate/v0_17/migrate.go b/migrate/v0_17/migrate.go index c5f1b094..08633bd7 100644 --- a/migrate/v0_17/migrate.go +++ b/migrate/v0_17/migrate.go @@ -15,7 +15,7 @@ import ( var ( // TODO: needs verification before release GenesisTime = time.Date(2022, 5, 10, 17, 0, 0, 0, time.UTC) - ChainID = "kava-2222-10" + ChainID = "kava_2222-10" ) func setConfigIfUnsealed() { diff --git a/migrate/v0_17/migrate_test.go b/migrate/v0_17/migrate_test.go index 5afa886c..94128867 100644 --- a/migrate/v0_17/migrate_test.go +++ b/migrate/v0_17/migrate_test.go @@ -8,6 +8,7 @@ import ( bridgetypes "github.com/kava-labs/kava-bridge/x/bridge/types" "github.com/kava-labs/kava/app" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" @@ -125,6 +126,29 @@ func TestMigrateSavings(t *testing.T) { }) } +func TestMigrateFull(t *testing.T) { + t.Skip() + + // File: https://s3.us-west-2.amazonaws.com/levi.testing.kava.io/kava-9-4-19-export-genesis.json + // Height: 1145621 + genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "kava-9-4-19-export-genesis.json")) + assert.NoError(t, err) + ctx := newClientContext() + newGenDoc, err := Migrate(genDoc, ctx) + assert.NoError(t, err) + + var appMap genutiltypes.AppMap + err = tmjson.Unmarshal(newGenDoc.AppState, &appMap) + assert.NoError(t, err) + config := app.MakeEncodingConfig() + err = app.ModuleBasics.ValidateGenesis(ctx.Codec, config.TxConfig, appMap) + assert.NoError(t, err) + tApp := app.NewTestApp() + require.NotPanics(t, func() { + tApp.InitializeFromGenesisStatesWithTimeAndChainID(newGenDoc.GenesisTime, newGenDoc.ChainID, app.GenesisState(appMap)) + }) +} + func migrateToV17AndGetAppMap(t *testing.T) (genutiltypes.AppMap, client.Context) { genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v16.json")) assert.NoError(t, err) diff --git a/migrate/v0_17/testdata/genesis-v17.json b/migrate/v0_17/testdata/genesis-v17.json index 82e1a45b..e34ca4a7 100644 --- a/migrate/v0_17/testdata/genesis-v17.json +++ b/migrate/v0_17/testdata/genesis-v17.json @@ -1,6 +1,6 @@ { "genesis_time": "2022-05-10T17:00:00Z", - "chain_id": "kava-2222-10", + "chain_id": "kava_2222-10", "initial_height": "1", "consensus_params": { "block": {