diff --git a/x/accountedpool/keeper/msg_server_test.go b/x/accountedpool/keeper/msg_server_test.go index 92fa44d85..29be03fc7 100644 --- a/x/accountedpool/keeper/msg_server_test.go +++ b/x/accountedpool/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/accountedpool/keeper" "github.com/elys-network/elys/x/accountedpool/types" @@ -13,7 +12,7 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx := keepertest.AccountedPoolKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } func TestMsgServer(t *testing.T) { diff --git a/x/accountedpool/keeper/query_accounted_pool_test.go b/x/accountedpool/keeper/query_accounted_pool_test.go index bb9a182f9..68335408c 100644 --- a/x/accountedpool/keeper/query_accounted_pool_test.go +++ b/x/accountedpool/keeper/query_accounted_pool_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -16,7 +15,6 @@ import ( func TestAccountedPoolQuerySingle(t *testing.T) { keeper, ctx := keepertest.AccountedPoolKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNAccountedPool(keeper, ctx, 2) tests := []struct { desc string @@ -52,7 +50,7 @@ func TestAccountedPoolQuerySingle(t *testing.T) { } for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.AccountedPool(wctx, tc.request) + response, err := keeper.AccountedPool(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -68,7 +66,6 @@ func TestAccountedPoolQuerySingle(t *testing.T) { func TestAccountedPoolQueryPaginated(t *testing.T) { keeper, ctx := keepertest.AccountedPoolKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNAccountedPool(keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllAccountedPoolRequest { @@ -84,7 +81,7 @@ func TestAccountedPoolQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.AccountedPoolAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.AccountedPoolAll(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.AccountedPool), step) require.Subset(t, @@ -97,7 +94,7 @@ func TestAccountedPoolQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.AccountedPoolAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.AccountedPoolAll(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.AccountedPool), step) require.Subset(t, @@ -108,7 +105,7 @@ func TestAccountedPoolQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.AccountedPoolAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.AccountedPoolAll(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -117,7 +114,7 @@ func TestAccountedPoolQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.AccountedPoolAll(wctx, nil) + _, err := keeper.AccountedPoolAll(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/amm/keeper/abci_test.go b/x/amm/keeper/abci_test.go index ac667c36a..ec10b368e 100644 --- a/x/amm/keeper/abci_test.go +++ b/x/amm/keeper/abci_test.go @@ -294,13 +294,13 @@ func (suite *AmmKeeperTestSuite) TestExecuteSwapRequests() { switch msg := msg.(type) { case *types.MsgSwapExactAmountIn: _, err := msgServer.SwapExactAmountIn( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, msg, ) suite.Require().NoError(err) case *types.MsgSwapExactAmountOut: _, err := msgServer.SwapExactAmountOut( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, msg, ) suite.Require().NoError(err) diff --git a/x/amm/keeper/msg_server_create_pool_test.go b/x/amm/keeper/msg_server_create_pool_test.go index adaf98f25..156bf1da5 100644 --- a/x/amm/keeper/msg_server_create_pool_test.go +++ b/x/amm/keeper/msg_server_create_pool_test.go @@ -197,7 +197,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerCreatePool() { suite.app.AmmKeeper.SetParams(suite.ctx, params) resp, err := msgServer.CreatePool( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgCreatePool{ Sender: sender.String(), PoolParams: &tc.poolParams, diff --git a/x/amm/keeper/msg_server_exit_pool_test.go b/x/amm/keeper/msg_server_exit_pool_test.go index 700ce84bc..b9ade3b51 100644 --- a/x/amm/keeper/msg_server_exit_pool_test.go +++ b/x/amm/keeper/msg_server_exit_pool_test.go @@ -137,7 +137,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerExitPool() { }, } _, err = msgServer.CreatePool( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgCreatePool{ Sender: sender.String(), PoolParams: &tc.poolParams, @@ -147,7 +147,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerExitPool() { pool := suite.app.AmmKeeper.GetAllPool(suite.ctx)[0] suite.ctx = suite.ctx.WithBlockTime(suite.ctx.BlockTime().Add(time.Hour)) resp, err := msgServer.ExitPool( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgExitPool{ Sender: sender.String(), PoolId: pool.PoolId, diff --git a/x/amm/keeper/msg_server_feed_multiple_external_liquidity_test.go b/x/amm/keeper/msg_server_feed_multiple_external_liquidity_test.go index cdaa2ff60..0e2219c49 100644 --- a/x/amm/keeper/msg_server_feed_multiple_external_liquidity_test.go +++ b/x/amm/keeper/msg_server_feed_multiple_external_liquidity_test.go @@ -249,9 +249,8 @@ func (suite *AmmKeeperTestSuite) TestFeedMultipleExternalLiquidity() { func() { // msg server msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) - goCtx := sdk.WrapSDKContext(suite.ctx) - _, err := msgServer.FeedMultipleExternalLiquidity(goCtx, &types.MsgFeedMultipleExternalLiquidity{}) + _, err := msgServer.FeedMultipleExternalLiquidity(suite.ctx, &types.MsgFeedMultipleExternalLiquidity{}) suite.Require().Error(err) }, }, @@ -263,11 +262,10 @@ func (suite *AmmKeeperTestSuite) TestFeedMultipleExternalLiquidity() { func() { // msg server msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) - goCtx := sdk.WrapSDKContext(suite.ctx) addr := suite.AddAccounts(1, nil)[0] - _, err := msgServer.FeedMultipleExternalLiquidity(goCtx, &types.MsgFeedMultipleExternalLiquidity{ + _, err := msgServer.FeedMultipleExternalLiquidity(suite.ctx, &types.MsgFeedMultipleExternalLiquidity{ Sender: addr.String(), Liquidity: []types.ExternalLiquidity{ { @@ -293,7 +291,6 @@ func (suite *AmmKeeperTestSuite) TestFeedMultipleExternalLiquidity() { func() { // msg server msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) - goCtx := sdk.WrapSDKContext(suite.ctx) addr := suite.AddAccounts(1, nil)[0] @@ -302,7 +299,7 @@ func (suite *AmmKeeperTestSuite) TestFeedMultipleExternalLiquidity() { IsActive: false, }) - _, err := msgServer.FeedMultipleExternalLiquidity(goCtx, &types.MsgFeedMultipleExternalLiquidity{ + _, err := msgServer.FeedMultipleExternalLiquidity(suite.ctx, &types.MsgFeedMultipleExternalLiquidity{ Sender: addr.String(), Liquidity: []types.ExternalLiquidity{ { @@ -328,7 +325,6 @@ func (suite *AmmKeeperTestSuite) TestFeedMultipleExternalLiquidity() { func() { // msg server msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) - goCtx := sdk.WrapSDKContext(suite.ctx) addr := suite.AddAccounts(1, nil)[0] @@ -337,7 +333,7 @@ func (suite *AmmKeeperTestSuite) TestFeedMultipleExternalLiquidity() { IsActive: true, }) - _, err := msgServer.FeedMultipleExternalLiquidity(goCtx, &types.MsgFeedMultipleExternalLiquidity{ + _, err := msgServer.FeedMultipleExternalLiquidity(suite.ctx, &types.MsgFeedMultipleExternalLiquidity{ Sender: addr.String(), Liquidity: []types.ExternalLiquidity{ { @@ -364,7 +360,6 @@ func (suite *AmmKeeperTestSuite) TestFeedMultipleExternalLiquidity() { func() { // msg server msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) - goCtx := sdk.WrapSDKContext(suite.ctx) addr := suite.AddAccounts(1, nil)[0] @@ -376,7 +371,7 @@ func (suite *AmmKeeperTestSuite) TestFeedMultipleExternalLiquidity() { IsActive: true, }) - _, err := msgServer.FeedMultipleExternalLiquidity(goCtx, &types.MsgFeedMultipleExternalLiquidity{ + _, err := msgServer.FeedMultipleExternalLiquidity(suite.ctx, &types.MsgFeedMultipleExternalLiquidity{ Sender: addr.String(), Liquidity: []types.ExternalLiquidity{ { diff --git a/x/amm/keeper/msg_server_join_pool_test.go b/x/amm/keeper/msg_server_join_pool_test.go index f7c2be208..0c0a67ebd 100644 --- a/x/amm/keeper/msg_server_join_pool_test.go +++ b/x/amm/keeper/msg_server_join_pool_test.go @@ -177,7 +177,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerJoinPool() { // execute function msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) resp, err := msgServer.JoinPool( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgJoinPool{ Sender: sender.String(), PoolId: 1, @@ -302,7 +302,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerJoinPoolExploitScenario() { // Step 5: New LP adds single-sided liquidity msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) resp, err := msgServer.JoinPool( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgJoinPool{ Sender: sender.String(), PoolId: 1, diff --git a/x/amm/keeper/msg_server_swap_exact_amount_in_test.go b/x/amm/keeper/msg_server_swap_exact_amount_in_test.go index a621cfc1f..5d9b741f0 100644 --- a/x/amm/keeper/msg_server_swap_exact_amount_in_test.go +++ b/x/amm/keeper/msg_server_swap_exact_amount_in_test.go @@ -180,7 +180,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerSwapExactAmountIn() { msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) resp, err := msgServer.SwapExactAmountIn( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgSwapExactAmountIn{ Sender: sender.String(), Routes: tc.swapRoute, @@ -275,7 +275,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerSlippageDifferenceWhenSplit() { cacheCtx, _ := suite.ctx.CacheContext() msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) resp, err := msgServer.SwapExactAmountIn( - sdk.WrapSDKContext(cacheCtx), + cacheCtx, &types.MsgSwapExactAmountIn{ Sender: sender.String(), Routes: swapRoute, @@ -295,7 +295,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerSlippageDifferenceWhenSplit() { cacheCtx, _ = suite.ctx.CacheContext() for i := 0; i < 100; i++ { resp, err = msgServer.SwapExactAmountIn( - sdk.WrapSDKContext(cacheCtx), + cacheCtx, &types.MsgSwapExactAmountIn{ Sender: sender.String(), Routes: swapRoute, diff --git a/x/amm/keeper/msg_server_swap_exact_amount_out_test.go b/x/amm/keeper/msg_server_swap_exact_amount_out_test.go index db9275cae..0c0c6a8b1 100644 --- a/x/amm/keeper/msg_server_swap_exact_amount_out_test.go +++ b/x/amm/keeper/msg_server_swap_exact_amount_out_test.go @@ -177,7 +177,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerSwapExactAmountOut() { msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) resp, err := msgServer.SwapExactAmountOut( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgSwapExactAmountOut{ Sender: sender.String(), Routes: tc.swapRoutes, diff --git a/x/amm/keeper/msg_server_test.go b/x/amm/keeper/msg_server_test.go index 40569d963..18e454ade 100644 --- a/x/amm/keeper/msg_server_test.go +++ b/x/amm/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/amm/keeper" "github.com/elys-network/elys/x/amm/types" @@ -12,5 +11,5 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx, _, _ := keepertest.AmmKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } diff --git a/x/amm/keeper/msg_server_update_pool_params_test.go b/x/amm/keeper/msg_server_update_pool_params_test.go index c6f1f33be..6f43e14df 100644 --- a/x/amm/keeper/msg_server_update_pool_params_test.go +++ b/x/amm/keeper/msg_server_update_pool_params_test.go @@ -153,7 +153,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerUpdatePoolParams() { // execute function msgServer := keeper.NewMsgServerImpl(*suite.app.AmmKeeper) resp, err := msgServer.CreatePool( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgCreatePool{ Sender: sender.String(), PoolParams: &tc.initialPoolParams, @@ -188,7 +188,7 @@ func (suite *AmmKeeperTestSuite) TestMsgServerUpdatePoolParams() { suite.Require().Equal(commitments.CommittedTokens[0].Amount.String(), tc.expLpCommitment.Amount.String()) resp2, err := msgServer.UpdatePoolParams( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgUpdatePoolParams{ Authority: sender.String(), PoolId: pools[0].PoolId, diff --git a/x/amm/keeper/query_denom_liquidity_test.go b/x/amm/keeper/query_denom_liquidity_test.go index d4b3b1464..7deba5452 100644 --- a/x/amm/keeper/query_denom_liquidity_test.go +++ b/x/amm/keeper/query_denom_liquidity_test.go @@ -4,7 +4,6 @@ import ( "strconv" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -17,7 +16,6 @@ import ( func TestDenomLiquidityQuerySingle(t *testing.T) { keeper, ctx, _, _ := keepertest.AmmKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNDenomLiquidity(keeper, ctx, 2) for _, tc := range []struct { desc string @@ -52,7 +50,7 @@ func TestDenomLiquidityQuerySingle(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.DenomLiquidity(wctx, tc.request) + response, err := keeper.DenomLiquidity(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -68,7 +66,6 @@ func TestDenomLiquidityQuerySingle(t *testing.T) { func TestDenomLiquidityQueryPaginated(t *testing.T) { keeper, ctx, _, _ := keepertest.AmmKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNDenomLiquidity(keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllDenomLiquidityRequest { @@ -84,7 +81,7 @@ func TestDenomLiquidityQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.DenomLiquidityAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.DenomLiquidityAll(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.DenomLiquidity), step) require.Subset(t, @@ -97,7 +94,7 @@ func TestDenomLiquidityQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.DenomLiquidityAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.DenomLiquidityAll(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.DenomLiquidity), step) require.Subset(t, @@ -108,7 +105,7 @@ func TestDenomLiquidityQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.DenomLiquidityAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.DenomLiquidityAll(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -117,7 +114,7 @@ func TestDenomLiquidityQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.DenomLiquidityAll(wctx, nil) + _, err := keeper.DenomLiquidityAll(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/amm/keeper/query_pool_test.go b/x/amm/keeper/query_pool_test.go index e8ff014b0..bafa542ec 100644 --- a/x/amm/keeper/query_pool_test.go +++ b/x/amm/keeper/query_pool_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -16,7 +15,6 @@ import ( func TestPoolQuerySingle(t *testing.T) { keeper, ctx, _, _ := keepertest.AmmKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNPool(keeper, ctx, 2) for _, tc := range []struct { desc string @@ -51,7 +49,7 @@ func TestPoolQuerySingle(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.Pool(wctx, tc.request) + response, err := keeper.Pool(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -67,7 +65,6 @@ func TestPoolQuerySingle(t *testing.T) { func TestPoolQueryPaginated(t *testing.T) { keeper, ctx, _, _ := keepertest.AmmKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNPool(keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllPoolRequest { @@ -83,7 +80,7 @@ func TestPoolQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.PoolAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.PoolAll(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Pool), step) require.Subset(t, @@ -96,7 +93,7 @@ func TestPoolQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.PoolAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.PoolAll(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Pool), step) require.Subset(t, @@ -107,7 +104,7 @@ func TestPoolQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.PoolAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.PoolAll(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -116,7 +113,7 @@ func TestPoolQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.PoolAll(wctx, nil) + _, err := keeper.PoolAll(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/amm/keeper/query_swap_estimation_test.go b/x/amm/keeper/query_swap_estimation_test.go new file mode 100644 index 000000000..71523fb9c --- /dev/null +++ b/x/amm/keeper/query_swap_estimation_test.go @@ -0,0 +1,27 @@ +package keeper_test + +func (suite *AmmKeeperTestSuite) TestQuerySwapEstimation() { + testCases := []struct { + name string + prerequisiteFunction func() + postValidateFunction func() + }{ + { + "nil request", + func() { + suite.ResetSuite() + }, + func() { + _, err := suite.app.AmmKeeper.SwapEstimation(suite.ctx, nil) + suite.Require().Error(err) + }, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + tc.prerequisiteFunction() + tc.postValidateFunction() + }) + } +} diff --git a/x/amm/keeper/query_test.go b/x/amm/keeper/query_test.go index 45e95767e..dbc1dade9 100644 --- a/x/amm/keeper/query_test.go +++ b/x/amm/keeper/query_test.go @@ -1,21 +1,47 @@ package keeper_test import ( - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/amm/types" - "github.com/stretchr/testify/require" ) -func TestParamsQuery(t *testing.T) { - keeper, ctx, _, _ := testkeeper.AmmKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - params := types.DefaultParams() - keeper.SetParams(ctx, params) +func (suite *AmmKeeperTestSuite) TestQuery() { + testCases := []struct { + name string + prerequisiteFunction func() + postValidateFunction func() + }{ + { + "params", + func() { + suite.ResetSuite() + + params := types.DefaultParams() + suite.app.AmmKeeper.SetParams(suite.ctx, params) + }, + func() { + params := types.DefaultParams() + + response, err := suite.app.AmmKeeper.Params(suite.ctx, &types.QueryParamsRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(&types.QueryParamsResponse{Params: params}, response) + }, + }, + { + "params with nil request", + func() { + suite.ResetSuite() + }, + func() { + _, err := suite.app.AmmKeeper.Params(suite.ctx, nil) + suite.Require().Error(err) + }, + }, + } - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) + for _, tc := range testCases { + suite.Run(tc.name, func() { + tc.prerequisiteFunction() + tc.postValidateFunction() + }) + } } diff --git a/x/assetprofile/keeper/msg_server_entry_test.go b/x/assetprofile/keeper/msg_server_entry_test.go index 8d902d646..50d90e15b 100644 --- a/x/assetprofile/keeper/msg_server_entry_test.go +++ b/x/assetprofile/keeper/msg_server_entry_test.go @@ -4,7 +4,6 @@ import ( "strconv" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" @@ -53,16 +52,15 @@ func TestEntryMsgServerUpdate(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { k, ctx := keepertest.AssetprofileKeeper(t) srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) expected := &types.MsgAddEntry{ Creator: authority, BaseDenom: strconv.Itoa(0), Decimals: 6, } - _, err := srv.AddEntry(wctx, expected) + _, err := srv.AddEntry(ctx, expected) require.NoError(t, err) - _, err = srv.UpdateEntry(wctx, tc.request) + _, err = srv.UpdateEntry(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { diff --git a/x/assetprofile/keeper/msg_server_test.go b/x/assetprofile/keeper/msg_server_test.go index 28a18252a..f27b972d0 100644 --- a/x/assetprofile/keeper/msg_server_test.go +++ b/x/assetprofile/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/assetprofile/keeper" "github.com/elys-network/elys/x/assetprofile/types" @@ -12,5 +11,5 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx := keepertest.AssetprofileKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } diff --git a/x/assetprofile/keeper/query_entry_test.go b/x/assetprofile/keeper/query_entry_test.go index 5858146c6..aa17878bf 100644 --- a/x/assetprofile/keeper/query_entry_test.go +++ b/x/assetprofile/keeper/query_entry_test.go @@ -4,7 +4,6 @@ import ( "strconv" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -17,7 +16,6 @@ import ( func TestEntryQuerySingle(t *testing.T) { keeper, ctx := keepertest.AssetprofileKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNEntry(keeper, ctx, 2) for _, tc := range []struct { desc string @@ -52,7 +50,7 @@ func TestEntryQuerySingle(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.Entry(wctx, tc.request) + response, err := keeper.Entry(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { diff --git a/x/assetprofile/keeper/query_params_test.go b/x/assetprofile/keeper/query_params_test.go index 9b525ee8a..23b25fc37 100644 --- a/x/assetprofile/keeper/query_params_test.go +++ b/x/assetprofile/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/assetprofile/types" "github.com/stretchr/testify/require" @@ -11,11 +10,10 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx := testkeeper.AssetprofileKeeper(t) - wctx := sdk.WrapSDKContext(ctx) params := types.DefaultParams() keeper.SetParams(ctx, params) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/burner/keeper/msg_server_test.go b/x/burner/keeper/msg_server_test.go index c6f420213..319088186 100644 --- a/x/burner/keeper/msg_server_test.go +++ b/x/burner/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/burner/keeper" "github.com/elys-network/elys/x/burner/types" @@ -12,5 +11,5 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx, _ := keepertest.BurnerKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } diff --git a/x/burner/keeper/query_history_test.go b/x/burner/keeper/query_history_test.go index 21a30128f..15a13b1d1 100644 --- a/x/burner/keeper/query_history_test.go +++ b/x/burner/keeper/query_history_test.go @@ -4,7 +4,6 @@ import ( "strconv" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -17,7 +16,6 @@ import ( func TestHistoryQuerySingle(t *testing.T) { keeper, ctx, _ := keepertest.BurnerKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNHistory(keeper, ctx, 2) for _, tc := range []struct { desc string @@ -55,7 +53,7 @@ func TestHistoryQuerySingle(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.History(wctx, tc.request) + response, err := keeper.History(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -71,7 +69,6 @@ func TestHistoryQuerySingle(t *testing.T) { func TestHistoryQueryPaginated(t *testing.T) { keeper, ctx, _ := keepertest.BurnerKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createNHistory(keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllHistoryRequest { @@ -87,7 +84,7 @@ func TestHistoryQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.HistoryAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.HistoryAll(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.History), step) require.Subset(t, @@ -100,7 +97,7 @@ func TestHistoryQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.HistoryAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.HistoryAll(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.History), step) require.Subset(t, @@ -111,7 +108,7 @@ func TestHistoryQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.HistoryAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.HistoryAll(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -120,7 +117,7 @@ func TestHistoryQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.HistoryAll(wctx, nil) + _, err := keeper.HistoryAll(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/burner/keeper/query_params_test.go b/x/burner/keeper/query_params_test.go index 712fd43e6..f63e5bf71 100644 --- a/x/burner/keeper/query_params_test.go +++ b/x/burner/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/burner/types" "github.com/stretchr/testify/require" @@ -11,11 +10,10 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx, _ := testkeeper.BurnerKeeper(t) - wctx := sdk.WrapSDKContext(ctx) params := types.DefaultParams() keeper.SetParams(ctx, ¶ms) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/commitment/keeper/msg_server_stake.go b/x/commitment/keeper/msg_server_stake.go index ddaa8d187..eb9bbf199 100644 --- a/x/commitment/keeper/msg_server_stake.go +++ b/x/commitment/keeper/msg_server_stake.go @@ -58,7 +58,7 @@ func (k msgServer) performStakeElys(ctx sdk.Context, msg *types.MsgStake) error } msgMsgDelegate := stakingtypes.NewMsgDelegate(address.String(), validator_address.String(), amount) - if _, err := msgServer.Delegate(sdk.WrapSDKContext(ctx), msgMsgDelegate); err != nil { // Discard the response because it's empty + if _, err := msgServer.Delegate(ctx, msgMsgDelegate); err != nil { // Discard the response because it's empty return errorsmod.Wrap(err, "elys stake msg") } @@ -72,7 +72,7 @@ func (k msgServer) performCommit(ctx sdk.Context, msg *types.MsgStake) error { return errorsmod.Wrap(err, "failed validating msgMsgCommit") } - _, err := k.CommitClaimedRewards(sdk.WrapSDKContext(ctx), msgMsgCommit) // Discard the response because it's empty + _, err := k.CommitClaimedRewards(ctx, msgMsgCommit) // Discard the response because it's empty if err != nil { return errorsmod.Wrap(err, "commit msg") } diff --git a/x/commitment/keeper/msg_server_stake_test.go b/x/commitment/keeper/msg_server_stake_test.go index 84d096b98..077d3e4c2 100644 --- a/x/commitment/keeper/msg_server_stake_test.go +++ b/x/commitment/keeper/msg_server_stake_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - sdkmath "cosmossdk.io/math" "testing" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" simapp "github.com/elys-network/elys/app" @@ -53,7 +54,7 @@ func TestKeeper_Stake(t *testing.T) { require.NoError(t, err) // Call the Stake function - _, err = msgServer.Stake(sdk.WrapSDKContext(ctx), &types.MsgStake{ + _, err = msgServer.Stake(ctx, &types.MsgStake{ Creator: creator, Asset: denom, Amount: uncommitAmount, diff --git a/x/commitment/keeper/msg_server_test.go b/x/commitment/keeper/msg_server_test.go index d6db6eec1..d374c516b 100644 --- a/x/commitment/keeper/msg_server_test.go +++ b/x/commitment/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/commitment/keeper" "github.com/elys-network/elys/x/commitment/types" @@ -12,5 +11,5 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx := keepertest.CommitmentKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } diff --git a/x/commitment/keeper/msg_server_uncommit_tokens_test.go b/x/commitment/keeper/msg_server_uncommit_tokens_test.go index a0874daff..08c24fe19 100644 --- a/x/commitment/keeper/msg_server_uncommit_tokens_test.go +++ b/x/commitment/keeper/msg_server_uncommit_tokens_test.go @@ -214,7 +214,7 @@ func TestMsgServerUncommitTokensNoDelegationError(t *testing.T) { msgServer := commitmentkeeper.NewMsgServerImpl(*keeper) // Call the UncommitTokens function through the MsgServer - _, err := msgServer.UncommitTokens(sdk.WrapSDKContext(ctx), &types.MsgUncommitTokens{ + _, err := msgServer.UncommitTokens(ctx, &types.MsgUncommitTokens{ Creator: creator, Denom: denom, Amount: uncommitAmount, @@ -255,7 +255,7 @@ func TestMsgServerUncommitTokensUnsupportedUncommitTokenError(t *testing.T) { msgServer := commitmentkeeper.NewMsgServerImpl(*keeper) // Call the UncommitTokens function through the MsgServer - _, err := msgServer.UncommitTokens(sdk.WrapSDKContext(ctx), &types.MsgUncommitTokens{ + _, err := msgServer.UncommitTokens(ctx, &types.MsgUncommitTokens{ Creator: creator, Denom: denom, Amount: uncommitAmount, @@ -275,7 +275,7 @@ func TestMsgServerUncommitTokensInvalidAddressError(t *testing.T) { msgServer := commitmentkeeper.NewMsgServerImpl(*keeper) // Call the UncommitTokens function through the MsgServer - _, err := msgServer.UncommitTokens(sdk.WrapSDKContext(ctx), &types.MsgUncommitTokens{ + _, err := msgServer.UncommitTokens(ctx, &types.MsgUncommitTokens{ Creator: "invalid_address", Denom: ptypes.Eden, Amount: sdkmath.NewInt(100), diff --git a/x/commitment/keeper/msg_server_unstake.go b/x/commitment/keeper/msg_server_unstake.go index bcbc15845..59deea480 100644 --- a/x/commitment/keeper/msg_server_unstake.go +++ b/x/commitment/keeper/msg_server_unstake.go @@ -58,7 +58,7 @@ func (k msgServer) performUnstakeElys(ctx sdk.Context, msg *types.MsgUnstake) er } msgMsgUndelegate := stakingtypes.NewMsgUndelegate(address.String(), validator_address.String(), amount) - if _, err := msgServer.Undelegate(sdk.WrapSDKContext(ctx), msgMsgUndelegate); err != nil { // Discard the response because it's empty + if _, err := msgServer.Undelegate(ctx, msgMsgUndelegate); err != nil { // Discard the response because it's empty return errorsmod.Wrap(err, "elys unstake msg") } @@ -72,7 +72,7 @@ func (k msgServer) performUncommit(ctx sdk.Context, msg *types.MsgUnstake) error return errorsmod.Wrap(err, "failed validating msgMsgUncommit") } - _, err := k.UncommitTokens(sdk.WrapSDKContext(ctx), msgMsgUncommit) // Discard the response because it's empty + _, err := k.UncommitTokens(ctx, msgMsgUncommit) // Discard the response because it's empty if err != nil { return errorsmod.Wrap(err, "uncommit msg") } diff --git a/x/commitment/keeper/msg_server_unstake_test.go b/x/commitment/keeper/msg_server_unstake_test.go index 5d1cb3481..ea0d5158b 100644 --- a/x/commitment/keeper/msg_server_unstake_test.go +++ b/x/commitment/keeper/msg_server_unstake_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - sdkmath "cosmossdk.io/math" "testing" + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" simapp "github.com/elys-network/elys/app" @@ -53,7 +54,7 @@ func TestKeeper_UnstakeWithElys(t *testing.T) { require.NoError(t, err) // Call the Stake function - _, err = msgServer.Unstake(sdk.WrapSDKContext(ctx), &types.MsgUnstake{ + _, err = msgServer.Unstake(ctx, &types.MsgUnstake{ Creator: creator, Asset: denom, Amount: uncommitAmount, @@ -102,7 +103,7 @@ func TestKeeper_UnstakeWithElysNegativeAmount(t *testing.T) { require.NoError(t, err) // Call the Stake function - _, err = msgServer.Unstake(sdk.WrapSDKContext(ctx), &types.MsgUnstake{ + _, err = msgServer.Unstake(ctx, &types.MsgUnstake{ Creator: "invalid_address", Asset: denom, Amount: uncommitAmount, @@ -151,7 +152,7 @@ func TestKeeper_UnstakeWithUncommitInvalidValidatorAddress(t *testing.T) { require.NoError(t, err) // Call the Stake function - _, err = msgServer.Unstake(sdk.WrapSDKContext(ctx), &types.MsgUnstake{ + _, err = msgServer.Unstake(ctx, &types.MsgUnstake{ Creator: creator, Asset: denom, Amount: uncommitAmount, @@ -199,7 +200,7 @@ func TestKeeper_UnstakeWithUncommit(t *testing.T) { require.NoError(t, err) // Call the Stake function - _, err = msgServer.Unstake(sdk.WrapSDKContext(ctx), &types.MsgUnstake{ + _, err = msgServer.Unstake(ctx, &types.MsgUnstake{ Creator: creator, Asset: denom, Amount: uncommitAmount, @@ -248,7 +249,7 @@ func TestKeeper_UnstakeWithUncommitNegativeAmount(t *testing.T) { require.NoError(t, err) // Call the Stake function - _, err = msgServer.Unstake(sdk.WrapSDKContext(ctx), &types.MsgUnstake{ + _, err = msgServer.Unstake(ctx, &types.MsgUnstake{ Creator: creator, Asset: denom, Amount: uncommitAmount, diff --git a/x/commitment/keeper/query_params_test.go b/x/commitment/keeper/query_params_test.go index bfd6eaa48..bc6252a69 100644 --- a/x/commitment/keeper/query_params_test.go +++ b/x/commitment/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/commitment/types" "github.com/stretchr/testify/require" @@ -13,11 +12,10 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx := testkeeper.CommitmentKeeper(t) - wctx := sdk.WrapSDKContext(ctx) params := types.DefaultParams() keeper.SetParams(ctx, params) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } @@ -25,8 +23,7 @@ func TestParamsQuery(t *testing.T) { // TestParamsQueryNilRequest tests the case where the request is nil func TestParamsQueryNilRequest(t *testing.T) { keeper, ctx := testkeeper.CommitmentKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - _, err := keeper.Params(wctx, nil) + _, err := keeper.Params(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) } diff --git a/x/epochs/keeper/grpc_query_test.go b/x/epochs/keeper/grpc_query_test.go index 5caf44d21..a5c8bc7d0 100644 --- a/x/epochs/keeper/grpc_query_test.go +++ b/x/epochs/keeper/grpc_query_test.go @@ -4,7 +4,6 @@ import ( "strconv" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -17,7 +16,6 @@ import ( func TestEpochInfoQuerySingle(t *testing.T) { keeper, ctx := keepertest.EpochsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createEpochInfos(keeper, ctx) for _, tc := range []struct { desc string @@ -52,7 +50,7 @@ func TestEpochInfoQuerySingle(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.CurrentEpoch(wctx, tc.request) + response, err := keeper.CurrentEpoch(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -68,7 +66,6 @@ func TestEpochInfoQuerySingle(t *testing.T) { func TestEntryQueryPaginated(t *testing.T) { keeper, ctx := keepertest.EpochsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) msgs := createEpochInfos(keeper, ctx) request := func(next []byte, offset, limit uint64, total bool) *types.QueryEpochsInfoRequest { @@ -84,7 +81,7 @@ func TestEntryQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.EpochInfos(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.EpochInfos(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Epochs), step) require.Subset(t, @@ -97,7 +94,7 @@ func TestEntryQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.EpochInfos(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.EpochInfos(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Epochs), step) require.Subset(t, @@ -108,7 +105,7 @@ func TestEntryQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.EpochInfos(wctx, request(nil, 0, 0, true)) + resp, err := keeper.EpochInfos(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -117,7 +114,7 @@ func TestEntryQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.EpochInfos(wctx, nil) + _, err := keeper.EpochInfos(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "empty request")) }) } diff --git a/x/estaking/keeper/keeper_burn_edenB_test.go b/x/estaking/keeper/keeper_burn_edenB_test.go index da2eec054..b5144778d 100644 --- a/x/estaking/keeper/keeper_burn_edenB_test.go +++ b/x/estaking/keeper/keeper_burn_edenB_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" commkeeper "github.com/elys-network/elys/x/commitment/keeper" ctypes "github.com/elys-network/elys/x/commitment/types" ptypes "github.com/elys-network/elys/x/parameter/types" @@ -77,7 +76,7 @@ func (suite *EstakingKeeperTestSuite) TestBurnEdenBFromEdenUncommitted() { suite.Require().NoError(err) // Uncommit tokens - _, err = msgServer.UncommitTokens(sdk.WrapSDKContext(suite.ctx), &ctypes.MsgUncommitTokens{ + _, err = msgServer.UncommitTokens(suite.ctx, &ctypes.MsgUncommitTokens{ Creator: suite.genAccount.String(), Amount: math.NewInt(1000), Denom: ptypes.Eden, diff --git a/x/estaking/keeper/keeper_test.go b/x/estaking/keeper/keeper_test.go index 8fef2fe56..c2d734c04 100644 --- a/x/estaking/keeper/keeper_test.go +++ b/x/estaking/keeper/keeper_test.go @@ -178,7 +178,7 @@ func (suite *EstakingKeeperTestSuite) TestEstakingExtendedFunctions() { suite.SetAssetProfile() commitmentMsgServer := ckeeper.NewMsgServerImpl(*suite.app.CommitmentKeeper) - _, err = commitmentMsgServer.CommitClaimedRewards(sdk.WrapSDKContext(suite.ctx), &ctypes.MsgCommitClaimedRewards{ + _, err = commitmentMsgServer.CommitClaimedRewards(suite.ctx, &ctypes.MsgCommitClaimedRewards{ Creator: addr.String(), Denom: ptypes.Eden, Amount: math.NewInt(1000_000), diff --git a/x/estaking/keeper/msg_server_test.go b/x/estaking/keeper/msg_server_test.go index 0a7faed46..b838686d1 100644 --- a/x/estaking/keeper/msg_server_test.go +++ b/x/estaking/keeper/msg_server_test.go @@ -151,7 +151,7 @@ func (suite *EstakingKeeperTestSuite) TestMsgServer() { WithdrawEnabled: true, }) commitmentMsgServer := commitmentkeeper.NewMsgServerImpl(*suite.app.CommitmentKeeper) - _, err = commitmentMsgServer.CommitClaimedRewards(sdk.WrapSDKContext(suite.ctx), &commitmenttypes.MsgCommitClaimedRewards{ + _, err = commitmentMsgServer.CommitClaimedRewards(suite.ctx, &commitmenttypes.MsgCommitClaimedRewards{ Creator: addr.String(), Denom: ptypes.Eden, Amount: math.NewInt(1000_000), @@ -216,7 +216,7 @@ func (suite *EstakingKeeperTestSuite) TestMsgServer() { WithdrawEnabled: true, }) commitmentMsgServer := commitmentkeeper.NewMsgServerImpl(*suite.app.CommitmentKeeper) - _, err = commitmentMsgServer.CommitClaimedRewards(sdk.WrapSDKContext(suite.ctx), &commitmenttypes.MsgCommitClaimedRewards{ + _, err = commitmentMsgServer.CommitClaimedRewards(suite.ctx, &commitmenttypes.MsgCommitClaimedRewards{ Creator: addr.String(), Denom: ptypes.EdenB, Amount: math.NewInt(1000_000), diff --git a/x/leveragelp/keeper/position_close_test.go b/x/leveragelp/keeper/position_close_test.go index 0dfe7b3eb..b20c878ff 100644 --- a/x/leveragelp/keeper/position_close_test.go +++ b/x/leveragelp/keeper/position_close_test.go @@ -77,7 +77,7 @@ func (suite *KeeperTestSuite) OpenPosition(addr sdk.AccAddress) (*types.Position suite.Require().NoError(err) stableMsgServer := stablestakekeeper.NewMsgServerImpl(*suite.app.StablestakeKeeper) - _, err = stableMsgServer.Bond(sdk.WrapSDKContext(suite.ctx), &stablestaketypes.MsgBond{ + _, err = stableMsgServer.Bond(suite.ctx, &stablestaketypes.MsgBond{ Creator: addr.String(), Amount: math.NewInt(amount * 10), }) diff --git a/x/leveragelp/keeper/position_open_test.go b/x/leveragelp/keeper/position_open_test.go index 9ce94c239..7b07402a7 100644 --- a/x/leveragelp/keeper/position_open_test.go +++ b/x/leveragelp/keeper/position_open_test.go @@ -81,7 +81,7 @@ func (suite *KeeperTestSuite) TestOpenLong() { suite.Require().NoError(err) stableMsgServer := stablestakekeeper.NewMsgServerImpl(*suite.app.StablestakeKeeper) - _, err = stableMsgServer.Bond(sdk.WrapSDKContext(suite.ctx), &stablestaketypes.MsgBond{ + _, err = stableMsgServer.Bond(suite.ctx, &stablestaketypes.MsgBond{ Creator: addr.String(), Amount: sdkmath.NewInt(10000), }) diff --git a/x/leveragelp/keeper/query_estimation_test.go b/x/leveragelp/keeper/query_estimation_test.go index 79f6667a2..26da0f149 100644 --- a/x/leveragelp/keeper/query_estimation_test.go +++ b/x/leveragelp/keeper/query_estimation_test.go @@ -78,7 +78,7 @@ func (suite *KeeperTestSuite) TestQueryEstimation() { suite.Require().NoError(err) stableMsgServer := stablestakekeeper.NewMsgServerImpl(*suite.app.StablestakeKeeper) - _, err = stableMsgServer.Bond(sdk.WrapSDKContext(suite.ctx), &stablestaketypes.MsgBond{ + _, err = stableMsgServer.Bond(suite.ctx, &stablestaketypes.MsgBond{ Creator: addr.String(), Amount: sdkmath.NewInt(10000), }) diff --git a/x/leveragelp/keeper/query_get_position_test.go b/x/leveragelp/keeper/query_get_position_test.go index 9360df9c4..c3ec56a6e 100644 --- a/x/leveragelp/keeper/query_get_position_test.go +++ b/x/leveragelp/keeper/query_get_position_test.go @@ -77,7 +77,7 @@ func (suite *KeeperTestSuite) TestQueryGetPosition() { suite.Require().NoError(err) stableMsgServer := stablestakekeeper.NewMsgServerImpl(*suite.app.StablestakeKeeper) - _, err = stableMsgServer.Bond(sdk.WrapSDKContext(suite.ctx), &stablestaketypes.MsgBond{ + _, err = stableMsgServer.Bond(suite.ctx, &stablestaketypes.MsgBond{ Creator: addr.String(), Amount: sdkmath.NewInt(10000), }) diff --git a/x/leveragelp/keeper/query_params_test.go b/x/leveragelp/keeper/query_params_test.go index 3ffff8509..54fdc8dac 100644 --- a/x/leveragelp/keeper/query_params_test.go +++ b/x/leveragelp/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/leveragelp/types" "github.com/stretchr/testify/require" @@ -11,11 +10,11 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx := testkeeper.LeveragelpKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() keeper.SetParams(ctx, ¶ms) - response, err := keeper.Params(wctx, &types.ParamsRequest{}) + response, err := keeper.Params(ctx, &types.ParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.ParamsResponse{Params: params}, response) } diff --git a/x/leveragelp/keeper/query_pool_test.go b/x/leveragelp/keeper/query_pool_test.go index 01c568c7c..d55765994 100644 --- a/x/leveragelp/keeper/query_pool_test.go +++ b/x/leveragelp/keeper/query_pool_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -16,7 +15,7 @@ import ( func TestPoolQuerySingle(t *testing.T) { keeper, ctx := keepertest.LeveragelpKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + msgs := createNPool(keeper, ctx, 2) tests := []struct { desc string @@ -52,7 +51,7 @@ func TestPoolQuerySingle(t *testing.T) { } for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.Pool(wctx, tc.request) + response, err := keeper.Pool(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -68,7 +67,7 @@ func TestPoolQuerySingle(t *testing.T) { func TestPoolQueryPaginated(t *testing.T) { keeper, ctx := keepertest.LeveragelpKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + msgs := createNPool(keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllPoolRequest { @@ -84,7 +83,7 @@ func TestPoolQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.Pools(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.Pools(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Pool), step) require.Subset(t, @@ -97,7 +96,7 @@ func TestPoolQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.Pools(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.Pools(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Pool), step) require.Subset(t, @@ -108,7 +107,7 @@ func TestPoolQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.Pools(wctx, request(nil, 0, 0, true)) + resp, err := keeper.Pools(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -117,7 +116,7 @@ func TestPoolQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.Pools(wctx, nil) + _, err := keeper.Pools(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/masterchef/keeper/apr_pool_test.go b/x/masterchef/keeper/apr_pool_test.go index cd48f687f..68baefd13 100644 --- a/x/masterchef/keeper/apr_pool_test.go +++ b/x/masterchef/keeper/apr_pool_test.go @@ -65,7 +65,7 @@ func TestCalculatePoolAprs(t *testing.T) { // Create a Elys+USDC pool msgServer := ammkeeper.NewMsgServerImpl(*amm) resp, err := msgServer.CreatePool( - sdk.WrapSDKContext(ctx), + ctx, &ammtypes.MsgCreatePool{ Sender: addr[0].String(), PoolParams: poolParams, diff --git a/x/masterchef/keeper/external_incentive_test.go b/x/masterchef/keeper/external_incentive_test.go index 753a19c06..e8e87bb68 100644 --- a/x/masterchef/keeper/external_incentive_test.go +++ b/x/masterchef/keeper/external_incentive_test.go @@ -96,8 +96,7 @@ func TestUSDCExternalIncentive(t *testing.T) { Description: "Description", } - wctx := sdk.WrapSDKContext(ctx) - _, err := srv.CreateTimeBasedInflation(wctx, expected) + _, err := srv.CreateTimeBasedInflation(ctx, expected) require.NoError(t, err) expected = &tokenomicstypes.MsgCreateTimeBasedInflation{ @@ -113,7 +112,7 @@ func TestUSDCExternalIncentive(t *testing.T) { }, Description: "Description", } - _, err = srv.CreateTimeBasedInflation(wctx, expected) + _, err = srv.CreateTimeBasedInflation(ctx, expected) require.NoError(t, err) // Generate 1 random account with 1000stake balanced @@ -191,14 +190,14 @@ func TestUSDCExternalIncentive(t *testing.T) { require.NoError(t, err) masterchefSrv := masterchefkeeper.NewMsgServerImpl(app.MasterchefKeeper) - _, err = masterchefSrv.AddExternalRewardDenom(sdk.WrapSDKContext(ctx), &types.MsgAddExternalRewardDenom{ + _, err = masterchefSrv.AddExternalRewardDenom(ctx, &types.MsgAddExternalRewardDenom{ Authority: app.GovKeeper.GetAuthority(), RewardDenom: ptypes.BaseCurrency, MinAmount: sdkmath.OneInt(), Supported: true, }) require.NoError(t, err) - _, err = masterchefSrv.AddExternalIncentive(sdk.WrapSDKContext(ctx), &types.MsgAddExternalIncentive{ + _, err = masterchefSrv.AddExternalIncentive(ctx, &types.MsgAddExternalIncentive{ Sender: addr[0].String(), RewardDenom: ptypes.BaseCurrency, PoolId: pools[0].PoolId, @@ -240,12 +239,12 @@ func TestUSDCExternalIncentive(t *testing.T) { prevUSDCBal := app.BankKeeper.GetBalance(ctx, addr[1], ptypes.BaseCurrency) // check rewards claimed - _, err = masterchefSrv.ClaimRewards(sdk.WrapSDKContext(ctx), &types.MsgClaimRewards{ + _, err = masterchefSrv.ClaimRewards(ctx, &types.MsgClaimRewards{ Sender: addr[0].String(), PoolIds: []uint64{pools[0].PoolId}, }) require.NoError(t, err) - _, err = masterchefSrv.ClaimRewards(sdk.WrapSDKContext(ctx), &types.MsgClaimRewards{ + _, err = masterchefSrv.ClaimRewards(ctx, &types.MsgClaimRewards{ Sender: addr[1].String(), PoolIds: []uint64{pools[0].PoolId}, }) diff --git a/x/masterchef/keeper/msg_server_test.go b/x/masterchef/keeper/msg_server_test.go index 0c31cecd6..17b8d7c9a 100644 --- a/x/masterchef/keeper/msg_server_test.go +++ b/x/masterchef/keeper/msg_server_test.go @@ -2,10 +2,10 @@ package keeper_test import ( "context" - sdkmath "cosmossdk.io/math" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" + sdkmath "cosmossdk.io/math" + keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/masterchef/keeper" "github.com/elys-network/elys/x/masterchef/types" @@ -26,7 +26,7 @@ func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { EnableEdenRewards: false, }) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } func TestMsgServer(t *testing.T) { diff --git a/x/masterchef/keeper/query_apr_test.go b/x/masterchef/keeper/query_apr_test.go index 630ed3af1..5753c8800 100644 --- a/x/masterchef/keeper/query_apr_test.go +++ b/x/masterchef/keeper/query_apr_test.go @@ -66,7 +66,7 @@ func SetupApp(t *testing.T) (keeper.Keeper, sdk.Context) { // Create a Elys+USDC pool msgServer := ammkeeper.NewMsgServerImpl(*amm) resp, err := msgServer.CreatePool( - sdk.WrapSDKContext(ctx), + ctx, &ammtypes.MsgCreatePool{ Sender: addr[0].String(), PoolParams: poolParams, diff --git a/x/masterchef/keeper/query_params_test.go b/x/masterchef/keeper/query_params_test.go index 126d1180e..2b53425ac 100644 --- a/x/masterchef/keeper/query_params_test.go +++ b/x/masterchef/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/masterchef/types" "github.com/stretchr/testify/require" @@ -11,11 +10,11 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx := testkeeper.MasterchefKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() keeper.SetParams(ctx, params) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/masterchef/keeper/query_show_fee_info_test.go b/x/masterchef/keeper/query_show_fee_info_test.go index cf969cb2f..22a335603 100644 --- a/x/masterchef/keeper/query_show_fee_info_test.go +++ b/x/masterchef/keeper/query_show_fee_info_test.go @@ -1,10 +1,10 @@ package keeper_test import ( - "cosmossdk.io/math" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/math" + testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/masterchef/types" "github.com/stretchr/testify/require" @@ -12,7 +12,7 @@ import ( func TestShowFeeInfoQuery(t *testing.T) { keeper, ctx := testkeeper.MasterchefKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + newInfo := types.FeeInfo{ GasLp: math.NewInt(300), GasStakers: math.NewInt(150), @@ -27,14 +27,14 @@ func TestShowFeeInfoQuery(t *testing.T) { } keeper.SetFeeInfo(ctx, newInfo, "2024-05-01") - response, err := keeper.ShowFeeInfo(wctx, &types.QueryShowFeeInfoRequest{Date: "2024-05-01"}) + response, err := keeper.ShowFeeInfo(ctx, &types.QueryShowFeeInfoRequest{Date: "2024-05-01"}) require.NoError(t, err) require.Equal(t, &types.QueryShowFeeInfoResponse{FeeInfo: newInfo}, response) } func TestListFeeInfoQuery(t *testing.T) { keeper, ctx := testkeeper.MasterchefKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + newInfo := types.FeeInfo{ GasLp: math.NewInt(300), GasStakers: math.NewInt(150), @@ -50,7 +50,7 @@ func TestListFeeInfoQuery(t *testing.T) { keeper.SetFeeInfo(ctx, newInfo, "2024-05-01") keeper.SetFeeInfo(ctx, newInfo, "2024-05-02") - response, err := keeper.ListFeeInfo(wctx, &types.QueryListFeeInfoRequest{}) + response, err := keeper.ListFeeInfo(ctx, &types.QueryListFeeInfoRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryListFeeInfoResponse{FeeInfo: []types.FeeInfo{newInfo, newInfo}}, response) } diff --git a/x/oracle/keeper/grpc_query_params_test.go b/x/oracle/keeper/grpc_query_params_test.go index b2f785465..f405d8fba 100644 --- a/x/oracle/keeper/grpc_query_params_test.go +++ b/x/oracle/keeper/grpc_query_params_test.go @@ -1,17 +1,16 @@ package keeper_test import ( - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/elys-network/elys/x/oracle/types" ) func (suite *KeeperTestSuite) TestParamsQuery() { keeper, ctx := suite.app.OracleKeeper, suite.ctx - wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() keeper.SetParams(ctx, params) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) suite.Require().NoError(err) suite.Require().Equal(&types.QueryParamsResponse{Params: params}, response) } diff --git a/x/oracle/keeper/grpc_query_price_feeder_test.go b/x/oracle/keeper/grpc_query_price_feeder_test.go index b424dc966..db0bd070a 100644 --- a/x/oracle/keeper/grpc_query_price_feeder_test.go +++ b/x/oracle/keeper/grpc_query_price_feeder_test.go @@ -1,10 +1,10 @@ package keeper_test import ( - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "strconv" - sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -15,7 +15,7 @@ import ( func (suite *KeeperTestSuite) TestPriceFeederQuerySingle() { keeper, ctx := suite.app.OracleKeeper, suite.ctx - wctx := sdk.WrapSDKContext(ctx) + msgs := createNPriceFeeder(&keeper, ctx, 2) for _, tc := range []struct { desc string @@ -50,7 +50,7 @@ func (suite *KeeperTestSuite) TestPriceFeederQuerySingle() { }, } { suite.Run(tc.desc, func() { - response, err := keeper.PriceFeeder(wctx, tc.request) + response, err := keeper.PriceFeeder(ctx, tc.request) if tc.err != nil { suite.Require().ErrorIs(err, tc.err) } else { @@ -66,7 +66,7 @@ func (suite *KeeperTestSuite) TestPriceFeederQuerySingle() { func (suite *KeeperTestSuite) TestPriceFeederQueryPaginated() { keeper, ctx := suite.app.OracleKeeper, suite.ctx - wctx := sdk.WrapSDKContext(ctx) + msgs := createNPriceFeeder(&keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllPriceFeederRequest { @@ -82,7 +82,7 @@ func (suite *KeeperTestSuite) TestPriceFeederQueryPaginated() { suite.Run("ByOffset", func() { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.PriceFeederAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.PriceFeederAll(ctx, request(nil, uint64(i), uint64(step), false)) suite.Require().NoError(err) suite.Require().LessOrEqual(len(resp.PriceFeeder), step) suite.Require().Subset( @@ -95,7 +95,7 @@ func (suite *KeeperTestSuite) TestPriceFeederQueryPaginated() { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.PriceFeederAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.PriceFeederAll(ctx, request(next, 0, uint64(step), false)) suite.Require().NoError(err) suite.Require().LessOrEqual(len(resp.PriceFeeder), step) suite.Require().Subset( @@ -106,7 +106,7 @@ func (suite *KeeperTestSuite) TestPriceFeederQueryPaginated() { } }) suite.Run("Total", func() { - resp, err := keeper.PriceFeederAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.PriceFeederAll(ctx, request(nil, 0, 0, true)) suite.Require().NoError(err) suite.Require().Equal(len(msgs), int(resp.Pagination.Total)) suite.Require().ElementsMatch( @@ -115,7 +115,7 @@ func (suite *KeeperTestSuite) TestPriceFeederQueryPaginated() { ) }) suite.Run("InvalidRequest", func() { - _, err := keeper.PriceFeederAll(wctx, nil) + _, err := keeper.PriceFeederAll(ctx, nil) suite.Require().ErrorIs(err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/oracle/keeper/grpc_query_price_test.go b/x/oracle/keeper/grpc_query_price_test.go index 976b7b263..afa497ac6 100644 --- a/x/oracle/keeper/grpc_query_price_test.go +++ b/x/oracle/keeper/grpc_query_price_test.go @@ -2,7 +2,6 @@ package keeper_test import ( sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/elys-network/elys/x/oracle/types" ) @@ -30,25 +29,25 @@ func (suite *KeeperTestSuite) TestGRPCQueryPrice() { for _, price := range prices { suite.app.OracleKeeper.SetPrice(suite.ctx, price) } - resp, err := suite.app.OracleKeeper.Price(sdk.WrapSDKContext(suite.ctx), &types.QueryGetPriceRequest{ + resp, err := suite.app.OracleKeeper.Price(suite.ctx, &types.QueryGetPriceRequest{ Asset: "BTC", }) suite.Require().NoError(err) suite.Require().Equal(resp.Price, prices[2]) - resp, err = suite.app.OracleKeeper.Price(sdk.WrapSDKContext(suite.ctx), &types.QueryGetPriceRequest{ + resp, err = suite.app.OracleKeeper.Price(suite.ctx, &types.QueryGetPriceRequest{ Asset: "BTC", Source: "elys", }) suite.Require().NoError(err) suite.Require().Equal(resp.Price, prices[0]) - resp, err = suite.app.OracleKeeper.Price(sdk.WrapSDKContext(suite.ctx), &types.QueryGetPriceRequest{ + resp, err = suite.app.OracleKeeper.Price(suite.ctx, &types.QueryGetPriceRequest{ Asset: "BTC", Source: "elys", Timestamp: 100000, }) suite.Require().NoError(err) suite.Require().Equal(resp.Price, prices[0]) - resp, err = suite.app.OracleKeeper.Price(sdk.WrapSDKContext(suite.ctx), &types.QueryGetPriceRequest{ + resp, err = suite.app.OracleKeeper.Price(suite.ctx, &types.QueryGetPriceRequest{ Asset: "BTC", Source: "elys", Timestamp: 11000, diff --git a/x/oracle/keeper/msg_server_price_feeder_test.go b/x/oracle/keeper/msg_server_price_feeder_test.go index f432883d6..bb6f5e60c 100644 --- a/x/oracle/keeper/msg_server_price_feeder_test.go +++ b/x/oracle/keeper/msg_server_price_feeder_test.go @@ -35,8 +35,8 @@ func (suite *KeeperTestSuite) TestPriceFeederMsgServerUpdate() { }) srv := keeper.NewMsgServerImpl(k) - wctx := sdk.WrapSDKContext(ctx) - _, err := srv.SetPriceFeeder(wctx, tc.request) + + _, err := srv.SetPriceFeeder(ctx, tc.request) if tc.err != nil { suite.Require().ErrorIs(err, tc.err) } else { @@ -76,8 +76,8 @@ func (suite *KeeperTestSuite) TestPriceFeederMsgServerDelete() { }) srv := keeper.NewMsgServerImpl(k) - wctx := sdk.WrapSDKContext(ctx) - _, err := srv.DeletePriceFeeder(wctx, tc.request) + + _, err := srv.DeletePriceFeeder(ctx, tc.request) if tc.err != nil { suite.Require().ErrorIs(err, tc.err) } else { diff --git a/x/parameter/keeper/msg_server_test.go b/x/parameter/keeper/msg_server_test.go index d532700fc..113b4df92 100644 --- a/x/parameter/keeper/msg_server_test.go +++ b/x/parameter/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/parameter/keeper" "github.com/elys-network/elys/x/parameter/types" @@ -12,5 +11,5 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx := keepertest.ParameterKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } diff --git a/x/parameter/keeper/msg_server_update_rewards_data_lifetime_test.go b/x/parameter/keeper/msg_server_update_rewards_data_lifetime_test.go index cb05fe617..303854bf5 100644 --- a/x/parameter/keeper/msg_server_update_rewards_data_lifetime_test.go +++ b/x/parameter/keeper/msg_server_update_rewards_data_lifetime_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/parameter/keeper" "github.com/elys-network/elys/x/parameter/types" @@ -13,7 +12,6 @@ import ( func TestMsgServer_UpdateRewardsDataLifetime(t *testing.T) { k, ctx := keepertest.ParameterKeeper(t) srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) tests := []struct { name string @@ -61,7 +59,7 @@ func TestMsgServer_UpdateRewardsDataLifetime(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := srv.UpdateRewardsDataLifetime(wctx, tt.msg) + got, err := srv.UpdateRewardsDataLifetime(ctx, tt.msg) if tt.wantErr { require.Error(t, err) require.Nil(t, got) diff --git a/x/parameter/keeper/query_params_test.go b/x/parameter/keeper/query_params_test.go index 882fbf56c..999f38135 100644 --- a/x/parameter/keeper/query_params_test.go +++ b/x/parameter/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/parameter/types" "github.com/stretchr/testify/require" @@ -11,11 +10,11 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx := testkeeper.ParameterKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() keeper.SetParams(ctx, params) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/perpetual/keeper/query_params_test.go b/x/perpetual/keeper/query_params_test.go index 980ecc6ba..bba77d348 100644 --- a/x/perpetual/keeper/query_params_test.go +++ b/x/perpetual/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/perpetual/types" "github.com/stretchr/testify/require" @@ -11,11 +10,11 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx := testkeeper.PerpetualKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() keeper.SetParams(ctx, ¶ms) - response, err := keeper.Params(wctx, &types.ParamsRequest{}) + response, err := keeper.Params(ctx, &types.ParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.ParamsResponse{Params: params}, response) } diff --git a/x/stablestake/keeper/msg_server_bond_test.go b/x/stablestake/keeper/msg_server_bond_test.go index 276ea49cc..5e1be3c91 100644 --- a/x/stablestake/keeper/msg_server_bond_test.go +++ b/x/stablestake/keeper/msg_server_bond_test.go @@ -50,7 +50,7 @@ func (suite *KeeperTestSuite) TestMsgServerBond() { msgServer := keeper.NewMsgServerImpl(*suite.app.StablestakeKeeper) _, err = msgServer.Bond( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgBond{ Creator: sender.String(), Amount: tc.bondAmount, diff --git a/x/stablestake/keeper/msg_server_test.go b/x/stablestake/keeper/msg_server_test.go index 9f348c48e..bf2cecac6 100644 --- a/x/stablestake/keeper/msg_server_test.go +++ b/x/stablestake/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/stablestake/keeper" "github.com/elys-network/elys/x/stablestake/types" @@ -13,7 +12,7 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx := keepertest.StablestakeKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } func TestMsgServer(t *testing.T) { diff --git a/x/stablestake/keeper/msg_server_unbond_test.go b/x/stablestake/keeper/msg_server_unbond_test.go index 22ee73d62..6f21e1927 100644 --- a/x/stablestake/keeper/msg_server_unbond_test.go +++ b/x/stablestake/keeper/msg_server_unbond_test.go @@ -91,7 +91,7 @@ func (suite *KeeperTestSuite) TestUnbond() { msgServer := keeper.NewMsgServerImpl(*suite.app.StablestakeKeeper) _, err = msgServer.Unbond( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgUnbond{ Creator: sender.String(), Amount: tc.unbondAmount, diff --git a/x/stablestake/keeper/params_test.go b/x/stablestake/keeper/params_test.go index 65a3211b5..a480076db 100644 --- a/x/stablestake/keeper/params_test.go +++ b/x/stablestake/keeper/params_test.go @@ -63,7 +63,7 @@ func (suite *KeeperTestSuite) TestGetRedemptionRate() { msgServer := keeper.NewMsgServerImpl(*suite.app.StablestakeKeeper) _, err = msgServer.Bond( - sdk.WrapSDKContext(suite.ctx), + suite.ctx, &types.MsgBond{ Creator: sender.String(), Amount: tc.bondAmount, diff --git a/x/tier/keeper/portfolio.go b/x/tier/keeper/portfolio.go index e004e3540..7469091cb 100644 --- a/x/tier/keeper/portfolio.go +++ b/x/tier/keeper/portfolio.go @@ -322,7 +322,7 @@ func (k Keeper) CalcAmmPrice(ctx sdk.Context, denom string, decimal uint64) sdkm return sdkmath.LegacyZeroDec() } usdcPrice := k.oracleKeeper.GetAssetPriceFromDenom(ctx, usdcDenom) - resp, err := k.amm.InRouteByDenom(sdk.WrapSDKContext(ctx), &ammtypes.QueryInRouteByDenomRequest{DenomIn: denom, DenomOut: usdcDenom}) + resp, err := k.amm.InRouteByDenom(ctx, &ammtypes.QueryInRouteByDenomRequest{DenomIn: denom, DenomOut: usdcDenom}) if err != nil { return sdkmath.LegacyZeroDec() } diff --git a/x/tier/keeper/query_params_test.go b/x/tier/keeper/query_params_test.go index 13887a2ba..2fdeae600 100644 --- a/x/tier/keeper/query_params_test.go +++ b/x/tier/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/tier/types" "github.com/stretchr/testify/require" @@ -11,11 +10,11 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx := testkeeper.MembershiptierKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() keeper.SetParams(ctx, params) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/tier/keeper/query_portfolio_test.go b/x/tier/keeper/query_portfolio_test.go index df279adb5..8ab3486ff 100644 --- a/x/tier/keeper/query_portfolio_test.go +++ b/x/tier/keeper/query_portfolio_test.go @@ -4,7 +4,6 @@ import ( "strconv" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -20,7 +19,7 @@ var _ = strconv.IntSize func TestPortfolioQuerySingle(t *testing.T) { keeper, ctx := keepertest.MembershiptierKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + msgs := createNPortfolio(keeper, ctx, 2) tests := []struct { desc string @@ -57,7 +56,7 @@ func TestPortfolioQuerySingle(t *testing.T) { } for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.Portfolio(wctx, tc.request) + response, err := keeper.Portfolio(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -73,7 +72,7 @@ func TestPortfolioQuerySingle(t *testing.T) { func TestPortfolioQueryPaginated(t *testing.T) { keeper, ctx := keepertest.MembershiptierKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + msgs := createNPortfolio(keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllPortfolioRequest { @@ -89,7 +88,7 @@ func TestPortfolioQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.PortfolioAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.PortfolioAll(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Portfolio), step) require.Subset(t, @@ -102,7 +101,7 @@ func TestPortfolioQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.PortfolioAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.PortfolioAll(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Portfolio), step) require.Subset(t, @@ -113,7 +112,7 @@ func TestPortfolioQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.PortfolioAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.PortfolioAll(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -122,7 +121,7 @@ func TestPortfolioQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.PortfolioAll(wctx, nil) + _, err := keeper.PortfolioAll(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/tokenomics/keeper/msg_server_airdrop_test.go b/x/tokenomics/keeper/msg_server_airdrop_test.go index fd96f4df9..867ca9515 100644 --- a/x/tokenomics/keeper/msg_server_airdrop_test.go +++ b/x/tokenomics/keeper/msg_server_airdrop_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" @@ -19,14 +18,14 @@ import ( func TestAirdropMsgServerCreate(t *testing.T) { k, ctx := keepertest.TokenomicsKeeper(t) srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) + authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() for i := 0; i < 5; i++ { expected := &types.MsgCreateAirdrop{ Authority: authority, Intent: strconv.Itoa(i), } - _, err := srv.CreateAirdrop(wctx, expected) + _, err := srv.CreateAirdrop(ctx, expected) require.NoError(t, err) rst, found := k.GetAirdrop(ctx, expected.Intent, @@ -77,15 +76,14 @@ func TestAirdropMsgServerUpdate(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { k, ctx := keepertest.TokenomicsKeeper(t) srv := keeper.NewMsgServerImpl(*k) - wctx := ctx expected := &types.MsgCreateAirdrop{ Authority: authority, Intent: strconv.Itoa(0), } - _, err := srv.CreateAirdrop(wctx, expected) + _, err := srv.CreateAirdrop(ctx, expected) require.NoError(t, err) - _, err = srv.UpdateAirdrop(wctx, tc.request) + _, err = srv.UpdateAirdrop(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -135,14 +133,13 @@ func TestAirdropMsgServerDelete(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { k, ctx := keepertest.TokenomicsKeeper(t) srv := keeper.NewMsgServerImpl(*k) - wctx := ctx - _, err := srv.CreateAirdrop(wctx, &types.MsgCreateAirdrop{ + _, err := srv.CreateAirdrop(ctx, &types.MsgCreateAirdrop{ Authority: authority, Intent: strconv.Itoa(0), }) require.NoError(t, err) - _, err = srv.DeleteAirdrop(wctx, tc.request) + _, err = srv.DeleteAirdrop(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { diff --git a/x/tokenomics/keeper/msg_server_test.go b/x/tokenomics/keeper/msg_server_test.go index d7bf4a598..67aa2935a 100644 --- a/x/tokenomics/keeper/msg_server_test.go +++ b/x/tokenomics/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/tokenomics/keeper" "github.com/elys-network/elys/x/tokenomics/types" @@ -12,5 +11,5 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx := keepertest.TokenomicsKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } diff --git a/x/tokenomics/keeper/msg_server_time_based_inflation_test.go b/x/tokenomics/keeper/msg_server_time_based_inflation_test.go index b8ec537f9..6c771006c 100644 --- a/x/tokenomics/keeper/msg_server_time_based_inflation_test.go +++ b/x/tokenomics/keeper/msg_server_time_based_inflation_test.go @@ -99,7 +99,7 @@ func TestTimeBasedInflationMsgServerUpdate(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { k, ctx := keepertest.TokenomicsKeeper(t) srv := keeper.NewMsgServerImpl(*k) - wctx := ctx + expected := &types.MsgCreateTimeBasedInflation{ Authority: authority, StartBlockHeight: 100, @@ -107,10 +107,10 @@ func TestTimeBasedInflationMsgServerUpdate(t *testing.T) { Description: description, Inflation: inflation, } - _, err := srv.CreateTimeBasedInflation(wctx, expected) + _, err := srv.CreateTimeBasedInflation(ctx, expected) require.NoError(t, err) - _, err = srv.UpdateTimeBasedInflation(wctx, tc.request) + _, err = srv.UpdateTimeBasedInflation(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -164,9 +164,8 @@ func TestTimeBasedInflationMsgServerDelete(t *testing.T) { t.Run(tc.desc, func(t *testing.T) { k, ctx := keepertest.TokenomicsKeeper(t) srv := keeper.NewMsgServerImpl(*k) - wctx := ctx - _, err := srv.CreateTimeBasedInflation(wctx, &types.MsgCreateTimeBasedInflation{ + _, err := srv.CreateTimeBasedInflation(ctx, &types.MsgCreateTimeBasedInflation{ Description: "Test create time based inflation", Authority: authority, StartBlockHeight: 10, @@ -180,7 +179,7 @@ func TestTimeBasedInflationMsgServerDelete(t *testing.T) { }, }) require.NoError(t, err) - _, err = srv.DeleteTimeBasedInflation(wctx, tc.request) + _, err = srv.DeleteTimeBasedInflation(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { diff --git a/x/tokenomics/keeper/query_airdrop_test.go b/x/tokenomics/keeper/query_airdrop_test.go index 93d028477..91c5c44d2 100644 --- a/x/tokenomics/keeper/query_airdrop_test.go +++ b/x/tokenomics/keeper/query_airdrop_test.go @@ -4,7 +4,6 @@ import ( "strconv" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -17,7 +16,7 @@ import ( func TestAirdropQuerySingle(t *testing.T) { keeper, ctx := keepertest.TokenomicsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + msgs := createNAirdrop(keeper, ctx, 2) for _, tc := range []struct { desc string @@ -52,7 +51,7 @@ func TestAirdropQuerySingle(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.Airdrop(wctx, tc.request) + response, err := keeper.Airdrop(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -68,7 +67,7 @@ func TestAirdropQuerySingle(t *testing.T) { func TestAirdropQueryPaginated(t *testing.T) { keeper, ctx := keepertest.TokenomicsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + msgs := createNAirdrop(keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllAirdropRequest { @@ -84,7 +83,7 @@ func TestAirdropQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.AirdropAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.AirdropAll(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Airdrop), step) require.Subset(t, @@ -97,7 +96,7 @@ func TestAirdropQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.AirdropAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.AirdropAll(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.Airdrop), step) require.Subset(t, @@ -108,7 +107,7 @@ func TestAirdropQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.AirdropAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.AirdropAll(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -117,7 +116,7 @@ func TestAirdropQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.AirdropAll(wctx, nil) + _, err := keeper.AirdropAll(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/tokenomics/keeper/query_genesis_inflation_test.go b/x/tokenomics/keeper/query_genesis_inflation_test.go index eb95e7b1d..b0896ffd4 100644 --- a/x/tokenomics/keeper/query_genesis_inflation_test.go +++ b/x/tokenomics/keeper/query_genesis_inflation_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -15,7 +14,7 @@ import ( func TestGenesisInflationQuery(t *testing.T) { keeper, ctx := keepertest.TokenomicsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + item := createTestGenesisInflation(keeper, ctx) for _, tc := range []struct { desc string @@ -34,7 +33,7 @@ func TestGenesisInflationQuery(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.GenesisInflation(wctx, tc.request) + response, err := keeper.GenesisInflation(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { diff --git a/x/tokenomics/keeper/query_params_test.go b/x/tokenomics/keeper/query_params_test.go index f4c0b71d6..1b19aa24c 100644 --- a/x/tokenomics/keeper/query_params_test.go +++ b/x/tokenomics/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/tokenomics/types" "github.com/stretchr/testify/require" @@ -11,11 +10,11 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx := testkeeper.TokenomicsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() keeper.SetParams(ctx, params) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/tokenomics/keeper/query_time_based_inflation_test.go b/x/tokenomics/keeper/query_time_based_inflation_test.go index b16547359..ad686a458 100644 --- a/x/tokenomics/keeper/query_time_based_inflation_test.go +++ b/x/tokenomics/keeper/query_time_based_inflation_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" @@ -16,7 +15,7 @@ import ( func TestTimeBasedInflationQuerySingle(t *testing.T) { keeper, ctx := keepertest.TokenomicsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + msgs := createNTimeBasedInflation(keeper, ctx, 2) for _, tc := range []struct { desc string @@ -54,7 +53,7 @@ func TestTimeBasedInflationQuerySingle(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.TimeBasedInflation(wctx, tc.request) + response, err := keeper.TimeBasedInflation(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { @@ -70,7 +69,7 @@ func TestTimeBasedInflationQuerySingle(t *testing.T) { func TestTimeBasedInflationQueryPaginated(t *testing.T) { keeper, ctx := keepertest.TokenomicsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + msgs := createNTimeBasedInflation(keeper, ctx, 5) request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllTimeBasedInflationRequest { @@ -86,7 +85,7 @@ func TestTimeBasedInflationQueryPaginated(t *testing.T) { t.Run("ByOffset", func(t *testing.T) { step := 2 for i := 0; i < len(msgs); i += step { - resp, err := keeper.TimeBasedInflationAll(wctx, request(nil, uint64(i), uint64(step), false)) + resp, err := keeper.TimeBasedInflationAll(ctx, request(nil, uint64(i), uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.TimeBasedInflation), step) require.Subset(t, @@ -99,7 +98,7 @@ func TestTimeBasedInflationQueryPaginated(t *testing.T) { step := 2 var next []byte for i := 0; i < len(msgs); i += step { - resp, err := keeper.TimeBasedInflationAll(wctx, request(next, 0, uint64(step), false)) + resp, err := keeper.TimeBasedInflationAll(ctx, request(next, 0, uint64(step), false)) require.NoError(t, err) require.LessOrEqual(t, len(resp.TimeBasedInflation), step) require.Subset(t, @@ -110,7 +109,7 @@ func TestTimeBasedInflationQueryPaginated(t *testing.T) { } }) t.Run("Total", func(t *testing.T) { - resp, err := keeper.TimeBasedInflationAll(wctx, request(nil, 0, 0, true)) + resp, err := keeper.TimeBasedInflationAll(ctx, request(nil, 0, 0, true)) require.NoError(t, err) require.Equal(t, len(msgs), int(resp.Pagination.Total)) require.ElementsMatch(t, @@ -119,7 +118,7 @@ func TestTimeBasedInflationQueryPaginated(t *testing.T) { ) }) t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.TimeBasedInflationAll(wctx, nil) + _, err := keeper.TimeBasedInflationAll(ctx, nil) require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) }) } diff --git a/x/tradeshield/keeper/msg_server_test.go b/x/tradeshield/keeper/msg_server_test.go index fa7f4bc25..e40135e5a 100644 --- a/x/tradeshield/keeper/msg_server_test.go +++ b/x/tradeshield/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( "context" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/tradeshield/keeper" "github.com/elys-network/elys/x/tradeshield/types" @@ -13,7 +12,7 @@ import ( func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { k, ctx, _, _, _ := keepertest.TradeshieldKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) + return keeper.NewMsgServerImpl(*k), ctx } func TestMsgServer(t *testing.T) { diff --git a/x/tradeshield/keeper/query_params_test.go b/x/tradeshield/keeper/query_params_test.go index 87c2c3f9c..7b0e8c49f 100644 --- a/x/tradeshield/keeper/query_params_test.go +++ b/x/tradeshield/keeper/query_params_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" testkeeper "github.com/elys-network/elys/testutil/keeper" "github.com/elys-network/elys/x/tradeshield/types" "github.com/stretchr/testify/require" @@ -11,11 +10,11 @@ import ( func TestParamsQuery(t *testing.T) { keeper, ctx, _, _, _ := testkeeper.TradeshieldKeeper(t) - wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() keeper.SetParams(ctx, ¶ms) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + response, err := keeper.Params(ctx, &types.QueryParamsRequest{}) require.NoError(t, err) require.Equal(t, &types.QueryParamsResponse{Params: params}, response) } diff --git a/x/tradeshield/keeper/query_pending_perpetual_order_for_address_test.go b/x/tradeshield/keeper/query_pending_perpetual_order_for_address_test.go index 838b9eada..6e737c9db 100644 --- a/x/tradeshield/keeper/query_pending_perpetual_order_for_address_test.go +++ b/x/tradeshield/keeper/query_pending_perpetual_order_for_address_test.go @@ -15,7 +15,6 @@ import ( func TestPendingPerpetualOrderForAddress(t *testing.T) { k, ctx, _, _, perpetualKeeper := keepertest.TradeshieldKeeper(t) - wctx := sdk.WrapSDKContext(ctx) ownerAddress := "valid_address" ownerAddressAcc := sdk.AccAddress(ownerAddress) @@ -121,7 +120,7 @@ func TestPendingPerpetualOrderForAddress(t *testing.T) { for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - response, err := k.PendingPerpetualOrderForAddress(wctx, tc.request) + response, err := k.PendingPerpetualOrderForAddress(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { diff --git a/x/tradeshield/keeper/query_pending_spot_order_for_address_test.go b/x/tradeshield/keeper/query_pending_spot_order_for_address_test.go index fa4332387..2a54cb455 100644 --- a/x/tradeshield/keeper/query_pending_spot_order_for_address_test.go +++ b/x/tradeshield/keeper/query_pending_spot_order_for_address_test.go @@ -14,7 +14,6 @@ import ( func TestPendingSpotOrderForAddress(t *testing.T) { k, ctx, _, _, _ := keepertest.TradeshieldKeeper(t) - wctx := sdk.WrapSDKContext(ctx) order := types.SpotOrder{ OrderId: 1, @@ -85,7 +84,7 @@ func TestPendingSpotOrderForAddress(t *testing.T) { for _, tc := range tests { t.Run(tc.desc, func(t *testing.T) { - response, err := k.PendingSpotOrderForAddress(wctx, tc.request) + response, err := k.PendingSpotOrderForAddress(ctx, tc.request) if tc.err != nil { require.ErrorIs(t, err, tc.err) } else { diff --git a/x/transferhook/keeper/swap.go b/x/transferhook/keeper/swap.go index 1b8b90d90..ec6071ae8 100644 --- a/x/transferhook/keeper/swap.go +++ b/x/transferhook/keeper/swap.go @@ -1,9 +1,10 @@ package keeper import ( - "cosmossdk.io/math" "errors" + "cosmossdk.io/math" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" @@ -64,7 +65,7 @@ func (k Keeper) SwapExactAmountIn(ctx sdk.Context, addr sdk.AccAddress, tokenIn } msgServer := ammkeeper.NewMsgServerImpl(k.ammKeeper) - _, err := msgServer.SwapExactAmountIn(sdk.WrapSDKContext(ctx), msg) + _, err := msgServer.SwapExactAmountIn(ctx, msg) if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } diff --git a/x/transferhook/spec/03_keeper.md b/x/transferhook/spec/03_keeper.md index 3fe9cc3f0..76f0dd7b8 100644 --- a/x/transferhook/spec/03_keeper.md +++ b/x/transferhook/spec/03_keeper.md @@ -92,7 +92,7 @@ func (k Keeper) SwapExactAmountIn(ctx sdk.Context, addr sdk.AccAddress, tokenIn } msgServer := ammkeeper.NewMsgServerImpl(k.ammKeeper) - _, err := msgServer.SwapExactAmountIn(sdk.WrapSDKContext(ctx), msg) + _, err := msgServer.SwapExactAmountIn(ctx, msg) if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } diff --git a/x/transferhook/spec/05_functions.md b/x/transferhook/spec/05_functions.md index 3f6ac4365..bda7b3ee2 100644 --- a/x/transferhook/spec/05_functions.md +++ b/x/transferhook/spec/05_functions.md @@ -90,7 +90,7 @@ func (k Keeper) SwapExactAmountIn(ctx sdk.Context, addr sdk.AccAddress, tokenIn msgServer := ammkeeper.NewMsgServerImpl(k.ammKeeper) _, err := msgServer.SwapExactAmountIn -(sdk.WrapSDKContext(ctx), msg) +(ctx, msg) if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) }