-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IbcHooks param store migration (#1939)
* migrate params to own store * change key name * move params into param file, add tests * remove paramspace from attribute keeper * remove init param keepers for modules that do not use them * add migration function * add change log * fix migrate function, add remove todos * add parent issue to changelog
- Loading branch information
1 parent
0ced31a
commit b004ae3
Showing
9 changed files
with
116 additions
and
33 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/provenance-io/provenance/x/ibchooks/types" | ||
) | ||
|
||
// GetParams returns the total set of the module's parameters. | ||
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { | ||
store := ctx.KVStore(k.storeKey) | ||
bz := store.Get(types.IbcHooksParamStoreKey) | ||
if bz == nil { | ||
return types.DefaultParams() | ||
} | ||
k.cdc.MustUnmarshal(bz, ¶ms) | ||
return params | ||
} | ||
|
||
// SetParams sets the module's parameters with the provided parameters. | ||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { | ||
store := ctx.KVStore(k.storeKey) | ||
bz := k.cdc.MustMarshal(¶ms) | ||
store.Set(types.IbcHooksParamStoreKey, bz) | ||
} |
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,44 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/provenance-io/provenance/app" | ||
simapp "github.com/provenance-io/provenance/app" | ||
"github.com/provenance-io/provenance/x/ibchooks/types" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type IbcHooksParamTestSuite struct { | ||
suite.Suite | ||
|
||
app *app.App | ||
ctx sdk.Context | ||
} | ||
|
||
func (s *IbcHooksParamTestSuite) SetupTest() { | ||
s.app = simapp.Setup(s.T()) | ||
s.ctx = s.app.BaseApp.NewContextLegacy(false, cmtproto.Header{Time: time.Now()}) | ||
} | ||
|
||
func TestIbcHooksParamTestSuite(t *testing.T) { | ||
suite.Run(t, new(IbcHooksParamTestSuite)) | ||
} | ||
|
||
func (s *IbcHooksParamTestSuite) TestGetSetParams() { | ||
defaultParams := s.app.IBCHooksKeeper.GetParams(s.ctx) | ||
s.Require().Len(defaultParams.AllowedAsyncAckContracts, 0, "Default AllowedAsyncAckContracts should be empty") | ||
|
||
newAllowedAsyncAckContracts := []string{"contract1", "contract2", "contract3"} | ||
newParams := types.Params{ | ||
AllowedAsyncAckContracts: newAllowedAsyncAckContracts, | ||
} | ||
|
||
s.app.IBCHooksKeeper.SetParams(s.ctx, newParams) | ||
|
||
updatedParams := s.app.IBCHooksKeeper.GetParams(s.ctx) | ||
s.Require().Equal(newAllowedAsyncAckContracts, updatedParams.AllowedAsyncAckContracts, "Updated AllowedAsyncAckContracts should match") | ||
} |
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