57ed355c98
* (refactor): Added new MsgUpdateParams tx and generated new proto files * (refactor): Refactor for migration of x/params * (fix): Refactor to use single Params store key for easier more readable code * (fix): removed unused * (fix): add validation * (fix): fix linter * remove line * Added changes from code review * Apply changes from code review * (fix): Made ParamKey back to a string * Added CHANGELOG entry * Apply suggestions from code review Co-authored-by: Tomas Guerra <54514587+GAtom22@users.noreply.github.com> * (fix): remove HTTP endpoint exposure * Apply suggestions from code review Co-authored-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com> * fix: Apply changes from code review and run linter * Update x/feemarket/keeper/params.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * Update x/feemarket/types/msg.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> * tests: added tests for msg_server and msg * tests: add failing test for migration * Update x/feemarket/keeper/params.go Co-authored-by: Tomas Guerra <54514587+GAtom22@users.noreply.github.com> Co-authored-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com> Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package v4_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/cosmos/cosmos-sdk/testutil"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/evmos/ethermint/app"
|
|
"github.com/evmos/ethermint/encoding"
|
|
v4 "github.com/evmos/ethermint/x/feemarket/migrations/v4"
|
|
v4types "github.com/evmos/ethermint/x/feemarket/migrations/v4/types"
|
|
"github.com/evmos/ethermint/x/feemarket/types"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
type mockSubspace struct {
|
|
ps v4types.Params
|
|
}
|
|
|
|
func newMockSubspaceEmpty() mockSubspace {
|
|
return mockSubspace{}
|
|
}
|
|
|
|
func newMockSubspace(ps v4types.Params) mockSubspace {
|
|
return mockSubspace{ps: ps}
|
|
}
|
|
|
|
func (ms mockSubspace) GetParamSetIfExists(ctx sdk.Context, ps types.LegacyParams) {
|
|
*ps.(*v4types.Params) = ms.ps
|
|
}
|
|
|
|
func TestMigrate(t *testing.T) {
|
|
encCfg := encoding.MakeConfig(app.ModuleBasics)
|
|
cdc := encCfg.Codec
|
|
|
|
storeKey := sdk.NewKVStoreKey(types.ModuleName)
|
|
tKey := sdk.NewTransientStoreKey("transient_test")
|
|
ctx := testutil.DefaultContext(storeKey, tKey)
|
|
kvStore := ctx.KVStore(storeKey)
|
|
|
|
legacySubspaceEmpty := newMockSubspaceEmpty()
|
|
require.Error(t, v4.MigrateStore(ctx, storeKey, legacySubspaceEmpty, cdc))
|
|
|
|
legacySubspace := newMockSubspace(v4types.DefaultParams())
|
|
require.NoError(t, v4.MigrateStore(ctx, storeKey, legacySubspace, cdc))
|
|
|
|
paramsBz := kvStore.Get(v4types.ParamsKey)
|
|
var params v4types.Params
|
|
cdc.MustUnmarshal(paramsBz, ¶ms)
|
|
|
|
require.Equal(t, params, legacySubspace.ps)
|
|
}
|