-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add connection router address to nexus params
- Loading branch information
1 parent
ce7e267
commit 98ae33a
Showing
14 changed files
with
230 additions
and
70 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/axelarnetwork/axelar-core/x/nexus/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// GetMigrationHandler returns the handler that performs in-place store migrations | ||
func GetMigrationHandler(k Keeper) func(ctx sdk.Context) error { | ||
// Migrate6to7 returns the handler that performs in-place store migrations | ||
func Migrate6to7(k Keeper) func(ctx sdk.Context) error { | ||
return func(ctx sdk.Context) error { | ||
addModuleParamConnectionRouter(ctx, k) | ||
|
||
return nil | ||
} | ||
} | ||
|
||
func addModuleParamConnectionRouter(ctx sdk.Context, k Keeper) { | ||
k.params.Set(ctx, types.KeyConnectionRouter, types.DefaultParams().ConnectionRouter) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/axelarnetwork/axelar-core/app" | ||
"github.com/axelarnetwork/axelar-core/testutils/fake" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
params "github.com/cosmos/cosmos-sdk/x/params/types" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
|
||
"github.com/axelarnetwork/axelar-core/x/nexus/keeper" | ||
"github.com/axelarnetwork/axelar-core/x/nexus/types" | ||
. "github.com/axelarnetwork/utils/test" | ||
) | ||
|
||
func TestMigrate6to7(t *testing.T) { | ||
encCfg := app.MakeEncodingConfig() | ||
subspace := params.NewSubspace(encCfg.Codec, encCfg.Amino, sdk.NewKVStoreKey("nexusKey"), sdk.NewKVStoreKey("tNexusKey"), "nexus") | ||
k := keeper.NewKeeper(encCfg.Codec, sdk.NewKVStoreKey("nexus"), subspace) | ||
ctx := sdk.NewContext(fake.NewMultiStore(), tmproto.Header{}, false, log.TestingLogger()) | ||
|
||
Given("subspace is setup with params before migration", func() { | ||
subspace.Set(ctx, types.KeyChainActivationThreshold, types.DefaultParams().ChainActivationThreshold) | ||
subspace.Set(ctx, types.KeyChainMaintainerMissingVoteThreshold, types.DefaultParams().ChainMaintainerMissingVoteThreshold) | ||
subspace.Set(ctx, types.KeyChainMaintainerIncorrectVoteThreshold, types.DefaultParams().ChainMaintainerIncorrectVoteThreshold) | ||
subspace.Set(ctx, types.KeyChainMaintainerCheckWindow, types.DefaultParams().ChainMaintainerCheckWindow) | ||
}). | ||
When("", func() {}). | ||
Then("the migration should add the new param with the default value", func(t *testing.T) { | ||
actual := sdk.AccAddress{} | ||
|
||
assert.PanicsWithError(t, "UnmarshalJSON cannot decode empty bytes", func() { | ||
subspace.Get(ctx, types.KeyConnectionRouter, &actual) | ||
}) | ||
assert.PanicsWithError(t, "UnmarshalJSON cannot decode empty bytes", func() { | ||
k.GetParams(ctx) | ||
}) | ||
|
||
keeper.Migrate6to7(k)(ctx) | ||
|
||
assert.NotPanics(t, func() { | ||
subspace.Get(ctx, types.KeyConnectionRouter, &actual) | ||
}) | ||
assert.NotPanics(t, func() { | ||
k.GetParams(ctx) | ||
}) | ||
|
||
assert.Len(t, actual, 0) | ||
assert.Len(t, k.GetParams(ctx).ConnectionRouter, 0) | ||
}). | ||
Run(t) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.