diff --git a/ignite/templates/module/create/files/base/x/{{moduleName}}/keeper/msg_update_params_test.go.plush b/ignite/templates/module/create/files/base/x/{{moduleName}}/keeper/msg_update_params_test.go.plush index ba24742dfd..9742f5cdd8 100644 --- a/ignite/templates/module/create/files/base/x/{{moduleName}}/keeper/msg_update_params_test.go.plush +++ b/ignite/templates/module/create/files/base/x/{{moduleName}}/keeper/msg_update_params_test.go.plush @@ -6,16 +6,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - keepertest "<%= modulePath %>/testutil/keeper" "<%= modulePath %>/x/<%= moduleName %>/types" ) func TestMsgUpdateParams(t *testing.T) { - ms, _ := setupMsgServer(t) - keeper, ctx := keepertest.<%= title(moduleName) %>Keeper(t) - wctx := sdk.WrapSDKContext(ctx) + k, ms, ctx := setupMsgServer(t) params := types.DefaultParams() - require.NoError(t, keeper.SetParams(ctx, params)) + require.NoError(t, k.SetParams(ctx, params)) + wctx := sdk.UnwrapSDKContext(ctx) // default params testCases := []struct { @@ -36,7 +34,7 @@ func TestMsgUpdateParams(t *testing.T) { { name: "send enabled param", input: &types.MsgUpdateParams{ - Authority: keeper.GetAuthority(), + Authority: k.GetAuthority(), Params: types.Params{}, }, expErr: false, @@ -44,7 +42,7 @@ func TestMsgUpdateParams(t *testing.T) { { name: "all good", input: &types.MsgUpdateParams{ - Authority: keeper.GetAuthority(), + Authority: k.GetAuthority(), Params: params, }, expErr: false, diff --git a/ignite/templates/module/create/files/msgserver/x/{{moduleName}}/keeper/msg_server_test.go.plush b/ignite/templates/module/create/files/msgserver/x/{{moduleName}}/keeper/msg_server_test.go.plush index bab94048f2..1e61e54852 100644 --- a/ignite/templates/module/create/files/msgserver/x/{{moduleName}}/keeper/msg_server_test.go.plush +++ b/ignite/templates/module/create/files/msgserver/x/{{moduleName}}/keeper/msg_server_test.go.plush @@ -1,23 +1,24 @@ package keeper_test import ( - "context" "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + + keepertest "<%= modulePath %>/testutil/keeper" "<%= modulePath %>/x/<%= moduleName %>/types" "<%= modulePath %>/x/<%= moduleName %>/keeper" - keepertest "<%= modulePath %>/testutil/keeper" ) -func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { - k, ctx := keepertest.<%= title(moduleName) %>Keeper(t) - return keeper.NewMsgServerImpl(k), sdk.WrapSDKContext(ctx) +func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, sdk.Context) { + k, ctx := keepertest.FooKeeper(t) + return k, keeper.NewMsgServerImpl(k), ctx } func TestMsgServer(t *testing.T) { - ms, ctx := setupMsgServer(t) + k, ms, ctx := setupMsgServer(t) require.NotNil(t, ms) require.NotNil(t, ctx) -} + require.NotEmpty(t, k) +} \ No newline at end of file diff --git a/ignite/templates/typed/list/files/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}_test.go.plush b/ignite/templates/typed/list/files/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}_test.go.plush index b937803c8d..13098707df 100644 --- a/ignite/templates/typed/list/files/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}_test.go.plush +++ b/ignite/templates/typed/list/files/messages/x/{{moduleName}}/keeper/msg_server_{{typeName}}_test.go.plush @@ -10,10 +10,12 @@ import ( ) func Test<%= TypeName.UpperCamel %>MsgServerCreate(t *testing.T) { - srv, ctx := setupMsgServer(t) + _, ms, ctx := setupMsgServer(t) + wctx := sdk.UnwrapSDKContext(ctx) + <%= MsgSigner.LowerCamel %> := "A" for i := 0; i < 5; i++ { - resp, err := srv.Create<%= TypeName.UpperCamel %>(ctx, &types.MsgCreate<%= TypeName.UpperCamel %>{<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>}) + resp, err := srv.Create<%= TypeName.UpperCamel %>(wctx, &types.MsgCreate<%= TypeName.UpperCamel %>{<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>}) require.NoError(t, err) require.Equal(t, i, int(resp.Id)) } @@ -44,11 +46,13 @@ func Test<%= TypeName.UpperCamel %>MsgServerUpdate(t *testing.T) { } for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - srv, ctx := setupMsgServer(t) - _, err := srv.Create<%= TypeName.UpperCamel %>(ctx, &types.MsgCreate<%= TypeName.UpperCamel %>{<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>}) + _, ms, ctx := setupMsgServer(t) + wctx := sdk.UnwrapSDKContext(ctx) + + _, err := srv.Create<%= TypeName.UpperCamel %>(wctx, &types.MsgCreate<%= TypeName.UpperCamel %>{<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>}) require.NoError(t, err) - _, err = srv.Update<%= TypeName.UpperCamel %>(ctx, tc.request) + _, err = srv.Update<%= TypeName.UpperCamel %>(wctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -83,11 +87,12 @@ func Test<%= TypeName.UpperCamel %>MsgServerDelete(t *testing.T) { } for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - srv, ctx := setupMsgServer(t) + _, ms, ctx := setupMsgServer(t) + wctx := sdk.UnwrapSDKContext(ctx) - _, err := srv.Create<%= TypeName.UpperCamel %>(ctx, &types.MsgCreate<%= TypeName.UpperCamel %>{<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>}) + _, err := srv.Create<%= TypeName.UpperCamel %>(wctx, &types.MsgCreate<%= TypeName.UpperCamel %>{<%= MsgSigner.UpperCamel %>: <%= MsgSigner.LowerCamel %>}) require.NoError(t, err) - _, err = srv.Delete<%= TypeName.UpperCamel %>(ctx, tc.request) + _, err = srv.Delete<%= TypeName.UpperCamel %>(wctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else {