From 86f9c1eab08b51fd7d551b578ebb947494c79048 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Tue, 9 May 2023 12:52:40 +0000 Subject: [PATCH] chore: check all errors in tests (#5104) * run golangci-lint and resolve ineffectual assignment to err * go work sync * waypoint in "check all errors in tests" * 50 error checks remaining * 42 errors remaining to check in tests * all tests pass and as many errors as possible have been checked * revert enabling golangci-lint to check tests, as it would always fail afterwards * update changelog * use thelper in golangci-lint without linting every test * Update tests/e2e/containers/containers.go Co-authored-by: Roman * thelper for incentives bench test * Update x/concentrated-liquidity/position_test.go Co-authored-by: Adam Tucker * Update CHANGELOG.md Co-authored-by: Roman * return error in SetIncentiveRecord * revert change to .golanci.yml --------- Co-authored-by: Roman Co-authored-by: Adam Tucker --- .golangci.yml | 5 +- app/upgrades/v12/upgrade_test.go | 2 +- app/upgrades/v13/upgrade_test.go | 3 +- app/upgrades/v15/upgrade_test.go | 4 ++ app/upgrades/v16/concentrated_pool_test.go | 4 +- tests/e2e/e2e_setup_test.go | 11 ++--- tests/e2e/e2e_test.go | 11 +++-- tests/e2e/initialization/init_test.go | 3 ++ tests/ibc-hooks/ibc_middleware_test.go | 46 +++++++++++------ tests/simulator/sim_test.go | 1 + wasmbinding/query_plugin_test.go | 10 ++-- wasmbinding/test/custom_msg_test.go | 2 + wasmbinding/test/custom_query_test.go | 9 ++++ wasmbinding/test/helpers_test.go | 1 + wasmbinding/test/store_run_test.go | 1 + x/concentrated-liquidity/export_test.go | 4 +- x/concentrated-liquidity/fees_test.go | 15 +++--- x/concentrated-liquidity/genesis_test.go | 1 - x/concentrated-liquidity/incentives_test.go | 43 ++++++++++------ x/concentrated-liquidity/keeper_test.go | 8 +-- x/concentrated-liquidity/lp_test.go | 1 - x/concentrated-liquidity/pool_test.go | 2 +- x/concentrated-liquidity/position_test.go | 27 ++++++---- x/concentrated-liquidity/swaps_test.go | 18 ++++--- x/concentrated-liquidity/tick_test.go | 15 ++++-- x/gamm/keeper/grpc_query_test.go | 4 +- x/gamm/keeper/pool_service_test.go | 3 +- x/gamm/keeper/pool_test.go | 3 +- x/gamm/keeper/swap_test.go | 3 +- x/gamm/pool-models/balancer/pool_test.go | 3 +- x/gamm/pool-models/balancer/util_test.go | 4 ++ x/gamm/pool-models/stableswap/amm_test.go | 1 + x/gamm/pool-models/stableswap/pool_test.go | 3 +- x/gamm/pool-models/stableswap/util_test.go | 1 + x/ibc-rate-limit/ibc_middleware_test.go | 45 +++++++++++------ x/incentives/keeper/bench_test.go | 13 ++--- x/incentives/keeper/distribute_test.go | 6 ++- x/incentives/keeper/gauge_test.go | 3 -- x/incentives/keeper/grpc_query_test.go | 25 ++++++++-- x/incentives/keeper/msg_server_test.go | 6 ++- x/lockup/keeper/bench_test.go | 5 +- x/lockup/keeper/lock_test.go | 6 ++- x/lockup/keeper/msg_server_test.go | 3 +- x/lockup/keeper/synthetic_lock_test.go | 3 +- x/lockup/keeper/utils_test.go | 6 ++- x/mint/keeper/hooks_test.go | 8 +-- x/mint/keeper/keeper_test.go | 7 +-- x/pool-incentives/keeper/grpc_query_test.go | 2 +- x/poolmanager/create_pool_test.go | 2 +- x/poolmanager/router_test.go | 4 +- x/protorev/keeper/developer_fees_test.go | 5 +- x/protorev/keeper/epoch_hook_test.go | 6 ++- x/protorev/keeper/grpc_query_test.go | 2 +- x/protorev/keeper/keeper_test.go | 11 +++-- x/protorev/keeper/posthandler_test.go | 55 ++++++++++++++------- x/protorev/keeper/protorev_test.go | 12 +++-- x/protorev/keeper/rebalance_test.go | 9 ++-- x/protorev/keeper/statistics_test.go | 4 +- x/superfluid/keeper/gov/gov_test.go | 1 - x/superfluid/keeper/grpc_query_test.go | 1 - x/superfluid/keeper/msg_server_test.go | 5 ++ x/superfluid/keeper/stake_test.go | 3 +- x/tokenfactory/keeper/admins_test.go | 1 + x/tokenfactory/keeper/createdenom_test.go | 1 - x/tokenfactory/keeper/msg_server_test.go | 41 ++++++++++++--- x/twap/client/query_proto_wrap_test.go | 2 +- x/twap/listeners_test.go | 5 +- x/twap/logic_test.go | 8 +-- x/twap/migrate_test.go | 1 + x/txfees/keeper/feedecorator_test.go | 8 +-- x/txfees/keeper/feetokens_test.go | 3 +- x/txfees/keeper/hooks_test.go | 12 +++-- x/valset-pref/keeper_test.go | 3 +- x/valset-pref/msg_server_test.go | 12 ++--- 74 files changed, 413 insertions(+), 214 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3a89ed2125a..3e367e1e7ae 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,7 +18,6 @@ linters: - goconst - gofmt - goimports - # - gofumpt - goheader - gomodguard - goprintffuncname @@ -30,14 +29,14 @@ linters: - misspell - nakedret - nilnil - - paralleltest - promlinter - staticcheck - stylecheck - tenv - thelper - - testpackage + - tparallel - typecheck + - thelper - unconvert - unused - whitespace diff --git a/app/upgrades/v12/upgrade_test.go b/app/upgrades/v12/upgrade_test.go index cfaee8dc41e..392d64e7277 100644 --- a/app/upgrades/v12/upgrade_test.go +++ b/app/upgrades/v12/upgrade_test.go @@ -53,7 +53,7 @@ func (suite *UpgradeTestSuite) TestPoolMigration() { plan := upgradetypes.Plan{Name: "v12", Height: dummyUpgradeHeight} err := suite.App.UpgradeKeeper.ScheduleUpgrade(suite.Ctx, plan) suite.Require().NoError(err) - plan, exists := suite.App.UpgradeKeeper.GetUpgradePlan(suite.Ctx) + _, exists := suite.App.UpgradeKeeper.GetUpgradePlan(suite.Ctx) suite.Require().True(exists) suite.Ctx = suite.Ctx.WithBlockHeight(dummyUpgradeHeight) diff --git a/app/upgrades/v13/upgrade_test.go b/app/upgrades/v13/upgrade_test.go index d0a0b316759..96c49800f25 100644 --- a/app/upgrades/v13/upgrade_test.go +++ b/app/upgrades/v13/upgrade_test.go @@ -35,7 +35,7 @@ func dummyUpgrade(suite *UpgradeTestSuite) { plan := upgradetypes.Plan{Name: "v13", Height: dummyUpgradeHeight} err := suite.App.UpgradeKeeper.ScheduleUpgrade(suite.Ctx, plan) suite.Require().NoError(err) - plan, exists := suite.App.UpgradeKeeper.GetUpgradePlan(suite.Ctx) + _, exists := suite.App.UpgradeKeeper.GetUpgradePlan(suite.Ctx) suite.Require().True(exists) suite.Ctx = suite.Ctx.WithBlockHeight(dummyUpgradeHeight) @@ -73,7 +73,6 @@ func (suite *UpgradeTestSuite) TestUpgrade() { // Same comment as above: this was the case when the upgrade happened, but we don't have accounts anymore // hasAcc := suite.App.AccountKeeper.HasAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr) // suite.Require().False(hasAcc) - }, func() { dummyUpgrade(suite) }, func() { diff --git a/app/upgrades/v15/upgrade_test.go b/app/upgrades/v15/upgrade_test.go index ea7c326e751..e0ad2334f00 100644 --- a/app/upgrades/v15/upgrade_test.go +++ b/app/upgrades/v15/upgrade_test.go @@ -128,6 +128,7 @@ func (suite *UpgradeTestSuite) TestMigrateBalancerToStablePools() { // shares before migration balancerPool, err := gammKeeper.GetCFMMPool(suite.Ctx, poolID) + suite.Require().NoError(err) balancerLiquidity, err := gammKeeper.GetTotalPoolLiquidity(suite.Ctx, balancerPool.GetId()) suite.Require().NoError(err) @@ -240,13 +241,16 @@ func (suite *UpgradeTestSuite) TestSetRateLimits() { state, err := suite.App.WasmKeeper.QuerySmart(suite.Ctx, addr, []byte(`{"get_quotas": {"channel_id": "any", "denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"}}`)) suite.Require().Greaterf(len(state), 0, "state should not be empty") + suite.Require().NoError(err) state, err = suite.App.WasmKeeper.QuerySmart(suite.Ctx, addr, []byte(`{"get_quotas": {"channel_id": "any", "denom": "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858"}}`)) suite.Require().Greaterf(len(state), 0, "state should not be empty") + suite.Require().NoError(err) // This is the last one. If the others failed the upgrade would've panicked before adding this one state, err = suite.App.WasmKeeper.QuerySmart(suite.Ctx, addr, []byte(`{"get_quotas": {"channel_id": "any", "denom": "ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1"}}`)) suite.Require().Greaterf(len(state), 0, "state should not be empty") + suite.Require().NoError(err) } func (suite *UpgradeTestSuite) validateCons(coinsA, coinsB sdk.Coins) { diff --git a/app/upgrades/v16/concentrated_pool_test.go b/app/upgrades/v16/concentrated_pool_test.go index bdad1a35107..719d8f1d45d 100644 --- a/app/upgrades/v16/concentrated_pool_test.go +++ b/app/upgrades/v16/concentrated_pool_test.go @@ -181,9 +181,9 @@ func (suite *ConcentratedUpgradeTestSuite) TestCreateCanonicalConcentratedLiuqid suite.Require().NoError(err) // Get balancer gauges. - gaugeToRedirect, err := suite.App.PoolIncentivesKeeper.GetPoolGaugeId(suite.Ctx, balancerPool.GetId(), longestLockableDuration) + gaugeToRedirect, _ := suite.App.PoolIncentivesKeeper.GetPoolGaugeId(suite.Ctx, balancerPool.GetId(), longestLockableDuration) - gaugeToNotRedeirect, err := suite.App.PoolIncentivesKeeper.GetPoolGaugeId(suite.Ctx, balancerId2, longestLockableDuration) + gaugeToNotRedeirect, _ := suite.App.PoolIncentivesKeeper.GetPoolGaugeId(suite.Ctx, balancerId2, longestLockableDuration) originalDistrInfo := poolincentivestypes.DistrInfo{ TotalWeight: sdk.NewInt(100), diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 7c4432aa7e9..d38cfcee66e 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -1,7 +1,6 @@ package e2e import ( - "fmt" "os" "strconv" "testing" @@ -40,7 +39,7 @@ type IntegrationTestSuite struct { func TestIntegrationTestSuite(t *testing.T) { isEnabled := os.Getenv(e2eEnabledEnv) if isEnabled != "True" { - t.Skip(fmt.Sprintf("e2e test is disabled. To run, set %s to True", e2eEnabledEnv)) + t.Skipf("e2e test is disabled. To run, set %s to True", e2eEnabledEnv) } suite.Run(t, new(IntegrationTestSuite)) } @@ -64,7 +63,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.skipUpgrade, err = strconv.ParseBool(str) s.Require().NoError(err) if s.skipUpgrade { - s.T().Log(fmt.Sprintf("%s was true, skipping upgrade tests", skipUpgradeEnv)) + s.T().Logf("%s was true, skipping upgrade tests", skipUpgradeEnv) } } upgradeSettings.IsEnabled = !s.skipUpgrade @@ -72,14 +71,14 @@ func (s *IntegrationTestSuite) SetupSuite() { if str := os.Getenv(forkHeightEnv); len(str) > 0 { upgradeSettings.ForkHeight, err = strconv.ParseInt(str, 0, 64) s.Require().NoError(err) - s.T().Log(fmt.Sprintf("fork upgrade is enabled, %s was set to height %d", forkHeightEnv, upgradeSettings.ForkHeight)) + s.T().Logf("fork upgrade is enabled, %s was set to height %d", forkHeightEnv, upgradeSettings.ForkHeight) } if str := os.Getenv(skipIBCEnv); len(str) > 0 { s.skipIBC, err = strconv.ParseBool(str) s.Require().NoError(err) if s.skipIBC { - s.T().Log(fmt.Sprintf("%s was true, skipping IBC tests", skipIBCEnv)) + s.T().Logf("%s was true, skipping IBC tests", skipIBCEnv) } } @@ -102,7 +101,7 @@ func (s *IntegrationTestSuite) SetupSuite() { if str := os.Getenv(upgradeVersionEnv); len(str) > 0 { upgradeSettings.Version = str - s.T().Log(fmt.Sprintf("upgrade version set to %s", upgradeSettings.Version)) + s.T().Logf("upgrade version set to %s", upgradeSettings.Version) } s.configurer, err = configurer.New(s.T(), !s.skipIBC, isDebugLogEnabled, upgradeSettings) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 133c2088e47..16ec4ab3be0 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -206,7 +206,8 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() { } // Change the parameter to enable permisionless pool creation. - chainA.SubmitParamChangeProposal("concentratedliquidity", string(cltypes.KeyIsPermisionlessPoolCreationEnabled), []byte("true")) + err = chainA.SubmitParamChangeProposal("concentratedliquidity", string(cltypes.KeyIsPermisionlessPoolCreationEnabled), []byte("true")) + s.Require().NoError(err) // Confirm that the parameter has been changed. isPermisionlessCreationEnabledStr = chainANode.QueryParams(cltypes.ModuleName, string(cltypes.KeyIsPermisionlessPoolCreationEnabled)) @@ -599,7 +600,7 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() { addr1BalancesAfter.AmountOf("uion"), ) - // Assert position that was active thoughout the whole swap: + // Assert position that was active throughout the whole swap: // Track balance of address3 addr3BalancesBefore = s.addrBalance(chainANode, address3) @@ -770,7 +771,7 @@ func (s *IntegrationTestSuite) TestStableSwapPostUpgrade() { } // TestGeometricTwapMigration tests that the geometric twap record -// migration runs succesfully. It does so by attempting to execute +// migration runs successfully. It does so by attempting to execute // the swap on the pool created pre-upgrade. When a pool is created // pre-upgrade, twap records are initialized for a pool. By runnning // a swap post-upgrade, we confirm that the geometric twap was initialized @@ -987,7 +988,6 @@ func (s *IntegrationTestSuite) TestIBCTokenTransferRateLimiting() { val := node.QueryParams(ibcratelimittypes.ModuleName, string(ibcratelimittypes.KeyContractAddress)) return strings.Contains(val, param) }, time.Second*30, time.Millisecond*500) - } } @@ -1100,6 +1100,7 @@ func (s *IntegrationTestSuite) TestPacketForwarding() { // sender wasm addr senderBech32, err := ibchookskeeper.DeriveIntermediateSender("channel-0", validatorAddr, "osmo") + s.Require().NoError(err) s.Require().Eventually(func() bool { response, err := nodeA.QueryWasmSmartObject(contractAddr, fmt.Sprintf(`{"get_count": {"addr": "%s"}}`, senderBech32)) if err != nil { @@ -1154,7 +1155,7 @@ func (s *IntegrationTestSuite) TestAddToExistingLock() { // TestArithmeticTWAP tests TWAP by creating a pool, performing a swap. // These two operations should create TWAP records. // Then, we wait until the epoch for the records to be pruned. -// The records are guranteed to be pruned at the next epoch +// The records are guaranteed to be pruned at the next epoch // because twap keep time = epoch time / 4 and we use a timer // to wait for at least the twap keep time. func (s *IntegrationTestSuite) TestArithmeticTWAP() { diff --git a/tests/e2e/initialization/init_test.go b/tests/e2e/initialization/init_test.go index ead665eb0da..d59b85947b1 100644 --- a/tests/e2e/initialization/init_test.go +++ b/tests/e2e/initialization/init_test.go @@ -47,6 +47,7 @@ func TestChainInit(t *testing.T) { } dataDir, err = os.MkdirTemp("", "osmosis-e2e-testnet-test") ) + require.NoError(t, err) chain, err := initialization.InitChain(id, dataDir, nodeConfigs, time.Second*3, time.Second, forkHeight) require.NoError(t, err) @@ -104,6 +105,7 @@ func TestSingleNodeInit(t *testing.T) { } dataDir, err = os.MkdirTemp("", "osmosis-e2e-testnet-test") ) + require.NoError(t, err) // Setup existingChain, err := initialization.InitChain(id, dataDir, existingChainNodeConfigs, time.Second*3, time.Second, forkHeight) @@ -116,6 +118,7 @@ func TestSingleNodeInit(t *testing.T) { } func validateNode(t *testing.T, chainId string, dataDir string, expectedConfig *initialization.NodeConfig, actualNode *initialization.Node) { + t.Helper() require.Equal(t, fmt.Sprintf("%s-node-%s", chainId, expectedConfig.Name), actualNode.Name) require.Equal(t, expectedConfig.IsValidator, actualNode.IsValidator) diff --git a/tests/ibc-hooks/ibc_middleware_test.go b/tests/ibc-hooks/ibc_middleware_test.go index c40c24d639c..76315f2aae7 100644 --- a/tests/ibc-hooks/ibc_middleware_test.go +++ b/tests/ibc-hooks/ibc_middleware_test.go @@ -319,6 +319,7 @@ func (suite *HooksTestSuite) receivePacketWithSequence(receiver, memo string, pr // recv in chain a res, err := suite.pathAB.EndpointA.RecvPacketWithResult(packet) + suite.Require().NoError(err) // get the ack from the chain a's response ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) @@ -593,7 +594,8 @@ func (suite *HooksTestSuite) TestAcks() { callbackMemo := fmt.Sprintf(`{"ibc_callback":"%s"}`, addr) // Send IBC transfer with the memo with crosschain-swap instructions transferMsg := NewMsgTransfer(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)), suite.chainA.SenderAccount.GetAddress().String(), addr.String(), "channel-0", callbackMemo) - suite.FullSend(transferMsg, AtoB) + _, _, _, err := suite.FullSend(transferMsg, AtoB) + suite.Require().NoError(err) // The test contract will increment the counter for itself every time it receives an ack state := suite.chainA.QueryContract( @@ -601,7 +603,8 @@ func (suite *HooksTestSuite) TestAcks() { []byte(fmt.Sprintf(`{"get_count": {"addr": "%s"}}`, addr))) suite.Require().Equal(`{"count":1}`, state) - suite.FullSend(transferMsg, AtoB) + _, _, _, err = suite.FullSend(transferMsg, AtoB) + suite.Require().NoError(err) state = suite.chainA.QueryContract( &suite.Suite, addr, []byte(fmt.Sprintf(`{"get_count": {"addr": "%s"}}`, addr))) @@ -792,17 +795,20 @@ func (suite *HooksTestSuite) SetupCrosschainRegistry(chainName Chain) (sdk.AccAd // Send some token0 tokens from C to B transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "channel-0", "") - suite.FullSend(transferMsg, CtoB) + _, _, _, err = suite.FullSend(transferMsg, CtoB) + suite.Require().NoError(err) // Send some token0 tokens from B to A transferMsg = NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "channel-0", "") - suite.FullSend(transferMsg, BtoA) + _, _, _, err = suite.FullSend(transferMsg, BtoA) + suite.Require().NoError(err) // Send some token0 tokens from C to B to A denomTrace0CB := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", suite.pathBC.EndpointA.ChannelID, "token0")) token0CB := denomTrace0CB.IBCDenom() transferMsg = NewMsgTransfer(sdk.NewCoin(token0CB, sdk.NewInt(2000)), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "channel-0", "") - suite.FullSend(transferMsg, BtoA) + _, _, _, err = suite.FullSend(transferMsg, BtoA) + suite.Require().NoError(err) // Denom traces CBAPath := fmt.Sprintf("transfer/%s/transfer/%s", suite.pathAB.EndpointA.ChannelID, suite.pathBC.EndpointA.ChannelID) @@ -1060,7 +1066,8 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCTest() { _, crosschainAddr := suite.SetupCrosschainSwaps(ChainA) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") - suite.FullSend(transferMsg, AtoB) + _, _, _, err := suite.FullSend(transferMsg, AtoB) + suite.Require().NoError(err) // Calculate the names of the tokens when swapped via IBC denomTrace0 := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", "token0")) @@ -1110,7 +1117,8 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCBadAck() { _, crosschainAddr := suite.SetupCrosschainSwaps(ChainA) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") - suite.FullSend(transferMsg, AtoB) + _, _, _, err := suite.FullSend(transferMsg, AtoB) + suite.Require().NoError(err) // Calculate the names of the tokens when swapped via IBC denomTrace0 := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", "token0")) @@ -1205,7 +1213,8 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCBadSwap() { _, crosschainAddr := suite.SetupCrosschainSwaps(ChainA) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") - suite.FullSend(transferMsg, AtoB) + _, _, _, err := suite.FullSend(transferMsg, AtoB) + suite.Require().NoError(err) // Calculate the names of the tokens when swapped via IBC denomTrace0 := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", "token0")) @@ -1247,7 +1256,8 @@ func (suite *HooksTestSuite) TestBadCrosschainSwapsNextMemoMessages() { _, crosschainAddr := suite.SetupCrosschainSwaps(ChainA) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(20000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") - suite.FullSend(transferMsg, AtoB) + _, _, _, err := suite.FullSend(transferMsg, AtoB) + suite.Require().NoError(err) // Calculate the names of the tokens when swapped via IBC denomTrace0 := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", "token0")) @@ -1396,9 +1406,11 @@ func (suite *HooksTestSuite) TestCrosschainForwardWithMemo() { swaprouterAddrB, crosschainAddrB := suite.SetupCrosschainSwaps(ChainB) // Send some token0 and token1 tokens to B so that there are ibc token0 to send to A and crosschain-swap, and token1 to create the pool transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(500000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") - suite.FullSend(transferMsg, AtoB) + _, _, _, err := suite.FullSend(transferMsg, AtoB) + suite.Require().NoError(err) transferMsg1 := NewMsgTransfer(sdk.NewCoin("token1", sdk.NewInt(500000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") - suite.FullSend(transferMsg1, AtoB) + _, _, _, err = suite.FullSend(transferMsg1, AtoB) + suite.Require().NoError(err) denom := suite.GetIBCDenom(ChainA, ChainB, "token1") poolId := suite.CreateIBCNativePoolOnChain(ChainB, denom) suite.SetupIBCRouteOnChain(swaprouterAddrB, suite.chainB.SenderAccount.GetAddress(), poolId, ChainB, denom) @@ -1472,7 +1484,8 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCMultiHop() { suite.pathAC.EndpointA.ChannelID, "", ) - suite.FullSend(transferMsg, AtoC) + _, _, _, err := suite.FullSend(transferMsg, AtoC) + suite.Require().NoError(err) token0AC := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", suite.pathAC.EndpointB.ChannelID, "token0")).IBCDenom() transferMsg = NewMsgTransfer( @@ -1482,7 +1495,8 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCMultiHop() { suite.pathBC.EndpointB.ChannelID, "", ) - suite.FullSend(transferMsg, CtoB) + _, _, _, err = suite.FullSend(transferMsg, CtoB) + suite.Require().NoError(err) // Calculate the names of the tokens when sent via IBC ACBPath := fmt.Sprintf("transfer/%s/transfer/%s", suite.pathAC.EndpointB.ChannelID, suite.pathBC.EndpointA.ChannelID) @@ -1564,7 +1578,6 @@ func (suite *HooksTestSuite) SimpleNativeTransfer(token string, amount sdk.Int, prevPrefix = strings.TrimLeft(prevPrefix, "/") denom = transfertypes.DenomTrace{Path: prevPrefix, BaseDenom: token}.IBCDenom() prev = toChain - } return denom } @@ -1795,7 +1808,8 @@ func (suite *HooksTestSuite) ExecuteOutpostSwap(initializer, receiverAddr sdk.Ac // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") - suite.FullSend(transferMsg, AtoB) + _, _, _, err := suite.FullSend(transferMsg, AtoB) + suite.Require().NoError(err) // Calculate the names of the tokens when swapped via IBC denomTrace0 := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", "token0")) @@ -1817,7 +1831,7 @@ func (suite *HooksTestSuite) ExecuteOutpostSwap(initializer, receiverAddr sdk.Ac // Call the outpost contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(osmosisAppB.WasmKeeper) ctxB := suite.chainB.GetContext() - _, err := contractKeeper.Execute(ctxB, outpostAddr, initializer, []byte(swapMsg), sdk.NewCoins(sdk.NewCoin(token0IBC, sdk.NewInt(1000)))) + _, err = contractKeeper.Execute(ctxB, outpostAddr, initializer, []byte(swapMsg), sdk.NewCoins(sdk.NewCoin(token0IBC, sdk.NewInt(1000)))) suite.Require().NoError(err) suite.chainB.NextBlock() err = suite.pathAB.EndpointA.UpdateClient() diff --git a/tests/simulator/sim_test.go b/tests/simulator/sim_test.go index f768a406750..6ee3c2d458c 100644 --- a/tests/simulator/sim_test.go +++ b/tests/simulator/sim_test.go @@ -47,6 +47,7 @@ func TestFullAppSimulation(t *testing.T) { } func fullAppSimulation(tb testing.TB, is_testing bool) { + tb.Helper() // TODO: Get SDK simulator fixed to have min fees possible txfeetypes.ConsensusMinFee = sdk.ZeroDec() config, db, logger, cleanup, err := osmosim.SetupSimulation("goleveldb-app-sim", "Simulation") diff --git a/wasmbinding/query_plugin_test.go b/wasmbinding/query_plugin_test.go index ef92ed21918..cda69b4cec7 100644 --- a/wasmbinding/query_plugin_test.go +++ b/wasmbinding/query_plugin_test.go @@ -115,8 +115,9 @@ func (suite *StargateTestSuite) TestStargateQuerier() { accAddr, err := sdk.AccAddressFromBech32("osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44") suite.Require().NoError(err) - // fund account to recieve non-empty response - simapp.FundAccount(suite.app.BankKeeper, suite.ctx, accAddr, sdk.Coins{sdk.NewCoin("stake", sdk.NewInt(10))}) + // fund account to receive non-empty response + err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, accAddr, sdk.Coins{sdk.NewCoin("stake", sdk.NewInt(10))}) + suite.Require().NoError(err) wasmbinding.SetWhitelistedQuery("/cosmos.bank.v1beta1.Query/AllBalances", &banktypes.QueryAllBalancesResponse{}) }, @@ -137,8 +138,9 @@ func (suite *StargateTestSuite) TestStargateQuerier() { accAddr, err := sdk.AccAddressFromBech32("osmo1t7egva48prqmzl59x5ngv4zx0dtrwewc9m7z44") suite.Require().NoError(err) - // fund account to recieve non-empty response - simapp.FundAccount(suite.app.BankKeeper, suite.ctx, accAddr, sdk.Coins{sdk.NewCoin("stake", sdk.NewInt(10))}) + // fund account to receive non-empty response + err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, accAddr, sdk.Coins{sdk.NewCoin("stake", sdk.NewInt(10))}) + suite.Require().NoError(err) wasmbinding.SetWhitelistedQuery("/cosmos.bank.v1beta1.Query/AllBalances", &banktypes.QueryAllBalancesResponse{}) }, diff --git a/wasmbinding/test/custom_msg_test.go b/wasmbinding/test/custom_msg_test.go index e3a50c182ac..0ee914b02b0 100644 --- a/wasmbinding/test/custom_msg_test.go +++ b/wasmbinding/test/custom_msg_test.go @@ -254,6 +254,8 @@ type ReflectSubMsgs struct { } func executeCustom(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, contract sdk.AccAddress, sender sdk.AccAddress, msg bindings.OsmosisMsg, funds sdk.Coin) error { + t.Helper() + customBz, err := json.Marshal(msg) require.NoError(t, err) reflectMsg := ReflectExec{ diff --git a/wasmbinding/test/custom_query_test.go b/wasmbinding/test/custom_query_test.go index 16e0f6a3951..c3c92d0b5c3 100644 --- a/wasmbinding/test/custom_query_test.go +++ b/wasmbinding/test/custom_query_test.go @@ -20,6 +20,8 @@ import ( ) func SetupCustomApp(t *testing.T, addr sdk.AccAddress) (*app.OsmosisApp, sdk.Context) { + t.Helper() + osmosis, ctx := CreateTestInput() wasmKeeper := osmosis.WasmKeeper @@ -65,6 +67,8 @@ type ChainResponse struct { } func queryCustom(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, contract sdk.AccAddress, request bindings.OsmosisQuery, response interface{}) { + t.Helper() + msgBz, err := json.Marshal(request) require.NoError(t, err) @@ -86,6 +90,8 @@ func queryCustom(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, contrac } func storeReflectCode(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, addr sdk.AccAddress) { + t.Helper() + govKeeper := osmosis.GovKeeper wasmCode, err := os.ReadFile("../testdata/osmo_reflect.wasm") require.NoError(t, err) @@ -108,6 +114,8 @@ func storeReflectCode(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, ad } func instantiateReflectContract(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, funder sdk.AccAddress) sdk.AccAddress { + t.Helper() + initMsgBz := []byte("{}") contractKeeper := keeper.NewDefaultPermissionKeeper(osmosis.WasmKeeper) codeID := uint64(1) @@ -118,6 +126,7 @@ func instantiateReflectContract(t *testing.T, ctx sdk.Context, osmosis *app.Osmo } func fundAccount(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, addr sdk.AccAddress, coins sdk.Coins) { + t.Helper() err := simapp.FundAccount( osmosis.BankKeeper, ctx, diff --git a/wasmbinding/test/helpers_test.go b/wasmbinding/test/helpers_test.go index 0150c6293da..957cfed651a 100644 --- a/wasmbinding/test/helpers_test.go +++ b/wasmbinding/test/helpers_test.go @@ -23,6 +23,7 @@ func CreateTestInput() (*app.OsmosisApp, sdk.Context) { } func FundAccount(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, acct sdk.AccAddress) { + t.Helper() err := simapp.FundAccount(osmosis.BankKeeper, ctx, acct, sdk.NewCoins( sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), )) diff --git a/wasmbinding/test/store_run_test.go b/wasmbinding/test/store_run_test.go index 94f1f88581d..64f7f70b160 100644 --- a/wasmbinding/test/store_run_test.go +++ b/wasmbinding/test/store_run_test.go @@ -35,6 +35,7 @@ func TestNoStorageWithoutProposal(t *testing.T) { } func storeCodeViaProposal(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, addr sdk.AccAddress) { + t.Helper() govKeeper := osmosis.GovKeeper wasmCode, err := os.ReadFile("../testdata/hackatom.wasm") require.NoError(t, err) diff --git a/x/concentrated-liquidity/export_test.go b/x/concentrated-liquidity/export_test.go index f0f2e655cb0..c172c905fb1 100644 --- a/x/concentrated-liquidity/export_test.go +++ b/x/concentrated-liquidity/export_test.go @@ -211,8 +211,8 @@ func (k Keeper) UpdateUptimeAccumulatorsToNow(ctx sdk.Context, poolId uint64) er return k.updateUptimeAccumulatorsToNow(ctx, poolId) } -func (k Keeper) SetIncentiveRecord(ctx sdk.Context, incentiveRecord types.IncentiveRecord) { - k.setIncentiveRecord(ctx, incentiveRecord) +func (k Keeper) SetIncentiveRecord(ctx sdk.Context, incentiveRecord types.IncentiveRecord) error { + return k.setIncentiveRecord(ctx, incentiveRecord) } func (k Keeper) SetMultipleIncentiveRecords(ctx sdk.Context, incentiveRecords []types.IncentiveRecord) error { diff --git a/x/concentrated-liquidity/fees_test.go b/x/concentrated-liquidity/fees_test.go index af930889d5a..b2f66f2f9aa 100644 --- a/x/concentrated-liquidity/fees_test.go +++ b/x/concentrated-liquidity/fees_test.go @@ -87,7 +87,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateFeeAccumulatorPosition() { // Setup is done once so that we test // the relationship between test cases. // For example, that positions with non-zero liquidity - // cannot be overriden. + // cannot be overridden. s.SetupTest() s.PrepareConcentratedPool() @@ -413,8 +413,9 @@ func (s *KeeperTestSuite) TestGetFeeGrowthOutside() { s.initializeTick(s.Ctx, currentTick, tc.lowerTick, defaultInitialLiquidity, tc.lowerTickFeeGrowthOutside, emptyUptimeTrackers, false) s.initializeTick(s.Ctx, currentTick, tc.upperTick, defaultInitialLiquidity, tc.upperTickFeeGrowthOutside, emptyUptimeTrackers, true) pool.SetCurrentTick(sdk.NewInt(tc.currentTick)) - s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) - err := s.App.ConcentratedLiquidityKeeper.ChargeFee(s.Ctx, validPoolId, tc.globalFeeGrowth) + err := s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) + s.Require().NoError(err) + err = s.App.ConcentratedLiquidityKeeper.ChargeFee(s.Ctx, validPoolId, tc.globalFeeGrowth) s.Require().NoError(err) } @@ -924,7 +925,8 @@ func (s *KeeperTestSuite) TestQueryAndCollectFees() { s.initializeTick(ctx, tc.currentTick, tc.upperTick, tc.initialLiquidity, tc.upperTickFeeGrowthOutside, emptyUptimeTrackers, true) validPool.SetCurrentTick(sdk.NewInt(tc.currentTick)) - clKeeper.SetPool(ctx, validPool) + err = clKeeper.SetPool(ctx, validPool) + s.Require().NoError(err) err = clKeeper.ChargeFee(ctx, validPoolId, tc.globalFeeGrowth[0]) s.Require().NoError(err) @@ -1186,6 +1188,7 @@ func (s *KeeperTestSuite) TestPrepareClaimableFees() { s.initializeTick(ctx, tc.currentTick, tc.lowerTick, tc.initialLiquidity, tc.lowerTickFeeGrowthOutside, emptyUptimeTrackers, false) s.initializeTick(ctx, tc.currentTick, tc.upperTick, tc.initialLiquidity, tc.upperTickFeeGrowthOutside, emptyUptimeTrackers, true) validPool.SetCurrentTick(sdk.NewInt(tc.currentTick)) + _ = clKeeper.SetPool(ctx, validPool) err = clKeeper.ChargeFee(ctx, validPoolId, tc.globalFeeGrowth[0]) @@ -1194,7 +1197,7 @@ func (s *KeeperTestSuite) TestPrepareClaimableFees() { positionKey := types.KeyFeePositionAccumulator(DefaultPositionId) // Note the position accumulator before calling prepare - accum, err := s.App.ConcentratedLiquidityKeeper.GetFeeAccumulator(ctx, validPoolId) + _, err = s.App.ConcentratedLiquidityKeeper.GetFeeAccumulator(ctx, validPoolId) s.Require().NoError(err) // System under test @@ -1208,7 +1211,7 @@ func (s *KeeperTestSuite) TestPrepareClaimableFees() { } s.Require().NoError(err) - accum, err = s.App.ConcentratedLiquidityKeeper.GetFeeAccumulator(ctx, validPoolId) + accum, err := s.App.ConcentratedLiquidityKeeper.GetFeeAccumulator(ctx, validPoolId) s.Require().NoError(err) postPreparePosition, err := accum.GetPosition(positionKey) diff --git a/x/concentrated-liquidity/genesis_test.go b/x/concentrated-liquidity/genesis_test.go index 33a8ee56566..79cdf5b5cbe 100644 --- a/x/concentrated-liquidity/genesis_test.go +++ b/x/concentrated-liquidity/genesis_test.go @@ -741,7 +741,6 @@ func (s *KeeperTestSuite) TestExportGenesis() { s.Require().Equal(incentiveRecord.IncentiveRecordBody.RemainingAmount.String(), expectedPoolData.IncentiveRecords[i].IncentiveRecordBody.RemainingAmount.String()) s.Require().True(incentiveRecord.IncentiveRecordBody.StartTime.Equal(expectedPoolData.IncentiveRecords[i].IncentiveRecordBody.StartTime)) } - } // Validate positions. diff --git a/x/concentrated-liquidity/incentives_test.go b/x/concentrated-liquidity/incentives_test.go index d5544e03280..f71acb1a0b0 100644 --- a/x/concentrated-liquidity/incentives_test.go +++ b/x/concentrated-liquidity/incentives_test.go @@ -944,6 +944,7 @@ func (s *KeeperTestSuite) TestUpdateUptimeAccumulatorsToNow() { // If a canonical balancer pool exists, we add its respective shares to the qualifying amount as well. clPool, err = clKeeper.GetPoolById(s.Ctx, clPool.GetId()) + s.Require().NoError(err) if tc.canonicalBalancerPoolAssets != nil { qualifyingBalancerLiquidityPreDiscount := math.GetLiquidityFromAmounts(clPool.GetCurrentSqrtPrice(), types.MinSqrtPrice, types.MaxSqrtPrice, tc.canonicalBalancerPoolAssets[0].Token.Amount, tc.canonicalBalancerPoolAssets[1].Token.Amount) qualifyingBalancerLiquidity = (sdk.OneDec().Sub(types.DefaultBalancerSharesDiscount)).Mul(qualifyingBalancerLiquidityPreDiscount) @@ -1067,7 +1068,8 @@ func (s *KeeperTestSuite) TestIncentiveRecordsSetAndGet() { s.Require().Equal(emptyIncentiveRecords, poolTwoRecords) // Ensure setting and getting a single record works with single Get and GetAll - clKeeper.SetIncentiveRecord(s.Ctx, incentiveRecordOne) + err = clKeeper.SetIncentiveRecord(s.Ctx, incentiveRecordOne) + s.Require().NoError(err) poolOneRecord, err := clKeeper.GetIncentiveRecord(s.Ctx, clPoolOne.GetId(), incentiveRecordOne.IncentiveDenom, incentiveRecordOne.MinUptime, sdk.MustAccAddressFromBech32(incentiveRecordOne.IncentiveCreatorAddr)) s.Require().NoError(err) s.Require().Equal(incentiveRecordOne, poolOneRecord) @@ -1085,7 +1087,8 @@ func (s *KeeperTestSuite) TestIncentiveRecordsSetAndGet() { s.Require().Equal(emptyIncentiveRecords, allRecordsPoolTwo) // Ensure directly setting additional records don't overwrite previous ones - clKeeper.SetIncentiveRecord(s.Ctx, incentiveRecordTwo) + err = clKeeper.SetIncentiveRecord(s.Ctx, incentiveRecordTwo) + s.Require().NoError(err) poolOneRecord, err = clKeeper.GetIncentiveRecord(s.Ctx, clPoolOne.GetId(), incentiveRecordTwo.IncentiveDenom, incentiveRecordTwo.MinUptime, sdk.MustAccAddressFromBech32(incentiveRecordTwo.IncentiveCreatorAddr)) s.Require().NoError(err) s.Require().Equal(incentiveRecordTwo, poolOneRecord) @@ -1462,13 +1465,15 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthInsideRange() { currentTick := pool.GetCurrentTick().Int64() // Update global uptime accums - addToUptimeAccums(s.Ctx, pool.GetId(), s.App.ConcentratedLiquidityKeeper, tc.globalUptimeGrowth) + err := addToUptimeAccums(s.Ctx, pool.GetId(), s.App.ConcentratedLiquidityKeeper, tc.globalUptimeGrowth) + s.Require().NoError(err) // Update tick-level uptime trackers s.initializeTick(s.Ctx, currentTick, tc.lowerTick, defaultInitialLiquidity, cl.EmptyCoins, wrapUptimeTrackers(tc.lowerTickUptimeGrowthOutside), true) s.initializeTick(s.Ctx, currentTick, tc.upperTick, defaultInitialLiquidity, cl.EmptyCoins, wrapUptimeTrackers(tc.upperTickUptimeGrowthOutside), false) pool.SetCurrentTick(sdk.NewInt(tc.currentTick)) - s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) + err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) + s.Require().NoError(err) } // system under test @@ -1785,13 +1790,15 @@ func (s *KeeperTestSuite) TestGetUptimeGrowthOutsideRange() { currentTick := pool.GetCurrentTick().Int64() // Update global uptime accums - addToUptimeAccums(s.Ctx, pool.GetId(), s.App.ConcentratedLiquidityKeeper, tc.globalUptimeGrowth) + err := addToUptimeAccums(s.Ctx, pool.GetId(), s.App.ConcentratedLiquidityKeeper, tc.globalUptimeGrowth) + s.Require().NoError(err) // Update tick-level uptime trackers s.initializeTick(s.Ctx, currentTick, tc.lowerTick, defaultInitialLiquidity, cl.EmptyCoins, wrapUptimeTrackers(tc.lowerTickUptimeGrowthOutside), true) s.initializeTick(s.Ctx, currentTick, tc.upperTick, defaultInitialLiquidity, cl.EmptyCoins, wrapUptimeTrackers(tc.upperTickUptimeGrowthOutside), false) pool.SetCurrentTick(sdk.NewInt(tc.currentTick)) - s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) + err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) + s.Require().NoError(err) } // system under test @@ -1958,10 +1965,12 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptime() { s.initializeTick(s.Ctx, test.currentTickIndex.Int64(), test.lowerTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.lowerTick.uptimeTrackers, true) s.initializeTick(s.Ctx, test.currentTickIndex.Int64(), test.upperTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.upperTick.uptimeTrackers, false) clPool.SetCurrentTick(test.currentTickIndex) - s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, clPool) + err := s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, clPool) + s.Require().NoError(err) // Initialize global uptime accums - addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, test.globalUptimeAccumValues) + err = addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, test.globalUptimeAccumValues) + s.Require().NoError(err) // If applicable, set up existing position and update ticks & global accums if test.existingPosition { @@ -1973,14 +1982,16 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptime() { s.initializeTick(s.Ctx, test.currentTickIndex.Int64(), test.newLowerTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.newLowerTick.uptimeTrackers, true) s.initializeTick(s.Ctx, test.currentTickIndex.Int64(), test.newUpperTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.newUpperTick.uptimeTrackers, false) clPool.SetCurrentTick(test.currentTickIndex) - s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, clPool) + err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, clPool) + s.Require().NoError(err) - addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, test.addToGlobalAccums) + err = addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, test.addToGlobalAccums) + s.Require().NoError(err) } // --- System under test --- - err := s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionUptime(s.Ctx, clPool.GetId(), test.positionLiquidity, s.TestAccs[0], test.lowerTick.tickIndex, test.upperTick.tickIndex, test.positionLiquidity, DefaultJoinTime, DefaultPositionId) + err = s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionUptime(s.Ctx, clPool.GetId(), test.positionLiquidity, s.TestAccs[0], test.lowerTick.tickIndex, test.upperTick.tickIndex, test.positionLiquidity, DefaultJoinTime, DefaultPositionId) // --- Error catching --- @@ -2863,7 +2874,8 @@ func (s *KeeperTestSuite) TestQueryAndCollectIncentives() { } validPool.SetCurrentTick(sdk.NewInt(tc.currentTick)) - clKeeper.SetPool(ctx, validPool) + err := clKeeper.SetPool(ctx, validPool) + s.Require().NoError(err) // Checkpoint starting balance to compare against later poolBalanceBeforeCollect := s.App.BankKeeper.GetAllBalances(ctx, validPool.GetAddress()) @@ -3212,6 +3224,7 @@ func (s *KeeperTestSuite) TestCreateIncentive() { // Returned incentive record should equal both to what's in state and what we expect recordInState, err := clKeeper.GetIncentiveRecord(s.Ctx, tc.poolId, tc.recordToSet.IncentiveDenom, tc.recordToSet.MinUptime, tc.sender) + s.Require().NoError(err) s.Require().Equal(tc.recordToSet, recordInState) s.Require().Equal(tc.recordToSet, incentiveRecord) @@ -3554,7 +3567,8 @@ func (s *KeeperTestSuite) TestFunctional_ClaimIncentices_LiquidityChange_Varying }, MinUptime: time.Nanosecond, } - s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, []types.IncentiveRecord{testIncentiveRecord}) + err := s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, []types.IncentiveRecord{testIncentiveRecord}) + s.Require().NoError(err) // Set up position positionIdOne, _, _, _, _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, defaultPoolId, defaultAddress, DefaultCoin0.Amount, DefaultCoin1.Amount, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) @@ -4133,7 +4147,8 @@ func (s *KeeperTestSuite) TestClaimAndResetFullRangeBalancerPool() { s.FundAcc(clPool.GetIncentivesAddress(), normalizedEmissions) } } - addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, tc.uptimeGrowth) + err := addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, tc.uptimeGrowth) + s.Require().NoError(err) // --- System under test --- diff --git a/x/concentrated-liquidity/keeper_test.go b/x/concentrated-liquidity/keeper_test.go index 7743fb7524f..bb08b079bd1 100644 --- a/x/concentrated-liquidity/keeper_test.go +++ b/x/concentrated-liquidity/keeper_test.go @@ -84,7 +84,7 @@ func (s *KeeperTestSuite) SetupPosition(poolId uint64, owner sdk.AccAddress, coi // Sets up the following positions: // 1. Default position // 2. Full range position -// 3. Postion with consecutive price range from the default position +// 3. Position with consecutive price range from the default position // 4. Position with overlapping price range from the default position func (s *KeeperTestSuite) SetupDefaultPositions(poolId uint64) { // ----------- set up positions ---------- @@ -217,7 +217,8 @@ func (s *KeeperTestSuite) addUptimeGrowthInsideRange(ctx sdk.Context, poolId uin // In all cases, global uptime accums need to be updated. If lowerTick <= currentTick < upperTick, // nothing more needs to be done. - addToUptimeAccums(ctx, poolId, s.App.ConcentratedLiquidityKeeper, uptimeGrowthToAdd) + err := addToUptimeAccums(ctx, poolId, s.App.ConcentratedLiquidityKeeper, uptimeGrowthToAdd) + s.Require().NoError(err) } // addUptimeGrowthOutsideRange adds uptime growth outside the range defined by [lowerTick, upperTick). @@ -271,7 +272,8 @@ func (s *KeeperTestSuite) addUptimeGrowthOutsideRange(ctx sdk.Context, poolId ui // In all cases, global uptime accums need to be updated. If currentTick < lowerTick, // nothing more needs to be done. - addToUptimeAccums(ctx, poolId, s.App.ConcentratedLiquidityKeeper, uptimeGrowthToAdd) + err := addToUptimeAccums(ctx, poolId, s.App.ConcentratedLiquidityKeeper, uptimeGrowthToAdd) + s.Require().NoError(err) } // validatePositionFeeAccUpdate validates that the position's accumulator with given parameters diff --git a/x/concentrated-liquidity/lp_test.go b/x/concentrated-liquidity/lp_test.go index b58a8af799e..473c05a8ea4 100644 --- a/x/concentrated-liquidity/lp_test.go +++ b/x/concentrated-liquidity/lp_test.go @@ -1333,7 +1333,6 @@ func (s *KeeperTestSuite) TestUpdatePosition() { s.Require().Equal(sdk.Int{}, actualAmount0) s.Require().Equal(sdk.Int{}, actualAmount1) } else { - s.Require().NoError(err) var ( diff --git a/x/concentrated-liquidity/pool_test.go b/x/concentrated-liquidity/pool_test.go index a1818b619f7..bd778312114 100644 --- a/x/concentrated-liquidity/pool_test.go +++ b/x/concentrated-liquidity/pool_test.go @@ -20,6 +20,7 @@ func (s *KeeperTestSuite) TestInitializePool() { // Create a concentrated liquidity pool with unauthorized tick spacing invalidTickSpacing := uint64(25) invalidTickSpacingConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(2, ETH, USDC, invalidTickSpacing, DefaultZeroSwapFee) + s.Require().NoError(err) // Create a concentrated liquidity pool with unauthorized swap fee invalidSwapFee := sdk.MustNewDecFromStr("0.1") @@ -107,7 +108,6 @@ func (s *KeeperTestSuite) TestInitializePool() { } s.validateListenerCallCount(1, 0, 0, 0) - } else { // Ensure specified error is returned s.Require().Error(err) diff --git a/x/concentrated-liquidity/position_test.go b/x/concentrated-liquidity/position_test.go index 996ac77ec43..ef5c89fcd3e 100644 --- a/x/concentrated-liquidity/position_test.go +++ b/x/concentrated-liquidity/position_test.go @@ -122,7 +122,8 @@ func (s *KeeperTestSuite) TestInitOrUpdatePosition() { } // Set incentives for pool to ensure accumulators work correctly - s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, test.incentiveRecords) + err = s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, test.incentiveRecords) + s.Require().NoError(err) // If positionExists set, initialize the specified position with defaultLiquidityAmt preexistingLiquidity := sdk.ZeroDec() @@ -213,7 +214,6 @@ func (s *KeeperTestSuite) TestInitOrUpdatePosition() { // 1. Position is properly updated on it // 2. Accum value has changed by the correct amount for uptimeIndex, uptime := range supportedUptimes { - // Position-related checks recordExists, err := newUptimeAccums[uptimeIndex].HasPosition(positionName) @@ -286,6 +286,7 @@ func (s *KeeperTestSuite) TestGetPosition() { // Set up a default initialized position err := s.App.ConcentratedLiquidityKeeper.InitOrUpdatePosition(s.Ctx, validPoolId, s.TestAccs[0], DefaultLowerTick, DefaultUpperTick, DefaultLiquidityAmt, DefaultJoinTime, DefaultPositionId) + s.Require().NoError(err) // System under test position, err := s.App.ConcentratedLiquidityKeeper.GetPosition(s.Ctx, test.positionId) @@ -570,7 +571,8 @@ func (s *KeeperTestSuite) TestDeletePosition() { // Retrieve the position from the store via position ID and compare to expected values. position := model.Position{} positionIdToPositionKey := types.KeyPositionId(DefaultPositionId) - osmoutils.Get(store, positionIdToPositionKey, &position) + _, err = osmoutils.Get(store, positionIdToPositionKey, &position) + s.Require().NoError(err) s.Require().Equal(model.Position{}, position) // Retrieve the position ID from the store via owner/poolId key and compare to expected values. @@ -629,9 +631,10 @@ func (s *KeeperTestSuite) TestCalculateUnderlyingAssetsFromPosition() { for _, tc := range tests { s.Run(tc.name, func() { // prepare concentrated pool with a default position - clPool := s.PrepareConcentratedPool() + s.PrepareConcentratedPool() s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin(ETH, DefaultAmt0), sdk.NewCoin(USDC, DefaultAmt1))) - s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, 1, s.TestAccs[0], DefaultAmt0, DefaultAmt1, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + _, _, _, _, _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, 1, s.TestAccs[0], DefaultAmt0, DefaultAmt1, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + s.Require().NoError(err) // create a position from the test case s.FundAcc(s.TestAccs[1], sdk.NewCoins(sdk.NewCoin(ETH, DefaultAmt0), sdk.NewCoin(USDC, DefaultAmt1))) @@ -647,7 +650,7 @@ func (s *KeeperTestSuite) TestCalculateUnderlyingAssetsFromPosition() { } // calculate underlying assets from the position - clPool, err = s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, tc.position.PoolId) + clPool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, tc.position.PoolId) s.Require().NoError(err) calculatedCoin0, calculatedCoin1, err := cl.CalculateUnderlyingAssetsFromPosition(s.Ctx, tc.position, clPool) @@ -769,7 +772,8 @@ func (s *KeeperTestSuite) TestValidateAndFungifyChargedPositions() { s.PrepareConcentratedPool() // Set incentives for pool to ensure accumulators work correctly - s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, DefaultIncentiveRecords) + err := s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, DefaultIncentiveRecords) + s.Require().NoError(err) // Set up fully charged positions totalLiquidity := sdk.ZeroDec() @@ -1085,7 +1089,8 @@ func (s *KeeperTestSuite) TestFungifyChargedPositions_SwapAndClaimFees() { s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, swapFee) // Set incentives for pool to ensure accumulators work correctly - s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, DefaultIncentiveRecords) + err := s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, DefaultIncentiveRecords) + s.Require().NoError(err) // Set up fully charged positions totalLiquidity := sdk.ZeroDec() @@ -1195,7 +1200,8 @@ func (s *KeeperTestSuite) TestFungifyChargedPositions_ClaimIncentives() { }, MinUptime: time.Nanosecond, } - s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, []types.IncentiveRecord{testIncentiveRecord}) + err := s.App.ConcentratedLiquidityKeeper.SetMultipleIncentiveRecords(s.Ctx, []types.IncentiveRecord{testIncentiveRecord}) + s.Require().NoError(err) // Set up fully charged positions totalLiquidity := sdk.ZeroDec() @@ -1209,7 +1215,7 @@ func (s *KeeperTestSuite) TestFungifyChargedPositions_ClaimIncentives() { s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(testFullChargeDuration)) // sync accumulators - err := s.App.ConcentratedLiquidityKeeper.UpdateUptimeAccumulatorsToNow(s.Ctx, pool.GetId()) + err = s.App.ConcentratedLiquidityKeeper.UpdateUptimeAccumulatorsToNow(s.Ctx, pool.GetId()) s.Require().NoError(err) claimableIncentives := sdk.NewCoins() @@ -1724,6 +1730,7 @@ func (s *KeeperTestSuite) TestPositionToLockCRUD() { // Create a position without a lock positionId, _, _, _, _, err = s.App.ConcentratedLiquidityKeeper.CreateFullRangePosition(s.Ctx, clPool.GetId(), owner, defaultPositionCoins) + s.Require().Error(err) // Check if position has lock in state, should not retrievedLockId, err = s.App.ConcentratedLiquidityKeeper.GetLockIdFromPositionId(s.Ctx, positionId) diff --git a/x/concentrated-liquidity/swaps_test.go b/x/concentrated-liquidity/swaps_test.go index 7a2da469573..4af9f8dea09 100644 --- a/x/concentrated-liquidity/swaps_test.go +++ b/x/concentrated-liquidity/swaps_test.go @@ -2362,7 +2362,7 @@ func (s *KeeperTestSuite) TestCalcOutAmtGivenInWriteCtx() { } } -// TestCalcInAmtGivenOutWriteCtx tests that writeCtx succesfully perfroms state changes as expected. +// TestCalcInAmtGivenOutWriteCtx tests that writeCtx successfully performs state changes as expected. // We expect writeCtx to only change fee accum state, since pool state change is not handled via writeCtx function. func (s *KeeperTestSuite) TestCalcInAmtGivenOutWriteCtx() { // we only use fee cases here since write Ctx only takes effect in the fee accumulator @@ -2483,6 +2483,7 @@ func (s *KeeperTestSuite) TestInverseRelationshipSwapOutAmtGivenIn() { s.Ctx, s.TestAccs[0], pool, test.tokenIn, test.tokenOutDenom, DefaultZeroSwapFee, test.priceLimit) + s.Require().NoError(err) secondTokenIn, secondTokenOut, _, _, _, err := s.App.ConcentratedLiquidityKeeper.SwapOutAmtGivenIn( s.Ctx, s.TestAccs[0], pool, @@ -2574,6 +2575,7 @@ func (s *KeeperTestSuite) TestInverseRelationshipSwapInAmtGivenOut() { s.Ctx, s.TestAccs[0], pool, test.tokenOut, test.tokenInDenom, DefaultZeroSwapFee, test.priceLimit) + s.Require().NoError(err) secondTokenIn, secondTokenOut, _, _, _, err := s.App.ConcentratedLiquidityKeeper.SwapInAmtGivenOut( s.Ctx, s.TestAccs[0], pool, @@ -2650,10 +2652,11 @@ func (suite *KeeperTestSuite) TestUpdatePoolForSwap() { suite.FundAcc(sender, tc.senderInitialBalance) // Default pool values are initialized to one. - pool.ApplySwap(sdk.OneDec(), sdk.OneInt(), sdk.OneDec()) + err := pool.ApplySwap(sdk.OneDec(), sdk.OneInt(), sdk.OneDec()) + suite.Require().NoError(err) // Write default pool to state. - err := concentratedLiquidityKeeper.SetPool(suite.Ctx, pool) + err = concentratedLiquidityKeeper.SetPool(suite.Ctx, pool) suite.Require().NoError(err) // Set mock listener to make sure that is is called when desired. @@ -2868,7 +2871,8 @@ func (s *KeeperTestSuite) TestFunctionalSwaps() { s.Require().NoError(err) owner, err := sdk.AccAddressFromBech32(position.Address) s.Require().NoError(err) - s.App.ConcentratedLiquidityKeeper.WithdrawPosition(s.Ctx, owner, positionId, position.Liquidity) + _, _, err = s.App.ConcentratedLiquidityKeeper.WithdrawPosition(s.Ctx, owner, positionId, position.Liquidity) + s.Require().NoError(err) } // Swap multiple times ETH for USDC, therefore decreasing the spot price @@ -2927,7 +2931,8 @@ func (s *KeeperTestSuite) TestFunctionalSwaps() { s.Require().NoError(err) owner, err := sdk.AccAddressFromBech32(position.Address) s.Require().NoError(err) - s.App.ConcentratedLiquidityKeeper.WithdrawPosition(s.Ctx, owner, positionId, position.Liquidity) + _, _, err = s.App.ConcentratedLiquidityKeeper.WithdrawPosition(s.Ctx, owner, positionId, position.Liquidity) + s.Require().NoError(err) } // Swap multiple times USDC for ETH, therefore increasing the spot price @@ -2986,7 +2991,8 @@ func (s *KeeperTestSuite) TestFunctionalSwaps() { s.Require().NoError(err) owner, err := sdk.AccAddressFromBech32(position.Address) s.Require().NoError(err) - s.App.ConcentratedLiquidityKeeper.WithdrawPosition(s.Ctx, owner, positionId, position.Liquidity) + _, _, err = s.App.ConcentratedLiquidityKeeper.WithdrawPosition(s.Ctx, owner, positionId, position.Liquidity) + s.Require().NoError(err) } // Swap multiple times ETH for USDC, therefore decreasing the spot price diff --git a/x/concentrated-liquidity/tick_test.go b/x/concentrated-liquidity/tick_test.go index 8a37c77b24c..d81ff6ab706 100644 --- a/x/concentrated-liquidity/tick_test.go +++ b/x/concentrated-liquidity/tick_test.go @@ -412,7 +412,8 @@ func (s *KeeperTestSuite) TestGetTickInfo() { clKeeper := s.App.ConcentratedLiquidityKeeper if test.preInitUptimeAccumValues != nil { - addToUptimeAccums(s.Ctx, clPool.GetId(), clKeeper, test.preInitUptimeAccumValues) + err := addToUptimeAccums(s.Ctx, clPool.GetId(), clKeeper, test.preInitUptimeAccumValues) + s.Require().NoError(err) } // Set up an initialized tick @@ -436,6 +437,7 @@ func (s *KeeperTestSuite) TestGetTickInfo() { } else { s.Require().NoError(err) clPool, err = clKeeper.GetPoolById(s.Ctx, validPoolId) + s.Require().NoError(err) s.Require().Equal(test.expectedTickInfo, tickInfo) } }) @@ -581,7 +583,8 @@ func (s *KeeperTestSuite) TestCrossTick() { // Initialize global uptime accums if test.initGlobalUptimeAccumValues != nil { - addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, test.initGlobalUptimeAccumValues) + err = addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, test.initGlobalUptimeAccumValues) + s.Require().NoError(err) } // Set up an initialized tick @@ -590,7 +593,8 @@ func (s *KeeperTestSuite) TestCrossTick() { // Update global uptime accums for edge case testing if test.globalUptimeAccumDelta != nil { - addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, test.globalUptimeAccumDelta) + err = addToUptimeAccums(s.Ctx, clPool.GetId(), s.App.ConcentratedLiquidityKeeper, test.globalUptimeAccumDelta) + s.Require().NoError(err) } // update the fee accumulator so that we have accum value > tick fee growth value @@ -1171,7 +1175,7 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { // Normally, initialized during position creation. // We only initialize ticks in this test for simplicity. curPrice := sdk.OneDec() - // TOOD: consider adding tests for GetTickLiquidityNetInDirection + // TODO: consider adding tests for GetTickLiquidityNetInDirection // with tick spacing > 1, requiring price to tick conversion with rounding. curTick, err := math.PriceToTick(curPrice) s.Require().NoError(err) @@ -1185,7 +1189,8 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { pool.SetCurrentSqrtPrice(curPrice) pool.SetCurrentTick(curTick) - s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) + err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, pool) + s.Require().NoError(err) // system under test liquidityForRange, err := s.App.ConcentratedLiquidityKeeper.GetTickLiquidityNetInDirection(s.Ctx, test.poolId, test.tokenIn, test.startTick, test.boundTick) diff --git a/x/gamm/keeper/grpc_query_test.go b/x/gamm/keeper/grpc_query_test.go index b4f819408fc..a64c22bd2f5 100644 --- a/x/gamm/keeper/grpc_query_test.go +++ b/x/gamm/keeper/grpc_query_test.go @@ -652,7 +652,7 @@ func (suite *KeeperTestSuite) TestQueryBalancerPoolSpotPrice() { result string }{ { - name: "non-existant pool", + name: "non-existent pool", req: &types.QuerySpotPriceRequest{ PoolId: 0, BaseAssetDenom: "foo", @@ -743,7 +743,7 @@ func (suite *KeeperTestSuite) TestV2QueryBalancerPoolSpotPrice() { result string }{ { - name: "non-existant pool", + name: "non-existent pool", req: &v2types.QuerySpotPriceRequest{ PoolId: 0, BaseAssetDenom: "tokenA", diff --git a/x/gamm/keeper/pool_service_test.go b/x/gamm/keeper/pool_service_test.go index 6972d3072e0..95de5abd2bf 100644 --- a/x/gamm/keeper/pool_service_test.go +++ b/x/gamm/keeper/pool_service_test.go @@ -378,7 +378,6 @@ func (suite *KeeperTestSuite) TestInitializePool() { suite.Require().NoError(err, "test: %v", test.name) suite.Require().Equal(poolIdFromPoolIncentives, defaultPoolId) } - } else { suite.Require().Error(err, "test: %v", test.name) } @@ -645,6 +644,7 @@ func (suite *KeeperTestSuite) TestExitPool() { ExitFee: sdk.NewDec(0), }, defaultPoolAssets, defaultFutureGovernor) poolId, err := poolmanagerKeeper.CreatePool(ctx, msg) + suite.Require().NoError(err) // If we are testing insufficient pool share balances, switch tx sender from pool creator to empty account if test.emptySender { @@ -749,6 +749,7 @@ func (suite *KeeperTestSuite) TestJoinPoolExitPool_InverseRelationship() { suite.AssertEventEmitted(ctx, types.TypeEvtPoolJoined, 1) _, err = gammKeeper.ExitPool(ctx, joinPoolAcc, poolId, tc.joinPoolShareAmt, sdk.Coins{}) + suite.Require().NoError(err) suite.AssertEventEmitted(ctx, types.TypeEvtPoolExited, 1) diff --git a/x/gamm/keeper/pool_test.go b/x/gamm/keeper/pool_test.go index 42eae907e11..ddcd676e0a3 100644 --- a/x/gamm/keeper/pool_test.go +++ b/x/gamm/keeper/pool_test.go @@ -499,7 +499,8 @@ func (suite *KeeperTestSuite) TestSetStableSwapScalingFactors() { pool, _ := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, poolId) stableswapPool, _ := pool.(*stableswap.Pool) stableswapPool.ScalingFactorController = controllerAddr.String() - suite.App.GAMMKeeper.SetPool(suite.Ctx, stableswapPool) + err := suite.App.GAMMKeeper.SetPool(suite.Ctx, stableswapPool) + suite.Require().NoError(err) } else { suite.prepareCustomBalancerPool( defaultAcctFunds, diff --git a/x/gamm/keeper/swap_test.go b/x/gamm/keeper/swap_test.go index 888afceddac..ca6705a05ba 100644 --- a/x/gamm/keeper/swap_test.go +++ b/x/gamm/keeper/swap_test.go @@ -490,7 +490,8 @@ func (suite *KeeperTestSuite) TestInactivePoolFreezeSwaps() { // mock objects don't have interface functions implemented by default. inactivePool.EXPECT().IsActive(suite.Ctx).Return(false).AnyTimes() inactivePool.EXPECT().GetId().Return(inactivePoolId).AnyTimes() - gammKeeper.SetPool(suite.Ctx, inactivePool) + err = gammKeeper.SetPool(suite.Ctx, inactivePool) + suite.Require().NoError(err) type testCase struct { pool poolmanagertypes.PoolI diff --git a/x/gamm/pool-models/balancer/pool_test.go b/x/gamm/pool-models/balancer/pool_test.go index 4de46cdadf8..9d3fbf14947 100644 --- a/x/gamm/pool-models/balancer/pool_test.go +++ b/x/gamm/pool-models/balancer/pool_test.go @@ -382,7 +382,7 @@ func TestCalcJoinSingleAssetTokensIn(t *testing.T) { } } -// TestGetPoolAssetsByDenom tests if `GetPoolAssetsByDenom` succesfully creates a map of denom to pool asset +// TestGetPoolAssetsByDenom tests if `GetPoolAssetsByDenom` successfully creates a map of denom to pool asset // given pool asset as parameter func TestGetPoolAssetsByDenom(t *testing.T) { testCases := []struct { @@ -693,6 +693,7 @@ func TestCalcSingleAssetInAndOut_InverseRelationship(t *testing.T) { // Expected is un-scaled func testTotalWeight(t *testing.T, expected sdk.Int, pool balancer.Pool) { + t.Helper() scaledExpected := expected.MulRaw(balancer.GuaranteedWeightPrecision) require.Equal(t, scaledExpected.String(), diff --git a/x/gamm/pool-models/balancer/util_test.go b/x/gamm/pool-models/balancer/util_test.go index ce73023f14c..3aae0cf9f6a 100644 --- a/x/gamm/pool-models/balancer/util_test.go +++ b/x/gamm/pool-models/balancer/util_test.go @@ -13,6 +13,7 @@ import ( ) func createTestPool(t *testing.T, swapFee, exitFee sdk.Dec, poolAssets ...balancer.PoolAsset) *balancer.Pool { + t.Helper() pool, err := balancer.NewBalancerPool( 1, balancer.NewPoolParams(swapFee, exitFee, nil), @@ -26,6 +27,7 @@ func createTestPool(t *testing.T, swapFee, exitFee sdk.Dec, poolAssets ...balanc } func assertExpectedSharesErrRatio(t *testing.T, expectedShares, actualShares sdk.Int) { + t.Helper() allowedErrRatioDec, err := sdk.NewDecFromStr(allowedErrRatio) require.NoError(t, err) @@ -41,12 +43,14 @@ func assertExpectedSharesErrRatio(t *testing.T, expectedShares, actualShares sdk } func assertExpectedLiquidity(t *testing.T, tokensJoined, liquidity sdk.Coins) { + t.Helper() require.Equal(t, tokensJoined, liquidity) } // assertPoolStateNotModified asserts that sut (system under test) does not modify // pool state. func assertPoolStateNotModified(t *testing.T, pool *balancer.Pool, sut func()) { + t.Helper() // We need to make sure that this method does not mutate state. oldPoolAssets := pool.GetAllPoolAssets() oldLiquidity := pool.GetTotalPoolLiquidity(sdk.Context{}) diff --git a/x/gamm/pool-models/stableswap/amm_test.go b/x/gamm/pool-models/stableswap/amm_test.go index 98245da170b..6a3a412c048 100644 --- a/x/gamm/pool-models/stableswap/amm_test.go +++ b/x/gamm/pool-models/stableswap/amm_test.go @@ -1070,6 +1070,7 @@ func TestCalcSingleAssetJoinShares(t *testing.T) { correctnessThreshold := sdk.OneInt().Mul(sdk.NewInt(int64(len(p.PoolLiquidity)))) tokenOutAmount, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, exitTokens, tc.tokenIn.Denom, sdk.ZeroDec()) + require.NoError(t, err, "test: %s", name) require.True(t, tokenOutAmount.LTE(tc.tokenIn.Amount)) require.True(t, tc.expectedOut.Sub(tokenOutAmount).Abs().LTE(correctnessThreshold)) }) diff --git a/x/gamm/pool-models/stableswap/pool_test.go b/x/gamm/pool-models/stableswap/pool_test.go index 3b489523d90..f9634c89a9a 100644 --- a/x/gamm/pool-models/stableswap/pool_test.go +++ b/x/gamm/pool-models/stableswap/pool_test.go @@ -960,8 +960,9 @@ func TestInverseJoinPoolExitPool(t *testing.T) { } // we join then exit the pool - shares, err := p.JoinPool(ctx, tc.tokensIn, tc.swapFee) + shares, _ := p.JoinPool(ctx, tc.tokensIn, tc.swapFee) tokenOut, err := p.ExitPool(ctx, shares, defaultExitFee) + require.NoError(t, err) // if single asset join, we swap output tokens to input denom to test the full inverse relationship if len(tc.tokensIn) == 1 { diff --git a/x/gamm/pool-models/stableswap/util_test.go b/x/gamm/pool-models/stableswap/util_test.go index dada28614ea..be7dfb6c464 100644 --- a/x/gamm/pool-models/stableswap/util_test.go +++ b/x/gamm/pool-models/stableswap/util_test.go @@ -10,6 +10,7 @@ import ( ) func createTestPool(t *testing.T, poolLiquidity sdk.Coins, swapFee, exitFee sdk.Dec, scalingFactors []uint64) types.CFMMPoolI { + t.Helper() scalingFactors, _ = applyScalingFactorMultiplier(scalingFactors) pool, err := NewStableswapPool(1, PoolParams{ diff --git a/x/ibc-rate-limit/ibc_middleware_test.go b/x/ibc-rate-limit/ibc_middleware_test.go index 489b6378244..fbdfb014a6e 100644 --- a/x/ibc-rate-limit/ibc_middleware_test.go +++ b/x/ibc-rate-limit/ibc_middleware_test.go @@ -167,6 +167,7 @@ func (suite *MiddlewareTestSuite) FullSendBToA(msg sdk.Msg) (*sdk.Result, string suite.Require().NoError(err) ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) + suite.Require().NoError(err) err = suite.path.EndpointA.UpdateClient() suite.Require().NoError(err) @@ -240,10 +241,10 @@ func (suite *MiddlewareTestSuite) AssertSend(success bool, msg sdk.Msg) (*sdk.Re return r, err } -func (suite *MiddlewareTestSuite) BuildChannelQuota(name, channel, denom string, duration, send_precentage, recv_percentage uint32) string { +func (suite *MiddlewareTestSuite) BuildChannelQuota(name, channel, denom string, duration, send_percentage, recv_percentage uint32) string { return fmt.Sprintf(` {"channel_id": "%s", "denom": "%s", "quotas": [{"name":"%s", "duration": %d, "send_recv":[%d, %d]}] } - `, channel, denom, name, duration, send_precentage, recv_percentage) + `, channel, denom, name, duration, send_percentage, recv_percentage) } // Tests @@ -251,13 +252,15 @@ func (suite *MiddlewareTestSuite) BuildChannelQuota(name, channel, denom string, // Test that Sending IBC messages works when the middleware isn't configured func (suite *MiddlewareTestSuite) TestSendTransferNoContract() { one := sdk.NewInt(1) - suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, one)) + _, err := suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, one)) + suite.Require().NoError(err) } // Test that Receiving IBC messages works when the middleware isn't configured func (suite *MiddlewareTestSuite) TestReceiveTransferNoContract() { one := sdk.NewInt(1) - suite.AssertReceive(true, suite.MessageFromBToA(sdk.DefaultBondDenom, one)) + _, err := suite.AssertReceive(true, suite.MessageFromBToA(sdk.DefaultBondDenom, one)) + suite.Require().NoError(err) } func (suite *MiddlewareTestSuite) initializeEscrow() (totalEscrow, expectedSed sdk.Int) { @@ -315,7 +318,8 @@ func (suite *MiddlewareTestSuite) fullSendTest(native bool) map[string]string { // send 2.5% (quota is 5%) fmt.Printf("Sending %s from A to B. Represented in chain A as wrapped? %v\n", denom, !native) - suite.AssertSend(true, suite.MessageFromAToB(denom, sendAmount)) + _, err := suite.AssertSend(true, suite.MessageFromAToB(denom, sendAmount)) + suite.Require().NoError(err) // send 2.5% (quota is 5%) fmt.Println("trying to send ", sendAmount) @@ -330,7 +334,8 @@ func (suite *MiddlewareTestSuite) fullSendTest(native bool) map[string]string { suite.Require().Equal(used, sendAmount.MulRaw(2)) // Sending above the quota should fail. We use 2 instead of 1 here to avoid rounding issues - suite.AssertSend(false, suite.MessageFromAToB(denom, sdk.NewInt(2))) + _, err = suite.AssertSend(false, suite.MessageFromAToB(denom, sdk.NewInt(2))) + suite.Require().Error(err) return attrs } @@ -361,14 +366,16 @@ func (suite *MiddlewareTestSuite) TestSendTransferReset() { // Move chainA forward one block suite.chainA.NextBlock() - suite.chainA.SenderAccount.SetSequence(suite.chainA.SenderAccount.GetSequence() + 1) + err = suite.chainA.SenderAccount.SetSequence(suite.chainA.SenderAccount.GetSequence() + 1) + suite.Require().NoError(err) // Reset time + one second oneSecAfterReset := resetTime.Add(time.Second) suite.coordinator.IncrementTimeBy(oneSecAfterReset.Sub(suite.coordinator.CurrentTime)) // Sending should succeed again - suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + _, err = suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + suite.Require().NoError(err) } // Test rate limiting on receives @@ -405,13 +412,16 @@ func (suite *MiddlewareTestSuite) fullRecvTest(native bool) { // receive 2.5% (quota is 5%) fmt.Printf("Sending %s from B to A. Represented in chain A as wrapped? %v\n", sendDenom, native) - suite.AssertReceive(true, suite.MessageFromBToA(sendDenom, sendAmount)) + _, err := suite.AssertReceive(true, suite.MessageFromBToA(sendDenom, sendAmount)) + suite.Require().NoError(err) // receive 2.5% (quota is 5%) - suite.AssertReceive(true, suite.MessageFromBToA(sendDenom, sendAmount)) + _, err = suite.AssertReceive(true, suite.MessageFromBToA(sendDenom, sendAmount)) + suite.Require().NoError(err) // Sending above the quota should fail. We send 2 instead of 1 to account for rounding errors - suite.AssertReceive(false, suite.MessageFromBToA(sendDenom, sdk.NewInt(2))) + _, err = suite.AssertReceive(false, suite.MessageFromBToA(sendDenom, sdk.NewInt(2))) + suite.Require().NoError(err) } func (suite *MiddlewareTestSuite) TestRecvTransferWithRateLimitingNative() { @@ -437,7 +447,8 @@ func (suite *MiddlewareTestSuite) TestSendTransferNoQuota() { // send 1 token. // If the contract doesn't have a quota for the current channel, all transfers are allowed - suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + _, err := suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + suite.Require().NoError(err) } // Test rate limits are reverted if a "send" fails @@ -473,11 +484,13 @@ func (suite *MiddlewareTestSuite) TestFailedSendTransfer() { suite.Require().NoError(err) // Sending again fails as the quota is filled - suite.AssertSend(false, suite.MessageFromAToB(sdk.DefaultBondDenom, quota)) + _, err = suite.AssertSend(false, suite.MessageFromAToB(sdk.DefaultBondDenom, quota)) + suite.Require().Error(err) // Move forward one block suite.chainA.NextBlock() - suite.chainA.SenderAccount.SetSequence(suite.chainA.SenderAccount.GetSequence() + 1) + err = suite.chainA.SenderAccount.SetSequence(suite.chainA.SenderAccount.GetSequence() + 1) + suite.Require().NoError(err) suite.chainA.Coordinator.IncrementTime() // Update both clients @@ -494,6 +507,7 @@ func (suite *MiddlewareTestSuite) TestFailedSendTransfer() { // recv in chain b res, err = suite.path.EndpointB.RecvPacketWithResult(packet) + suite.Require().NoError(err) // get the ack from the chain b's response ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) @@ -504,7 +518,8 @@ func (suite *MiddlewareTestSuite) TestFailedSendTransfer() { suite.Require().NoError(err) // We should be able to send again because the packet that exceeded the quota failed and has been reverted - suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + _, err = suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + suite.Require().NoError(err) } func (suite *MiddlewareTestSuite) TestUnsetRateLimitingContract() { diff --git a/x/incentives/keeper/bench_test.go b/x/incentives/keeper/bench_test.go index 8a7e48b7109..f0feeb05e25 100644 --- a/x/incentives/keeper/bench_test.go +++ b/x/incentives/keeper/bench_test.go @@ -69,7 +69,8 @@ func genQueryCondition( } // benchmarkDistributionLogic creates gauges with lockups that get distributed to. Benchmarks the performance of the distribution process. -func benchmarkDistributionLogic(numAccts, numDenoms, numGauges, numLockups, numDistrs int, b *testing.B) { +func benchmarkDistributionLogic(b *testing.B, numAccts, numDenoms, numGauges, numLockups, numDistrs int) { + b.Helper() b.StopTimer() blockStartTime := time.Now().UTC() @@ -175,7 +176,7 @@ func BenchmarkDistributionLogicTiny(b *testing.B) { numGauges := 1 numLockups := 1 numDistrs := 1 - benchmarkDistributionLogic(numAccts, numDenoms, numGauges, numLockups, numDistrs, b) + benchmarkDistributionLogic(b, numAccts, numDenoms, numGauges, numLockups, numDistrs) } func BenchmarkDistributionLogicSmall(b *testing.B) { @@ -184,7 +185,7 @@ func BenchmarkDistributionLogicSmall(b *testing.B) { numGauges := 10 numLockups := 1000 numDistrs := 100 - benchmarkDistributionLogic(numAccts, numDenoms, numGauges, numLockups, numDistrs, b) + benchmarkDistributionLogic(b, numAccts, numDenoms, numGauges, numLockups, numDistrs) } func BenchmarkDistributionLogicMedium(b *testing.B) { @@ -194,7 +195,7 @@ func BenchmarkDistributionLogicMedium(b *testing.B) { numLockups := 20000 numDistrs := 1 - benchmarkDistributionLogic(numAccts, numDenoms, numGauges, numLockups, numDistrs, b) + benchmarkDistributionLogic(b, numAccts, numDenoms, numGauges, numLockups, numDistrs) } func BenchmarkDistributionLogicLarge(b *testing.B) { @@ -204,7 +205,7 @@ func BenchmarkDistributionLogicLarge(b *testing.B) { numLockups := 100000 numDistrs := 1 - benchmarkDistributionLogic(numAccts, numDenoms, numGauges, numLockups, numDistrs, b) + benchmarkDistributionLogic(b, numAccts, numDenoms, numGauges, numLockups, numDistrs) } func BenchmarkDistributionLogicHuge(b *testing.B) { @@ -213,5 +214,5 @@ func BenchmarkDistributionLogicHuge(b *testing.B) { numGauges := 1000 numLockups := 1000 numDistrs := 30000 - benchmarkDistributionLogic(numAccts, numDenoms, numGauges, numLockups, numDistrs, b) + benchmarkDistributionLogic(b, numAccts, numDenoms, numGauges, numLockups, numDistrs) } diff --git a/x/incentives/keeper/distribute_test.go b/x/incentives/keeper/distribute_test.go index 8f20b5db5b0..ac48df43d42 100644 --- a/x/incentives/keeper/distribute_test.go +++ b/x/incentives/keeper/distribute_test.go @@ -221,7 +221,9 @@ func (suite *KeeperTestSuite) TestDistributeToConcentratedLiquidityPools() { suite.FundAcc(addr, coinsToMint) // make sure the module has enough funds - suite.App.BankKeeper.SendCoinsFromAccountToModule(suite.Ctx, addr, types.ModuleName, coinsToMint) + err := suite.App.BankKeeper.SendCoinsFromAccountToModule(suite.Ctx, addr, types.ModuleName, coinsToMint) + suite.Require().NoError(err) + var poolId uint64 // prepare a CL Pool that creates gauge at the end of createPool if tc.poolType == poolmanagertypes.Concentrated { @@ -290,7 +292,7 @@ func (suite *KeeperTestSuite) TestDistributeToConcentratedLiquidityPools() { poolId, err := suite.App.PoolIncentivesKeeper.GetPoolIdFromGaugeId(suite.Ctx, gauge.GetId(), currentEpoch.Duration) suite.Require().NoError(err) - // GetIncentiveRecord to see if pools recieved incentives properly + // GetIncentiveRecord to see if pools received incentives properly incentiveRecord, err := suite.App.ConcentratedLiquidityKeeper.GetIncentiveRecord(suite.Ctx, poolId, defaultRewardDenom, types.DefaultConcentratedUptime, suite.App.AccountKeeper.GetModuleAddress(types.ModuleName)) suite.Require().NoError(err) diff --git a/x/incentives/keeper/gauge_test.go b/x/incentives/keeper/gauge_test.go index ef672054e85..60c67bd7e72 100644 --- a/x/incentives/keeper/gauge_test.go +++ b/x/incentives/keeper/gauge_test.go @@ -202,7 +202,6 @@ func (suite *KeeperTestSuite) TestGaugeOperations() { // check non-perpetual gauges (finished + rewards estimate empty) if !tc.isPerpetual { - // check finished gauges gauges = suite.App.IncentivesKeeper.GetFinishedGauges(suite.Ctx) suite.Require().Len(gauges, 1) @@ -223,7 +222,6 @@ func (suite *KeeperTestSuite) TestGaugeOperations() { gaugeIdsByDenom = suite.App.IncentivesKeeper.GetAllGaugeIDsByDenom(suite.Ctx, "lptoken") suite.Require().Len(gaugeIdsByDenom, 0) } else { // check perpetual gauges (not finished + rewards estimate empty) - // check finished gauges gauges = suite.App.IncentivesKeeper.GetFinishedGauges(suite.Ctx) suite.Require().Len(gauges, 0) @@ -404,7 +402,6 @@ func (suite *KeeperTestSuite) TestAddToGaugeRewards() { // balance shouldn't change in the module balance := suite.App.BankKeeper.GetAllBalances(suite.Ctx, suite.App.AccountKeeper.GetModuleAddress(types.ModuleName)) suite.Require().Equal(existingGaugeCoins, balance) - } else { suite.Require().NoError(err) diff --git a/x/incentives/keeper/grpc_query_test.go b/x/incentives/keeper/grpc_query_test.go index ccc2a8ed0d1..a5f85cf54c9 100644 --- a/x/incentives/keeper/grpc_query_test.go +++ b/x/incentives/keeper/grpc_query_test.go @@ -89,6 +89,7 @@ func (suite *KeeperTestSuite) TestGRPCGauges() { // check that setting page request limit to 10 will only return 10 out of the 11 gauges filter := query.PageRequest{Limit: 10} res, err = suite.querier.Gauges(sdk.WrapSDKContext(suite.Ctx), &types.GaugesRequest{Pagination: &filter}) + suite.Require().NoError(err) suite.Require().Len(res.Data, 10) } @@ -134,16 +135,19 @@ func (suite *KeeperTestSuite) TestGRPCActiveGauges() { // move the first 9 gauges from upcoming to active (now 10 active gauges, 30 total gauges) if i < 9 { - suite.querier.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + err = suite.querier.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + suite.Require().NoError(err) } } // set page request limit to 5, expect only 5 active gauge responses res, err = suite.querier.ActiveGauges(sdk.WrapSDKContext(suite.Ctx), &types.ActiveGaugesRequest{Pagination: &query.PageRequest{Limit: 5}}) + suite.Require().NoError(err) suite.Require().Len(res.Data, 5) // set page request limit to 15, expect only 10 active gauge responses res, err = suite.querier.ActiveGauges(sdk.WrapSDKContext(suite.Ctx), &types.ActiveGaugesRequest{Pagination: &query.PageRequest{Limit: 15}}) + suite.Require().NoError(err) suite.Require().Len(res.Data, 10) } @@ -160,6 +164,7 @@ func (suite *KeeperTestSuite) TestGRPCActiveGaugesPerDenom() { gaugeID, gauge, coins, startTime := suite.SetupNewGauge(false, sdk.Coins{sdk.NewInt64Coin("stake", 10)}) suite.Ctx = suite.Ctx.WithBlockTime(startTime.Add(time.Second)) err = suite.App.IncentivesKeeper.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + suite.Require().NoError(err) // query gauges by denom again, but this time expect the gauge created earlier in the response res, err = suite.querier.ActiveGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &types.ActiveGaugesPerDenomRequest{Denom: "lptoken", Pagination: nil}) @@ -188,21 +193,25 @@ func (suite *KeeperTestSuite) TestGRPCActiveGaugesPerDenom() { // move the first 10 of 20 gauges to an active status if i < 10 { - suite.querier.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + err = suite.querier.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + suite.Require().NoError(err) } } // query active gauges by lptoken denom with a page request of 5 should only return one gauge res, err = suite.querier.ActiveGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &types.ActiveGaugesPerDenomRequest{Denom: "lptoken", Pagination: &query.PageRequest{Limit: 5}}) suite.Require().Len(res.Data, 1) + suite.Require().NoError(err) // query active gauges by pool denom with a page request of 5 should return 5 gauges res, err = suite.querier.ActiveGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &types.ActiveGaugesPerDenomRequest{Denom: "pool", Pagination: &query.PageRequest{Limit: 5}}) suite.Require().Len(res.Data, 5) + suite.Require().NoError(err) // query active gauges by pool denom with a page request of 15 should return 10 gauges res, err = suite.querier.ActiveGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &types.ActiveGaugesPerDenomRequest{Denom: "pool", Pagination: &query.PageRequest{Limit: 15}}) suite.Require().Len(res.Data, 10) + suite.Require().NoError(err) } // TestGRPCUpcomingGauges tests querying upcoming gauges via gRPC returns the correct response. @@ -245,16 +254,19 @@ func (suite *KeeperTestSuite) TestGRPCUpcomingGauges() { // move the first 9 created gauges to an active status // 1 + (20 -9) = 12 upcoming gauges if i < 9 { - suite.querier.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + err = suite.querier.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + suite.Require().NoError(err) } } // query upcoming gauges with a page request of 5 should return 5 gauges res, err = suite.querier.UpcomingGauges(sdk.WrapSDKContext(suite.Ctx), &types.UpcomingGaugesRequest{Pagination: &query.PageRequest{Limit: 5}}) + suite.Require().NoError(err) suite.Require().Len(res.Data, 5) // query upcoming gauges with a page request of 15 should return 12 gauges res, err = suite.querier.UpcomingGauges(sdk.WrapSDKContext(suite.Ctx), &types.UpcomingGaugesRequest{Pagination: &query.PageRequest{Limit: 15}}) + suite.Require().NoError(err) suite.Require().Len(res.Data, 12) } @@ -295,6 +307,7 @@ func (suite *KeeperTestSuite) TestGRPCUpcomingGaugesPerDenom() { // ensure the query no longer returns a response suite.Ctx = suite.Ctx.WithBlockTime(startTime.Add(time.Second)) err = suite.App.IncentivesKeeper.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + suite.Require().NoError(err) res, err = suite.querier.UpcomingGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &upcomingGaugeRequest) suite.Require().NoError(err) suite.Require().Len(res.UpcomingGauges, 0) @@ -307,20 +320,24 @@ func (suite *KeeperTestSuite) TestGRPCUpcomingGaugesPerDenom() { // move the first 10 created gauges from upcoming to active // this leaves 10 upcoming gauges if i < 10 { - suite.querier.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + err = suite.querier.MoveUpcomingGaugeToActiveGauge(suite.Ctx, *gauge) + suite.Require().NoError(err) } } // query upcoming gauges by lptoken denom with a page request of 5 should return 0 gauges res, err = suite.querier.UpcomingGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &types.UpcomingGaugesPerDenomRequest{Denom: "lptoken", Pagination: &query.PageRequest{Limit: 5}}) + suite.Require().NoError(err) suite.Require().Len(res.UpcomingGauges, 0) // query upcoming gauges by pool denom with a page request of 5 should return 5 gauges res, err = suite.querier.UpcomingGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &types.UpcomingGaugesPerDenomRequest{Denom: "pool", Pagination: &query.PageRequest{Limit: 5}}) + suite.Require().NoError(err) suite.Require().Len(res.UpcomingGauges, 5) // query upcoming gauges by pool denom with a page request of 15 should return 10 gauges res, err = suite.querier.UpcomingGaugesPerDenom(sdk.WrapSDKContext(suite.Ctx), &types.UpcomingGaugesPerDenomRequest{Denom: "pool", Pagination: &query.PageRequest{Limit: 15}}) + suite.Require().NoError(err) suite.Require().Len(res.UpcomingGauges, 10) } diff --git a/x/incentives/keeper/msg_server_test.go b/x/incentives/keeper/msg_server_test.go index 9ecbbf880b7..a662ad9af20 100644 --- a/x/incentives/keeper/msg_server_test.go +++ b/x/incentives/keeper/msg_server_test.go @@ -266,8 +266,10 @@ func (suite *KeeperTestSuite) completeGauge(gauge *types.Gauge, sendingAddress s } suite.BeginNewBlock(false) for i := 0; i < int(gauge.NumEpochsPaidOver); i++ { - suite.App.IncentivesKeeper.BeforeEpochStart(suite.Ctx, epochId, int64(i)) - suite.App.IncentivesKeeper.AfterEpochEnd(suite.Ctx, epochId, int64(i)) + err := suite.App.IncentivesKeeper.BeforeEpochStart(suite.Ctx, epochId, int64(i)) + suite.Require().NoError(err) + err = suite.App.IncentivesKeeper.AfterEpochEnd(suite.Ctx, epochId, int64(i)) + suite.Require().NoError(err) } suite.BeginNewBlock(false) gauge2, err := suite.App.IncentivesKeeper.GetGaugeByID(suite.Ctx, gauge.Id) diff --git a/x/lockup/keeper/bench_test.go b/x/lockup/keeper/bench_test.go index 23205ceada8..50b12933d5d 100644 --- a/x/lockup/keeper/bench_test.go +++ b/x/lockup/keeper/bench_test.go @@ -31,7 +31,8 @@ func Max(x, y int) int { return y } -func benchmarkResetLogic(numLockups int, b *testing.B) { +func benchmarkResetLogic(b *testing.B, numLockups int) { + b.Helper() // b.ReportAllocs() b.StopTimer() @@ -79,5 +80,5 @@ func benchmarkResetLogic(numLockups int, b *testing.B) { } func BenchmarkResetLogicMedium(b *testing.B) { - benchmarkResetLogic(50000, b) + benchmarkResetLogic(b, 50000) } diff --git a/x/lockup/keeper/lock_test.go b/x/lockup/keeper/lock_test.go index 764d410516d..6a803138a9f 100644 --- a/x/lockup/keeper/lock_test.go +++ b/x/lockup/keeper/lock_test.go @@ -276,7 +276,6 @@ func (suite *KeeperTestSuite) TestUnlock() { // check lock state suite.Require().Equal(ctx.BlockTime().Add(lock.Duration), lock.EndTime) suite.Require().Equal(true, lock.IsUnlocking()) - } else { suite.Require().Error(err) @@ -1001,7 +1000,9 @@ func (suite *KeeperTestSuite) TestSlashTokensFromLockByID() { }) suite.Require().Equal(int64(10), acc.Int64()) - suite.App.LockupKeeper.SlashTokensFromLockByID(suite.Ctx, 1, sdk.Coins{sdk.NewInt64Coin("stake", 1)}) + _, err = suite.App.LockupKeeper.SlashTokensFromLockByID(suite.Ctx, 1, sdk.Coins{sdk.NewInt64Coin("stake", 1)}) + suite.Require().NoError(err) + acc = suite.App.LockupKeeper.GetPeriodLocksAccumulation(suite.Ctx, types.QueryCondition{ Denom: "stake", Duration: time.Second, @@ -1064,6 +1065,7 @@ func (suite *KeeperTestSuite) TestSlashTokensFromLockByIDSendUnderlyingAndBurn() clPool := suite.PrepareConcentratedPool() clPoolId := clPool.GetId() positionID, _, _, liquidity, _, concentratedLockId, err := suite.App.ConcentratedLiquidityKeeper.CreateFullRangePositionLocked(suite.Ctx, clPoolId, addr, tc.positionCoins, time.Hour) + suite.Require().NoError(err) // Refetch the cl pool post full range position creation clPool, err = suite.App.ConcentratedLiquidityKeeper.GetPoolFromPoolIdAndConvertToConcentrated(suite.Ctx, clPoolId) diff --git a/x/lockup/keeper/msg_server_test.go b/x/lockup/keeper/msg_server_test.go index a8331e52bad..ea259a5f2ce 100644 --- a/x/lockup/keeper/msg_server_test.go +++ b/x/lockup/keeper/msg_server_test.go @@ -58,7 +58,7 @@ func (suite *KeeperTestSuite) TestMsgLockTokens() { if test.expectPass { // creation of lock via LockTokens msgServer := keeper.NewMsgServerImpl(suite.App.LockupKeeper) - _, err = msgServer.LockTokens(sdk.WrapSDKContext(suite.Ctx), types.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock)) + _, _ = msgServer.LockTokens(sdk.WrapSDKContext(suite.Ctx), types.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock)) // Check Locks locks, err := suite.App.LockupKeeper.GetPeriodLocks(suite.Ctx) @@ -93,7 +93,6 @@ func (suite *KeeperTestSuite) TestMsgLockTokens() { Duration: test.param.duration, }) suite.Require().Equal(accum.String(), "20") - } else { // Fail simple lock token suite.Require().Error(err) diff --git a/x/lockup/keeper/synthetic_lock_test.go b/x/lockup/keeper/synthetic_lock_test.go index 8aed84e07f2..1fbf7fdc447 100644 --- a/x/lockup/keeper/synthetic_lock_test.go +++ b/x/lockup/keeper/synthetic_lock_test.go @@ -276,7 +276,7 @@ func (suite *KeeperTestSuite) TestResetAllSyntheticLocks() { suite.Require().Len(locks, 1) suite.Require().Equal(locks[0].Coins, coins) - suite.App.LockupKeeper.InitializeAllSyntheticLocks(suite.Ctx, []types.SyntheticLock{ + err = suite.App.LockupKeeper.InitializeAllSyntheticLocks(suite.Ctx, []types.SyntheticLock{ { UnderlyingLockId: 1, SynthDenom: "synthstakestakedtovalidator1", @@ -290,6 +290,7 @@ func (suite *KeeperTestSuite) TestResetAllSyntheticLocks() { Duration: time.Second, }, }) + suite.Require().NoError(err) synthLock, err := suite.App.LockupKeeper.GetSyntheticLockup(suite.Ctx, 1, "synthstakestakedtovalidator1") suite.Require().NoError(err) diff --git a/x/lockup/keeper/utils_test.go b/x/lockup/keeper/utils_test.go index 2281fc54e24..c8d3cc18108 100644 --- a/x/lockup/keeper/utils_test.go +++ b/x/lockup/keeper/utils_test.go @@ -5,9 +5,10 @@ import ( "testing" "time" - "github.com/osmosis-labs/osmosis/v15/x/lockup/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/v15/x/lockup/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -54,13 +55,16 @@ func TestLockRefKeys(t *testing.T) { // not empty address and 1 coin lock3 := types.NewPeriodLock(1, addr1, time.Second, time.Now(), sdk.Coins{sdk.NewInt64Coin("stake", 10)}) keys3, err := lockRefKeys(lock3) + require.NoError(t, err) require.Len(t, keys3, 8) // not empty address and empty coin lock4 := types.NewPeriodLock(1, addr1, time.Second, time.Now(), sdk.Coins{sdk.NewInt64Coin("stake", 10)}) keys4, err := lockRefKeys(lock4) + require.NoError(t, err) require.Len(t, keys4, 8) // not empty address and 2 coins lock5 := types.NewPeriodLock(1, addr1, time.Second, time.Now(), sdk.Coins{sdk.NewInt64Coin("stake", 10), sdk.NewInt64Coin("atom", 1)}) keys5, err := lockRefKeys(lock5) + require.NoError(t, err) require.Len(t, keys5, 12) } diff --git a/x/mint/keeper/hooks_test.go b/x/mint/keeper/hooks_test.go index 79cc5601411..45993b3e1d3 100644 --- a/x/mint/keeper/hooks_test.go +++ b/x/mint/keeper/hooks_test.go @@ -543,7 +543,8 @@ func (suite *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParamete developerAccountBalanceBeforeHook := app.BankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName), sdk.DefaultBondDenom) // System under test. - mintKeeper.AfterEpochEnd(ctx, defaultEpochIdentifier, i) + err = mintKeeper.AfterEpochEnd(ctx, defaultEpochIdentifier, i) + suite.Require().NoError(err) // System truncates EpochProvisions because bank takes an Int. // This causes rounding errors. Let's refer to this source as #1. @@ -604,7 +605,8 @@ func (suite *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParamete // This end of epoch should trigger thirdening. It will utilize the updated // (reduced) provisions. - mintKeeper.AfterEpochEnd(ctx, defaultEpochIdentifier, defaultThirdeningEpochNum) + err = mintKeeper.AfterEpochEnd(ctx, defaultEpochIdentifier, defaultThirdeningEpochNum) + suite.Require().NoError(err) suite.Require().Equal(defaultThirdeningEpochNum, mintKeeper.GetLastReductionEpochNum(ctx)) @@ -614,7 +616,7 @@ func (suite *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParamete suite.Require().Equal(expectedThirdenedProvisions, mintKeeper.GetMinter(ctx).EpochProvisions) } -func (suite KeeperTestSuite) assertAddressWeightsAddUpToOne(receivers []types.WeightedAddress) { +func (suite KeeperTestSuite) assertAddressWeightsAddUpToOne(receivers []types.WeightedAddress) { //nolint:govet // this is a test and we can copy locks here. sumOfWeights := sdk.ZeroDec() // As a sanity check, ensure developer reward receivers add up to 1. for _, w := range receivers { diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index f87f762c414..d3cb9076e2e 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -76,7 +76,8 @@ func (suite *KeeperTestSuite) setupDeveloperVestingModuleAccountTest(blockHeight // testing edge cases of multiple tests. developerVestingAccount := accountKeeper.GetAccount(suite.Ctx, accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName)) accountKeeper.RemoveAccount(suite.Ctx, developerVestingAccount) - bankKeeper.BurnCoins(suite.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(keeper.DeveloperVestingAmount)))) + err := bankKeeper.BurnCoins(suite.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(keeper.DeveloperVestingAmount)))) + suite.Require().Error(err) // If developer module account is created, the suite.Setup() also sets the offset, // therefore, we should reset it to 0 to set up the environment truly w/o the module account. @@ -429,7 +430,7 @@ func (suite *KeeperTestSuite) TestDistributeToModule() { // - developer vesting module account balance is correctly updated. // - all developer addressed are updated with correct proportions. // - mint module account balance is updated - burn over allocations. -// - if recepients are empty - community pool us updated. +// - if recipients are empty - community pool us updated. func (suite *KeeperTestSuite) TestDistributeDeveloperRewards() { const ( invalidAddress = "invalid" @@ -554,7 +555,7 @@ func (suite *KeeperTestSuite) TestDistributeDeveloperRewards() { expectedError: errorsmod.Wrap(bech32.ErrInvalidLength(len(invalidAddress)), "decoding bech32 failed"), // This case should not happen in practice due to parameter validation. - // The method spec also requires that all recepient addresses are valid by CONTRACT. + // The method spec also requires that all recipient addresses are valid by CONTRACT. // Since we still handle error returned by the converion from string to address, // we try to cover it explicitly. However, it changes balance so we don't test it. allowBalanceChange: true, diff --git a/x/pool-incentives/keeper/grpc_query_test.go b/x/pool-incentives/keeper/grpc_query_test.go index 8a95ead0df0..bbd489cb4d0 100644 --- a/x/pool-incentives/keeper/grpc_query_test.go +++ b/x/pool-incentives/keeper/grpc_query_test.go @@ -238,7 +238,7 @@ func (suite *KeeperTestSuite) TestIncentivizedPools() { }) // update records and ensure that non-perpetuals pot cannot get rewards. - keeper.UpdateDistrRecords(suite.Ctx, distRecords...) + _ = keeper.UpdateDistrRecords(suite.Ctx, distRecords...) } res, err := queryClient.IncentivizedPools(context.Background(), &types.QueryIncentivizedPoolsRequest{}) suite.Require().NoError(err) diff --git a/x/poolmanager/create_pool_test.go b/x/poolmanager/create_pool_test.go index 1208e9ec433..d0c6c6dcd26 100644 --- a/x/poolmanager/create_pool_test.go +++ b/x/poolmanager/create_pool_test.go @@ -416,7 +416,7 @@ func (suite *KeeperTestSuite) TestGetNextPoolIdAndIncrement() { nextPoolId := suite.App.PoolManagerKeeper.GetNextPoolId(suite.Ctx) suite.Require().Equal(tc.expectedNextPoolId, nextPoolId) - // Sytem under test. + // System under test. nextPoolId = suite.App.PoolManagerKeeper.GetNextPoolIdAndIncrement(suite.Ctx) suite.Require().Equal(tc.expectedNextPoolId, nextPoolId) suite.Require().Equal(tc.expectedNextPoolId+1, suite.App.PoolManagerKeeper.GetNextPoolId(suite.Ctx)) diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index cbb8a6f7bc3..4db293c1253 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -1774,7 +1774,7 @@ func (suite *KeeperTestSuite) TestSplitRouteExactAmountIn() { // Note, we use a 1% error tolerance with rounding down // because we initialize the reserves 1:1 so by performing // the swap we don't expect the price to change significantly. - // As a result, we rougly expect the amount out to be the same + // As a result, we roughly expect the amount out to be the same // as the amount in given in another token. However, the actual // amount must be stricly less than the given due to price impact. errTolerance := osmomath.ErrTolerance{ @@ -1975,7 +1975,7 @@ func (suite *KeeperTestSuite) TestSplitRouteExactAmountOut() { // Note, we use a 1% error tolerance with rounding up // because we initialize the reserves 1:1 so by performing // the swap we don't expect the price to change significantly. - // As a result, we rougly expect the amount in to be the same + // As a result, we roughly expect the amount in to be the same // as the amount out given of another token. However, the actual // amount must be stricly greater than the given due to price impact. errTolerance := osmomath.ErrTolerance{ diff --git a/x/protorev/keeper/developer_fees_test.go b/x/protorev/keeper/developer_fees_test.go index adaaff1e73a..3e4f11d3656 100644 --- a/x/protorev/keeper/developer_fees_test.go +++ b/x/protorev/keeper/developer_fees_test.go @@ -165,7 +165,10 @@ func (suite *KeeperTestSuite) pseudoExecuteTrade(denom string, profit sdk.Int, d // Initialize the number of days since genesis suite.App.ProtoRevKeeper.SetDaysSinceModuleGenesis(suite.Ctx, daysSinceGenesis) // Mint the profit to the module account (which will be sent to the developer account later) - suite.App.AppKeepers.BankKeeper.MintCoins(suite.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(denom, profit))) + err := suite.App.AppKeepers.BankKeeper.MintCoins(suite.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(denom, profit))) + if err != nil { + return err + } // Update the developer fees return suite.App.ProtoRevKeeper.UpdateDeveloperFees(suite.Ctx, denom, profit) } diff --git a/x/protorev/keeper/epoch_hook_test.go b/x/protorev/keeper/epoch_hook_test.go index e7075d3ef50..602061d6c56 100644 --- a/x/protorev/keeper/epoch_hook_test.go +++ b/x/protorev/keeper/epoch_hook_test.go @@ -23,7 +23,10 @@ func BenchmarkEpochHook(b *testing.B) { for i := 0; i < b.N; i++ { b.StartTimer() - suite.App.ProtoRevKeeper.UpdatePools(suite.Ctx) + err := suite.App.ProtoRevKeeper.UpdatePools(suite.Ctx) + if err != nil { + panic(fmt.Sprintf("error updating pools in protorev epoch hook benchmark: %s", err)) + } b.StopTimer() } } @@ -48,7 +51,6 @@ func (suite *KeeperTestSuite) TestEpochHook() { baseDenoms, err := suite.App.ProtoRevKeeper.GetAllBaseDenoms(suite.Ctx) suite.Require().NoError(err) for _, pool := range suite.pools { - // Module currently limited to two asset pools // Instantiate asset and amounts for the pool if len(pool.PoolAssets) == 2 { diff --git a/x/protorev/keeper/grpc_query_test.go b/x/protorev/keeper/grpc_query_test.go index 9c8b398df68..111000b69cb 100644 --- a/x/protorev/keeper/grpc_query_test.go +++ b/x/protorev/keeper/grpc_query_test.go @@ -73,7 +73,7 @@ func (suite *KeeperTestSuite) TestGetProtoRevProfitsByDenom() { suite.Require().NoError(err) suite.Commit() - res, err = suite.queryClient.GetProtoRevProfitsByDenom(sdk.WrapSDKContext(suite.Ctx), req) + _, err = suite.queryClient.GetProtoRevProfitsByDenom(sdk.WrapSDKContext(suite.Ctx), req) suite.Require().NoError(err) req = &types.QueryGetProtoRevProfitsByDenomRequest{ Denom: "Atom", diff --git a/x/protorev/keeper/keeper_test.go b/x/protorev/keeper/keeper_test.go index d57ba37d33a..ce1d4a172af 100644 --- a/x/protorev/keeper/keeper_test.go +++ b/x/protorev/keeper/keeper_test.go @@ -100,7 +100,8 @@ func (suite *KeeperTestSuite) SetupTest() { StepSize: sdk.NewInt(1_000_000), }, } - suite.App.ProtoRevKeeper.SetBaseDenoms(suite.Ctx, baseDenomPriorities) + err := suite.App.ProtoRevKeeper.SetBaseDenoms(suite.Ctx, baseDenomPriorities) + suite.Require().NoError(err) encodingConfig := osmosisapp.MakeEncodingConfig() suite.clientCtx = client.Context{}. @@ -148,7 +149,7 @@ func (suite *KeeperTestSuite) SetupTest() { // Set the Admin Account suite.adminAccount = apptesting.CreateRandomAccounts(1)[0] - err := protorev.HandleSetProtoRevAdminAccount(suite.Ctx, *suite.App.ProtoRevKeeper, &types.SetProtoRevAdminAccountProposal{Account: suite.adminAccount.String()}) + err = protorev.HandleSetProtoRevAdminAccount(suite.Ctx, *suite.App.ProtoRevKeeper, &types.SetProtoRevAdminAccountProposal{Account: suite.adminAccount.String()}) suite.Require().NoError(err) queryHelper := baseapp.NewQueryServerTestHelper(suite.Ctx, suite.App.InterfaceRegistry()) @@ -895,7 +896,8 @@ func (suite *KeeperTestSuite) setUpPools() { suite.Require().NoError(err) // Set all of the pool info into the stores - suite.App.ProtoRevKeeper.UpdatePools(suite.Ctx) + err = suite.App.ProtoRevKeeper.UpdatePools(suite.Ctx) + suite.Require().NoError(err) } // createStableswapPool creates a stableswap pool with the given pool assets and params @@ -1037,6 +1039,7 @@ func (suite *KeeperTestSuite) setUpTokenPairRoutes() { for _, tokenPair := range suite.tokenPairArbRoutes { err := tokenPair.Validate() suite.Require().NoError(err) - suite.App.ProtoRevKeeper.SetTokenPairArbRoutes(suite.Ctx, tokenPair.TokenIn, tokenPair.TokenOut, tokenPair) + err = suite.App.ProtoRevKeeper.SetTokenPairArbRoutes(suite.Ctx, tokenPair.TokenIn, tokenPair.TokenOut, tokenPair) + suite.Require().NoError(err) } } diff --git a/x/protorev/keeper/posthandler_test.go b/x/protorev/keeper/posthandler_test.go index e87643e9e48..b19f748d1fe 100644 --- a/x/protorev/keeper/posthandler_test.go +++ b/x/protorev/keeper/posthandler_test.go @@ -443,8 +443,10 @@ func (suite *KeeperTestSuite) TestAnteHandle() { } // Ensure that the max points per tx is enough for the test suite - suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 18) - suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 100) + err := suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 18) + suite.Require().NoError(err) + err = suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 100) + suite.Require().NoError(err) suite.App.ProtoRevKeeper.SetPoolWeights(suite.Ctx, types.PoolWeights{StableWeight: 5, BalancerWeight: 2, ConcentratedWeight: 2}) for _, tc := range tests { @@ -468,18 +470,22 @@ func (suite *KeeperTestSuite) TestAnteHandle() { suite.clientCtx.TxConfig, accSeqs[0], ) - simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, tc.params.txFee) + err := simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, tc.params.txFee) + suite.Require().NoError(err) var tx authsigning.Tx var msgs []sdk.Msg // Lower the max points per tx and block if the test cases are doomsday testing if strings.Contains(tc.name, "Tx Pool Points Limit") { - suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 5) + err := suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 5) + suite.Require().NoError(err) } else if strings.Contains(tc.name, "Block Pool Points Limit - Within a tx") { - suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 35) + err := suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 35) + suite.Require().NoError(err) } else if strings.Contains(tc.name, "Block Pool Points Limit Already Reached") { - suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 33) + err := suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 33) + suite.Require().NoError(err) } if strings.Contains(tc.name, "Doomsday") { @@ -487,8 +493,10 @@ func (suite *KeeperTestSuite) TestAnteHandle() { msgs = append(msgs, tc.params.msgs...) } - txBuilder.SetMsgs(msgs...) - txBuilder.SetSignatures(sigV2) + err := txBuilder.SetMsgs(msgs...) + suite.Require().NoError(err) + err = txBuilder.SetSignatures(sigV2) + suite.Require().NoError(err) txBuilder.SetMemo("") txBuilder.SetFeeAmount(tc.params.txFee) txBuilder.SetGasLimit(gasLimit) @@ -508,7 +516,7 @@ func (suite *KeeperTestSuite) TestAnteHandle() { gasBefore := suite.Ctx.GasMeter().GasConsumed() gasLimitBefore := suite.Ctx.GasMeter().Limit() - _, err := posthandlerProtoRev(suite.Ctx, tx, false) + _, err = posthandlerProtoRev(suite.Ctx, tx, false) gasAfter := suite.Ctx.GasMeter().GasConsumed() gasLimitAfter := suite.Ctx.GasMeter().Limit() @@ -536,6 +544,7 @@ func (suite *KeeperTestSuite) TestAnteHandle() { suite.Require().Equal(tc.params.expectedPoolPoints, pointCount) _, remainingBlockPoolPoints, err := suite.App.ProtoRevKeeper.GetRemainingPoolPoints(suite.Ctx) + suite.Require().NoError(err) lastEvent := suite.Ctx.EventManager().Events()[len(suite.Ctx.EventManager().Events())-1] for _, attr := range lastEvent.Attributes { @@ -543,16 +552,17 @@ func (suite *KeeperTestSuite) TestAnteHandle() { suite.Require().Equal(strconv.FormatUint(remainingBlockPoolPoints, 10), string(attr.Value)) } } - } else { suite.Require().Error(err) } // Reset the max points per tx and block if strings.Contains(tc.name, "Tx Pool Points Limit") { - suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 18) + err = suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 18) + suite.Require().NoError(err) } else if strings.Contains(tc.name, "Block Pool Points Limit") { - suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 100) + err = suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 100) + suite.Require().NoError(err) } }) } @@ -934,11 +944,14 @@ func (suite *KeeperTestSuite) TestExtractSwappedPools() { suite.clientCtx.TxConfig, accSeqs[0], ) - simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, tc.params.txFee) + err := simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, tc.params.txFee) + suite.Require().NoError(err) // Can't use test suite BuildTx because it doesn't allow for multiple msgs - txBuilder.SetMsgs(msgs...) - txBuilder.SetSignatures(sigV2) + err = txBuilder.SetMsgs(msgs...) + suite.Require().NoError(err) + err = txBuilder.SetSignatures(sigV2) + suite.Require().NoError(err) txBuilder.SetMemo("") txBuilder.SetFeeAmount(tc.params.txFee) txBuilder.SetGasLimit(gasLimit) @@ -958,6 +971,7 @@ func (suite *KeeperTestSuite) TestExtractSwappedPools() { // messages to be sent, and the expected number of trades. It then runs the benchmark and checks the // number of trades after the post handler is run. func benchmarkWrapper(b *testing.B, msgs []sdk.Msg, expectedTrades int) { + b.Helper() b.ReportAllocs() b.ResetTimer() @@ -965,7 +979,10 @@ func benchmarkWrapper(b *testing.B, msgs []sdk.Msg, expectedTrades int) { suite, tx, postHandler := setUpBenchmarkSuite(msgs) b.StartTimer() - postHandler(suite.Ctx, tx, false) + _, err := postHandler(suite.Ctx, tx, false) + if err != nil { + b.Fatal(err) + } b.StopTimer() numberTrades, err := suite.App.ProtoRevKeeper.GetNumberOfTrades(suite.Ctx) @@ -990,14 +1007,16 @@ func setUpBenchmarkSuite(msgs []sdk.Msg) (*KeeperTestSuite, authsigning.Tx, sdk. // Set up the app to the correct state to run the test suite.Ctx = suite.Ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) - suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 40) + err := suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 40) + suite.Require().NoError(err) suite.App.ProtoRevKeeper.SetPoolWeights(suite.Ctx, types.PoolWeights{StableWeight: 5, BalancerWeight: 2, ConcentratedWeight: 2}) // Init a new account and fund it with tokens for gas fees priv0, _, addr0 := testdata.KeyTestPubAddr() acc1 := suite.App.AccountKeeper.NewAccountWithAddress(suite.Ctx, addr0) suite.App.AccountKeeper.SetAccount(suite.Ctx, acc1) - simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(10000)))) + err = simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(10000)))) + suite.Require().NoError(err) // Build the tx privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} diff --git a/x/protorev/keeper/protorev_test.go b/x/protorev/keeper/protorev_test.go index 37826692cc4..9d42564340b 100644 --- a/x/protorev/keeper/protorev_test.go +++ b/x/protorev/keeper/protorev_test.go @@ -72,7 +72,8 @@ func (suite *KeeperTestSuite) TestGetAllBaseDenoms() { suite.Require().Equal(0, len(baseDenoms)) // Should be able to set the base denoms - suite.App.ProtoRevKeeper.SetBaseDenoms(suite.Ctx, []types.BaseDenom{{Denom: "osmo"}, {Denom: "atom"}, {Denom: "weth"}}) + err = suite.App.ProtoRevKeeper.SetBaseDenoms(suite.Ctx, []types.BaseDenom{{Denom: "osmo"}, {Denom: "atom"}, {Denom: "weth"}}) + suite.Require().NoError(err) baseDenoms, err = suite.App.ProtoRevKeeper.GetAllBaseDenoms(suite.Ctx) suite.Require().NoError(err) suite.Require().Equal(3, len(baseDenoms)) @@ -150,6 +151,7 @@ func (suite *KeeperTestSuite) TestGetDeveloperFees() { err = suite.App.ProtoRevKeeper.SetDeveloperFees(suite.Ctx, sdk.NewCoin("Atom", sdk.NewInt(100))) suite.Require().NoError(err) err = suite.App.ProtoRevKeeper.SetDeveloperFees(suite.Ctx, sdk.NewCoin("weth", sdk.NewInt(100))) + suite.Require().NoError(err) // Should be able to get the fees osmoFees, err = suite.App.ProtoRevKeeper.GetDeveloperFees(suite.Ctx, types.OsmosisDenomination) @@ -234,7 +236,8 @@ func (suite *KeeperTestSuite) TestGetMaxPointsPerTx() { suite.Require().Equal(uint64(18), maxPoints) // Should be able to set the max points per tx - suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 4) + err = suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, 4) + suite.Require().NoError(err) maxPoints, err = suite.App.ProtoRevKeeper.GetMaxPointsPerTx(suite.Ctx) suite.Require().NoError(err) suite.Require().Equal(uint64(4), maxPoints) @@ -289,12 +292,13 @@ func (suite *KeeperTestSuite) TestGetMaxPointsPerBlock() { suite.Require().Equal(uint64(100), maxPoints) // Should be able to set the max points per block - suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 4) + err = suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 4) + suite.Require().NoError(err) maxPoints, err = suite.App.ProtoRevKeeper.GetMaxPointsPerBlock(suite.Ctx) suite.Require().NoError(err) suite.Require().Equal(uint64(4), maxPoints) - // Can only initalize between 1 and types.MaxPoolPointsPerBlock + // Can only initialize between 1 and types.MaxPoolPointsPerBlock err = suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, 0) suite.Require().Error(err) err = suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, types.MaxPoolPointsPerBlock+1) diff --git a/x/protorev/keeper/rebalance_test.go b/x/protorev/keeper/rebalance_test.go index 47de1af64fb..12cbc2a7ace 100644 --- a/x/protorev/keeper/rebalance_test.go +++ b/x/protorev/keeper/rebalance_test.go @@ -393,7 +393,6 @@ func (suite *KeeperTestSuite) TestExecuteTrade() { } for _, test := range tests { - // Empty SwapToBackrun var to pass in as param pool := protorevtypes.SwapToBackrun{} txPoolPointsRemaining := uint64(100) @@ -644,8 +643,12 @@ func (suite *KeeperTestSuite) TestRemainingPoolPointsForTx() { suite.Run(tc.description, func() { suite.SetupTest() - suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, tc.maxRoutesPerTx) - suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, tc.maxRoutesPerBlock) + err := suite.App.ProtoRevKeeper.SetMaxPointsPerTx(suite.Ctx, tc.maxRoutesPerTx) + suite.Require().NoError(err) + + err = suite.App.ProtoRevKeeper.SetMaxPointsPerBlock(suite.Ctx, tc.maxRoutesPerBlock) + suite.Require().NoError(err) + suite.App.ProtoRevKeeper.SetPointCountForBlock(suite.Ctx, tc.currentRouteCount) points, _, err := suite.App.ProtoRevKeeper.GetRemainingPoolPoints(suite.Ctx) diff --git a/x/protorev/keeper/statistics_test.go b/x/protorev/keeper/statistics_test.go index 7a52b65c1f2..4dab599479b 100644 --- a/x/protorev/keeper/statistics_test.go +++ b/x/protorev/keeper/statistics_test.go @@ -148,7 +148,7 @@ func (suite *KeeperTestSuite) TestGetProfitsByRoute() { // TestUpdateStatistics tests UpdateStatistics which is a wrapper for much of the statistics keeper // functionality. func (suite *KeeperTestSuite) TestUpdateStatistics() { - // Psuedo execute a trade + // Pseudo execute a trade err := suite.App.ProtoRevKeeper.UpdateStatistics(suite.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, types.OsmosisDenomination, sdk.NewInt(1000), @@ -170,7 +170,7 @@ func (suite *KeeperTestSuite) TestUpdateStatistics() { suite.Require().NoError(err) suite.Require().Equal(1, len(routes)) - // Psuedo execute a second trade + // Pseudo execute a second trade err = suite.App.ProtoRevKeeper.UpdateStatistics(suite.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}, {TokenOutDenom: "", PoolId: 4}}, types.OsmosisDenomination, sdk.NewInt(1100), diff --git a/x/superfluid/keeper/gov/gov_test.go b/x/superfluid/keeper/gov/gov_test.go index 8a7927bd171..9ad2a100944 100644 --- a/x/superfluid/keeper/gov/gov_test.go +++ b/x/superfluid/keeper/gov/gov_test.go @@ -131,7 +131,6 @@ func (suite *KeeperTestSuite) TestHandleSetSuperfluidAssetsProposal() { suite.Require().Len(resp.Assets, 0) for i, action := range tc.actions { - // here we set two different string arrays of denoms. // The reason we do this is because native denom should be an asset within the pool, // while we do not want native asset to be in gov proposals. diff --git a/x/superfluid/keeper/grpc_query_test.go b/x/superfluid/keeper/grpc_query_test.go index 23ddd9bd1ad..d3444109f43 100644 --- a/x/superfluid/keeper/grpc_query_test.go +++ b/x/superfluid/keeper/grpc_query_test.go @@ -175,7 +175,6 @@ func (suite *KeeperTestSuite) TestGRPCQuerySuperfluidDelegations() { suite.Require().NotEqual("", connectedIntermediaryAccountRes.Account.Denom) suite.Require().NotEqual("", connectedIntermediaryAccountRes.Account.Address) suite.Require().NotEqual(uint64(0), connectedIntermediaryAccountRes.Account.GaugeId) - } connectedIntermediaryAccountRes, err := suite.queryClient.ConnectedIntermediaryAccount(sdk.WrapSDKContext(suite.Ctx), &types.ConnectedIntermediaryAccountRequest{LockId: 123}) suite.Require().NoError(err) diff --git a/x/superfluid/keeper/msg_server_test.go b/x/superfluid/keeper/msg_server_test.go index 2cf3795daae..e7e329ee876 100644 --- a/x/superfluid/keeper/msg_server_test.go +++ b/x/superfluid/keeper/msg_server_test.go @@ -71,6 +71,7 @@ func (suite *KeeperTestSuite) TestMsgSuperfluidDelegate() { } suite.FundAcc(test.param.lockOwner, test.param.coinsToLock) resp, err := lockupMsgServer.LockTokens(c, lockuptypes.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock)) + suite.Require().NoError(err) valAddrs := suite.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded}) @@ -120,6 +121,7 @@ func (suite *KeeperTestSuite) TestMsgSuperfluidUndelegate() { lockupMsgServer := lockupkeeper.NewMsgServerImpl(suite.App.LockupKeeper) c := sdk.WrapSDKContext(suite.Ctx) resp, err := lockupMsgServer.LockTokens(c, lockuptypes.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock)) + suite.Require().NoError(err) msgServer := keeper.NewMsgServerImpl(suite.App.SuperfluidKeeper) _, err = msgServer.SuperfluidUndelegate(c, types.NewMsgSuperfluidUndelegate(test.param.lockOwner, resp.ID)) @@ -243,6 +245,7 @@ func (suite *KeeperTestSuite) TestMsgSuperfluidUnbondLock() { lockupMsgServer := lockupkeeper.NewMsgServerImpl(suite.App.LockupKeeper) c := sdk.WrapSDKContext(suite.Ctx) resp, err := lockupMsgServer.LockTokens(c, lockuptypes.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock)) + suite.Require().NoError(err) msgServer := keeper.NewMsgServerImpl(suite.App.SuperfluidKeeper) _, err = msgServer.SuperfluidUnbondLock(c, types.NewMsgSuperfluidUnbondLock(test.param.lockOwner, resp.ID)) @@ -290,6 +293,7 @@ func (suite *KeeperTestSuite) TestMsgSuperfluidUndelegateAndUnbondLock() { lockupMsgServer := lockupkeeper.NewMsgServerImpl(suite.App.LockupKeeper) c := sdk.WrapSDKContext(suite.Ctx) resp, err := lockupMsgServer.LockTokens(c, lockuptypes.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock)) + suite.Require().NoError(err) msgServer := keeper.NewMsgServerImpl(suite.App.SuperfluidKeeper) _, err = msgServer.SuperfluidUndelegateAndUnbondLock(c, types.NewMsgSuperfluidUndelegateAndUnbondLock(test.param.lockOwner, resp.ID, test.param.amountToUnlock)) @@ -493,6 +497,7 @@ func (suite *KeeperTestSuite) TestUnlockAndMigrateSharesToFullRangeConcentratedP balancerPooId, err := suite.App.PoolManagerKeeper.CreatePool(suite.Ctx, msg) suite.Require().NoError(err) balancerPool, err := suite.App.GAMMKeeper.GetPool(suite.Ctx, balancerPooId) + suite.Require().NoError(err) poolDenom := gammtypes.GetPoolShareDenom(balancerPool.GetId()) err = suite.App.SuperfluidKeeper.AddNewSuperfluidAsset(suite.Ctx, types.SuperfluidAsset{ Denom: poolDenom, diff --git a/x/superfluid/keeper/stake_test.go b/x/superfluid/keeper/stake_test.go index 6f81cd14f2d..7ab49d396c4 100644 --- a/x/superfluid/keeper/stake_test.go +++ b/x/superfluid/keeper/stake_test.go @@ -980,7 +980,8 @@ func (suite *KeeperTestSuite) TestRefreshIntermediaryDelegationAmounts() { lpTokenAmount := sdk.NewInt(1000000) decAmt := multiplier.Mul(lpTokenAmount.ToDec()) denom := intermediaryAcc.Denom - suite.App.SuperfluidKeeper.GetSuperfluidAsset(suite.Ctx, denom) + _, err := suite.App.SuperfluidKeeper.GetSuperfluidAsset(suite.Ctx, denom) + suite.Require().NoError(err) expAmount := suite.App.SuperfluidKeeper.GetRiskAdjustedOsmoValue(suite.Ctx, decAmt.RoundInt()) // check delegation changes diff --git a/x/tokenfactory/keeper/admins_test.go b/x/tokenfactory/keeper/admins_test.go index 46f1e429718..ca4c820a4c0 100644 --- a/x/tokenfactory/keeper/admins_test.go +++ b/x/tokenfactory/keeper/admins_test.go @@ -50,6 +50,7 @@ func (suite *KeeperTestSuite) TestAdminMsgs() { // Test Change Admin _, err = suite.msgServer.ChangeAdmin(sdk.WrapSDKContext(suite.Ctx), types.NewMsgChangeAdmin(suite.TestAccs[0].String(), suite.defaultDenom, suite.TestAccs[1].String())) + suite.Require().NoError(err) queryRes, err = suite.queryClient.DenomAuthorityMetadata(suite.Ctx.Context(), &types.QueryDenomAuthorityMetadataRequest{ Denom: suite.defaultDenom, }) diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go index a8f90506444..0d667b41fd0 100644 --- a/x/tokenfactory/keeper/createdenom_test.go +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -152,7 +152,6 @@ func (suite *KeeperTestSuite) TestCreateDenom() { suite.Require().NoError(err) suite.Require().Equal(suite.TestAccs[0].String(), queryRes.AuthorityMetadata.Admin) - } else { suite.Require().Error(err) // Ensure we don't charge if we expect an error diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index 5e0b3179182..357361b371b 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -42,7 +42,12 @@ func (suite *KeeperTestSuite) TestMintDenomMsg() { ctx := suite.Ctx.WithEventManager(sdk.NewEventManager()) suite.Require().Equal(0, len(ctx.EventManager().Events())) // Test mint message - suite.msgServer.Mint(sdk.WrapSDKContext(ctx), types.NewMsgMint(tc.admin, sdk.NewInt64Coin(tc.mintDenom, 10))) + _, err := suite.msgServer.Mint(sdk.WrapSDKContext(ctx), types.NewMsgMint(tc.admin, sdk.NewInt64Coin(tc.mintDenom, 10))) + if tc.valid { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } // Ensure current number and type of event is emitted suite.AssertEventEmitted(ctx, types.TypeMsgMint, tc.expectedMessageEvents) }) @@ -54,7 +59,8 @@ func (suite *KeeperTestSuite) TestBurnDenomMsg() { // Create a denom. suite.CreateDefaultDenom() // mint 10 default token for testAcc[0] - suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(suite.defaultDenom, 10))) + _, err := suite.msgServer.Mint(sdk.WrapSDKContext(suite.Ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(suite.defaultDenom, 10))) + suite.Require().NoError(err) for _, tc := range []struct { desc string @@ -82,7 +88,12 @@ func (suite *KeeperTestSuite) TestBurnDenomMsg() { ctx := suite.Ctx.WithEventManager(sdk.NewEventManager()) suite.Require().Equal(0, len(ctx.EventManager().Events())) // Test burn message - suite.msgServer.Burn(sdk.WrapSDKContext(ctx), types.NewMsgBurn(tc.admin, sdk.NewInt64Coin(tc.burnDenom, 10))) + _, err := suite.msgServer.Burn(sdk.WrapSDKContext(ctx), types.NewMsgBurn(tc.admin, sdk.NewInt64Coin(tc.burnDenom, 10))) + if tc.valid { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } // Ensure current number and type of event is emitted suite.AssertEventEmitted(ctx, types.TypeMsgBurn, tc.expectedMessageEvents) }) @@ -121,7 +132,12 @@ func (suite *KeeperTestSuite) TestCreateDenomMsg() { // Set denom creation fee in params tokenFactoryKeeper.SetParams(suite.Ctx, tc.denomCreationFee) // Test create denom message - suite.msgServer.CreateDenom(sdk.WrapSDKContext(ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), tc.subdenom)) + _, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), tc.subdenom)) + if tc.valid { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } // Ensure current number and type of event is emitted suite.AssertEventEmitted(ctx, types.TypeMsgCreateDenom, tc.expectedMessageEvents) }) @@ -170,9 +186,15 @@ func (suite *KeeperTestSuite) TestChangeAdminDenomMsg() { res, err := suite.msgServer.CreateDenom(sdk.WrapSDKContext(ctx), types.NewMsgCreateDenom(suite.TestAccs[0].String(), "bitcoin")) suite.Require().NoError(err) testDenom := res.GetNewTokenDenom() - suite.msgServer.Mint(sdk.WrapSDKContext(ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(testDenom, 10))) + _, err = suite.msgServer.Mint(sdk.WrapSDKContext(ctx), types.NewMsgMint(suite.TestAccs[0].String(), sdk.NewInt64Coin(testDenom, 10))) + suite.Require().NoError(err) // Test change admin message - suite.msgServer.ChangeAdmin(sdk.WrapSDKContext(ctx), tc.msgChangeAdmin(testDenom)) + _, err = suite.msgServer.ChangeAdmin(sdk.WrapSDKContext(ctx), tc.msgChangeAdmin(testDenom)) + if tc.expectedChangeAdminPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } // Ensure current number and type of event is emitted suite.AssertEventEmitted(ctx, types.TypeMsgChangeAdmin, tc.expectedMessageEvents) }) @@ -239,7 +261,12 @@ func (suite *KeeperTestSuite) TestSetDenomMetaDataMsg() { ctx := suite.Ctx.WithEventManager(sdk.NewEventManager()) suite.Require().Equal(0, len(ctx.EventManager().Events())) // Test set denom metadata message - suite.msgServer.SetDenomMetadata(sdk.WrapSDKContext(ctx), &tc.msgSetDenomMetadata) + _, err := suite.msgServer.SetDenomMetadata(sdk.WrapSDKContext(ctx), &tc.msgSetDenomMetadata) + if tc.expectedPass { + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } // Ensure current number and type of event is emitted suite.AssertEventEmitted(ctx, types.TypeMsgSetDenomMetadata, tc.expectedMessageEvents) }) diff --git a/x/twap/client/query_proto_wrap_test.go b/x/twap/client/query_proto_wrap_test.go index f19b9ec57ad..21bb73f471b 100644 --- a/x/twap/client/query_proto_wrap_test.go +++ b/x/twap/client/query_proto_wrap_test.go @@ -56,7 +56,7 @@ func (suite *QueryTestSuite) TestQueryTwap() { result string }{ { - name: "non-existant pool", + name: "non-existent pool", poolId: 0, baseAssetDenom: "tokenA", quoteAssetDenom: "tokenB", diff --git a/x/twap/listeners_test.go b/x/twap/listeners_test.go index 28f5bd1b3c7..928f2d166f3 100644 --- a/x/twap/listeners_test.go +++ b/x/twap/listeners_test.go @@ -238,7 +238,7 @@ func (s *TestSuite) TestEndBlock() { } } -// TestAfterEpochEnd tests if records get succesfully deleted via `AfterEpochEnd` hook. +// TestAfterEpochEnd tests if records get successfully deleted via `AfterEpochEnd` hook. // We test details of correct implementation of pruning method in store test. // Specifically, the newest record that is younger than the (current block time - record keep period) // is kept, and the rest are deleted. @@ -270,7 +270,8 @@ func (s *TestSuite) TestAfterEpochEnd() { // iterate through all epoch, ensure that epoch only gets pruned in prune epoch identifier // we reverse iterate here to test epochs that are not prune epoch for i := len(allEpochs) - 1; i >= 0; i-- { - s.App.TwapKeeper.EpochHooks().AfterEpochEnd(s.Ctx, allEpochs[i].Identifier, int64(1)) + err = s.App.TwapKeeper.EpochHooks().AfterEpochEnd(s.Ctx, allEpochs[i].Identifier, int64(1)) + s.Require().NoError(err) recordsAfterEpoch, err := s.twapkeeper.GetAllHistoricalTimeIndexedTWAPs(s.Ctx) diff --git a/x/twap/logic_test.go b/x/twap/logic_test.go index 0f1db4cb2a4..d65caebe3db 100644 --- a/x/twap/logic_test.go +++ b/x/twap/logic_test.go @@ -582,15 +582,15 @@ func (s *TestSuite) TestPruneRecords() { pool1OlderMin2MsRecord, // deleted pool2OlderMin1MsRecordAB, pool2OlderMin1MsRecordAC, pool2OlderMin1MsRecordBC, // deleted - pool3OlderBaseRecord, // kept as newest under keep period + pool3OlderBaseRecord, // kept as newest under keep period pool4OlderPlus1Record := // kept as newest under keep period - s.createTestRecordsFromTime(baseTime.Add(2 * -recordHistoryKeepPeriod)) + s.createTestRecordsFromTime(baseTime.Add(2 * -recordHistoryKeepPeriod)) pool1Min2MsRecord, // kept as newest under keep period pool2Min1MsRecordAB, pool2Min1MsRecordAC, pool2Min1MsRecordBC, // kept as newest under keep period - pool3BaseRecord, // kept as it is at the keep period boundary + pool3BaseRecord, // kept as it is at the keep period boundary pool4Plus1Record := // kept as it is above the keep period boundary - s.createTestRecordsFromTime(baseTime.Add(-recordHistoryKeepPeriod)) + s.createTestRecordsFromTime(baseTime.Add(-recordHistoryKeepPeriod)) // non-ascending insertion order. recordsToPreSet := []types.TwapRecord{ diff --git a/x/twap/migrate_test.go b/x/twap/migrate_test.go index 054169b48b9..3457d8102ee 100644 --- a/x/twap/migrate_test.go +++ b/x/twap/migrate_test.go @@ -32,6 +32,7 @@ func (s *TestSuite) TestMigrateExistingPools() { // iterate through all pools, check that all state entries have been correctly updated for poolId := 1; poolId <= int(latestPoolId); poolId++ { recentTwapRecords, err := s.twapkeeper.GetAllMostRecentRecordsForPool(s.Ctx, uint64(poolId)) + s.Require().NoError(err) poolDenoms, err := s.App.GAMMKeeper.GetPoolDenoms(s.Ctx, uint64(poolId)) s.Require().NoError(err) denomPairs := types.GetAllUniqueDenomPairs(poolDenoms) diff --git a/x/txfees/keeper/feedecorator_test.go b/x/txfees/keeper/feedecorator_test.go index 4c7515a3e83..53ce7b875cb 100644 --- a/x/txfees/keeper/feedecorator_test.go +++ b/x/txfees/keeper/feedecorator_test.go @@ -158,7 +158,8 @@ func (suite *KeeperTestSuite) TestFeeDecorator() { sdk.NewInt64Coin(sdk.DefaultBondDenom, 500), sdk.NewInt64Coin(uion, 500), ) - suite.ExecuteUpgradeFeeTokenProposal(uion, uionPoolId) + err := suite.ExecuteUpgradeFeeTokenProposal(uion, uionPoolId) + suite.Require().NoError(err) if tc.minGasPrices == nil { tc.minGasPrices = sdk.NewDecCoins() @@ -192,14 +193,15 @@ func (suite *KeeperTestSuite) TestFeeDecorator() { accSeqs[0], ) - simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, tc.txFee) + err = simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, tc.txFee) + suite.Require().NoError(err) tx := suite.BuildTx(txBuilder, msgs, sigV2, "", tc.txFee, gasLimit) mfd := keeper.NewMempoolFeeDecorator(*suite.App.TxFeesKeeper, mempoolFeeOpts) dfd := keeper.NewDeductFeeDecorator(*suite.App.TxFeesKeeper, *suite.App.AccountKeeper, *suite.App.BankKeeper, nil) antehandlerMFD := sdk.ChainAnteDecorators(mfd, dfd) - _, err := antehandlerMFD(suite.Ctx, tx, tc.isSimulate) + _, err = antehandlerMFD(suite.Ctx, tx, tc.isSimulate) if tc.expectPass { // ensure fee was collected diff --git a/x/txfees/keeper/feetokens_test.go b/x/txfees/keeper/feetokens_test.go index 76cfafeadc6..2577b5a33b1 100644 --- a/x/txfees/keeper/feetokens_test.go +++ b/x/txfees/keeper/feetokens_test.go @@ -212,7 +212,8 @@ func (suite *KeeperTestSuite) TestFeeTokenConversions() { tc.feeTokenPoolInput, ) - suite.ExecuteUpgradeFeeTokenProposal(tc.feeTokenPoolInput.Denom, poolId) + err := suite.ExecuteUpgradeFeeTokenProposal(tc.feeTokenPoolInput.Denom, poolId) + suite.Require().NoError(err) converted, err := suite.App.TxFeesKeeper.ConvertToBaseToken(suite.Ctx, tc.inputFee) if tc.expectedConvertable { diff --git a/x/txfees/keeper/hooks_test.go b/x/txfees/keeper/hooks_test.go index b719dc7c795..792c9fa04a1 100644 --- a/x/txfees/keeper/hooks_test.go +++ b/x/txfees/keeper/hooks_test.go @@ -22,7 +22,8 @@ func (suite *KeeperTestSuite) preparePool(denom string) (poolID uint64, pool poo ) pool, err := suite.App.GAMMKeeper.GetPoolAndPoke(suite.Ctx, poolID) suite.Require().NoError(err) - suite.ExecuteUpgradeFeeTokenProposal(denom, poolID) + err = suite.ExecuteUpgradeFeeTokenProposal(denom, poolID) + suite.Require().NoError(err) return poolID, pool } @@ -88,8 +89,10 @@ func (suite *KeeperTestSuite) TestTxFeesAfterEpochEnd() { // Deposit some fee amount (non-native-denom) to the fee module account _, _, addr0 := testdata.KeyTestPubAddr() - simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, sdk.Coins{coin}) - suite.App.BankKeeper.SendCoinsFromAccountToModule(suite.Ctx, addr0, types.NonNativeFeeCollectorName, sdk.Coins{coin}) + err = simapp.FundAccount(suite.App.BankKeeper, suite.Ctx, addr0, sdk.Coins{coin}) + suite.NoError(err) + err = suite.App.BankKeeper.SendCoinsFromAccountToModule(suite.Ctx, addr0, types.NonNativeFeeCollectorName, sdk.Coins{coin}) + suite.NoError(err) } // checks the balance of the non-native denom in module account @@ -99,7 +102,8 @@ func (suite *KeeperTestSuite) TestTxFeesAfterEpochEnd() { // End of epoch, so all the non-osmo fee amount should be swapped to osmo and transfer to fee module account params := suite.App.IncentivesKeeper.GetParams(suite.Ctx) futureCtx := suite.Ctx.WithBlockTime(time.Now().Add(time.Minute)) - suite.App.TxFeesKeeper.AfterEpochEnd(futureCtx, params.DistrEpochIdentifier, int64(1)) + err := suite.App.TxFeesKeeper.AfterEpochEnd(futureCtx, params.DistrEpochIdentifier, int64(1)) + suite.NoError(err) // check the balance of the native-basedenom in module moduleAddrFee := suite.App.AccountKeeper.GetModuleAddress(types.FeeCollectorName) diff --git a/x/valset-pref/keeper_test.go b/x/valset-pref/keeper_test.go index cd666f5f594..2abe4eac33c 100644 --- a/x/valset-pref/keeper_test.go +++ b/x/valset-pref/keeper_test.go @@ -69,7 +69,8 @@ func (suite *KeeperTestSuite) GetDelegationRewards(ctx sdk.Context, valAddrStr s return rewards, validator } -func (suite *KeeperTestSuite) SetupDelegationReward(ctx sdk.Context, delegator sdk.AccAddress, preferences []types.ValidatorPreference, existingValAddrStr string, setValSetDel, setExistingdel bool) { +func (suite *KeeperTestSuite) SetupDelegationReward(delegator sdk.AccAddress, preferences []types.ValidatorPreference, existingValAddrStr string, setValSetDel, setExistingdel bool) { + var ctx sdk.Context // incrementing the blockheight by 1 for reward ctx = suite.Ctx.WithBlockHeight(suite.Ctx.BlockHeight() + 1) diff --git a/x/valset-pref/msg_server_test.go b/x/valset-pref/msg_server_test.go index fc76a8469ae..74af977bc3f 100644 --- a/x/valset-pref/msg_server_test.go +++ b/x/valset-pref/msg_server_test.go @@ -420,7 +420,6 @@ func (suite *KeeperTestSuite) TestUnDelegateFromValidatorSet() { suite.Require().Equal(test.expectedShares[i], del.GetShares()) } } - } else { suite.Require().Error(err) } @@ -557,12 +556,12 @@ func (suite *KeeperTestSuite) TestRedelegateToValidatorSet() { suite.Require().NoError(err) } - // RedelegateValidatorSet redelegates from an exisitng set to a new one + // RedelegateValidatorSet redelegates from an existing set to a new one _, err := msgServer.RedelegateValidatorSet(c, types.NewMsgRedelegateValidatorSet(test.delegator, test.newPreferences)) if test.expectPass { suite.Require().NoError(err) - // check if the validator have recieved the correct amount of tokens + // check if the validator have received the correct amount of tokens for i, val := range test.newPreferences { valAddr, err := sdk.ValAddressFromBech32(val.ValOperAddress) suite.Require().NoError(err) @@ -627,7 +626,7 @@ func (suite *KeeperTestSuite) TestWithdrawDelegationRewards() { _, err = msgServer.DelegateToValidatorSet(c, types.NewMsgDelegateToValidatorSet(test.delegator, test.coinsToDelegate)) suite.Require().NoError(err) - suite.SetupDelegationReward(ctx, test.delegator, preferences, "", test.setValSetDelegation, test.setExistingDelegation) + suite.SetupDelegationReward(test.delegator, preferences, "", test.setValSetDelegation, test.setExistingDelegation) } // setup test for only existing staking position @@ -635,14 +634,14 @@ func (suite *KeeperTestSuite) TestWithdrawDelegationRewards() { err := suite.PrepareExistingDelegations(suite.Ctx, valAddrs, test.delegator, test.coinsToDelegate.Amount) suite.Require().NoError(err) - suite.SetupDelegationReward(ctx, test.delegator, nil, valAddrs[0], test.setValSetDelegation, test.setExistingDelegation) + suite.SetupDelegationReward(test.delegator, nil, valAddrs[0], test.setValSetDelegation, test.setExistingDelegation) } _, err := msgServer.WithdrawDelegationRewards(c, types.NewMsgWithdrawDelegationRewards(test.delegator)) if test.expectPass { suite.Require().NoError(err) - // the rewards for valset and exising delegations should be nil + // the rewards for valset and existing delegations should be nil if test.setValSetDelegation { for _, val := range preferences { rewardAfterWithdrawValSet, _ := suite.GetDelegationRewards(ctx, val.ValOperAddress, test.delegator) @@ -654,7 +653,6 @@ func (suite *KeeperTestSuite) TestWithdrawDelegationRewards() { rewardAfterWithdrawExistingSet, _ := suite.GetDelegationRewards(ctx, valAddrs[0], test.delegator) suite.Require().Nil(rewardAfterWithdrawExistingSet) } - } else { suite.Require().Error(err) }