From 6e1b7a727b2a4ad5b44b962423494bb6826e91ca Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Mon, 8 May 2023 20:02:06 +0700 Subject: [PATCH] eliminate unnecessary type conversions from tests (#5115) * eliminate unnecessary type conversions from tests * fix breakage of TestQueryTotalShares * TestQueryBalancerPoolTotalLiquidity fix * fix TestQueryBalancerPoolTotalLiquidity -- correct call --- tests/e2e/e2e_test.go | 4 ++-- tests/e2e/helpers_e2e_test.go | 8 +++----- x/concentrated-liquidity/incentives_test.go | 6 +++--- x/gamm/pool-models/balancer/pool_suite_test.go | 2 +- x/ibc-rate-limit/ibc_middleware_test.go | 10 +++++----- x/superfluid/keeper/concentrated_liquidity_test.go | 2 +- x/superfluid/keeper/migrate_test.go | 2 +- x/superfluid/keeper/unpool_test.go | 2 +- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index a1e6d81c546..01fa42c6e3d 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -730,7 +730,7 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() { } // if querying proposal takes longer than timeoutPeriod, stop the goroutine and error - timeoutPeriod := time.Duration(2 * time.Minute) + timeoutPeriod := 2 * time.Minute select { case <-time.After(timeoutPeriod): err := fmt.Errorf("go routine took longer than %s", timeoutPeriod) @@ -1438,7 +1438,7 @@ func (s *IntegrationTestSuite) TestExpeditedProposals() { } // if querying proposal takes longer than timeoutPeriod, stop the goroutine and error var elapsed time.Duration - timeoutPeriod := time.Duration(2 * time.Minute) + timeoutPeriod := 2 * time.Minute select { case elapsed = <-totalTimeChan: case <-time.After(timeoutPeriod): diff --git a/tests/e2e/helpers_e2e_test.go b/tests/e2e/helpers_e2e_test.go index 2ab08c8b121..78b37131c0b 100644 --- a/tests/e2e/helpers_e2e_test.go +++ b/tests/e2e/helpers_e2e_test.go @@ -8,9 +8,7 @@ import ( "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types" ) -var ( - defaultFeePerTx = sdk.NewInt(1000) -) +var defaultFeePerTx = sdk.NewInt(1000) // calculateFeeGrowthGlobal calculates fee growth global per unit of virtual liquidity based on swap parameters: // amountIn - amount being swapped @@ -84,6 +82,6 @@ func (s *IntegrationTestSuite) updatedPool(node *chain.NodeConfig, poolId uint64 // Assert returned positions: func (s *IntegrationTestSuite) validateCLPosition(position model.Position, poolId uint64, lowerTick, upperTick int64) { s.Require().Equal(position.PoolId, poolId) - s.Require().Equal(position.LowerTick, int64(lowerTick)) - s.Require().Equal(position.UpperTick, int64(upperTick)) + s.Require().Equal(position.LowerTick, lowerTick) + s.Require().Equal(position.UpperTick, upperTick) } diff --git a/x/concentrated-liquidity/incentives_test.go b/x/concentrated-liquidity/incentives_test.go index 987f990532e..ae7b8d54c22 100644 --- a/x/concentrated-liquidity/incentives_test.go +++ b/x/concentrated-liquidity/incentives_test.go @@ -372,17 +372,17 @@ func (s *KeeperTestSuite) TestGetUptimeAccumulatorName() { "pool id 1, uptime id 0": { poolId: defaultPoolId, uptimeIndex: uint64(0), - expectedAccumName: string(types.KeyUptimeAccumulator(1, 0)), + expectedAccumName: types.KeyUptimeAccumulator(1, 0), }, "pool id 1, uptime id 999": { poolId: defaultPoolId, uptimeIndex: uint64(999), - expectedAccumName: string(types.KeyUptimeAccumulator(1, 999)), + expectedAccumName: types.KeyUptimeAccumulator(1, 999), }, "pool id 999, uptime id 1": { poolId: uint64(999), uptimeIndex: uint64(1), - expectedAccumName: string(types.KeyUptimeAccumulator(999, 1)), + expectedAccumName: types.KeyUptimeAccumulator(999, 1), }, } diff --git a/x/gamm/pool-models/balancer/pool_suite_test.go b/x/gamm/pool-models/balancer/pool_suite_test.go index 13f0ad57ce1..0bc9051d7f2 100644 --- a/x/gamm/pool-models/balancer/pool_suite_test.go +++ b/x/gamm/pool-models/balancer/pool_suite_test.go @@ -1007,7 +1007,7 @@ func (suite *KeeperTestSuite) TestRandomizedJoinPoolExitPoolInvariants() { denomIn = "denomIn" ) - now := int64(time.Now().Unix()) + now := time.Now().Unix() rng := rand.NewSource(now) suite.T().Logf("Using random source of %d\n", now) diff --git a/x/ibc-rate-limit/ibc_middleware_test.go b/x/ibc-rate-limit/ibc_middleware_test.go index 541e0895c79..489b6378244 100644 --- a/x/ibc-rate-limit/ibc_middleware_test.go +++ b/x/ibc-rate-limit/ibc_middleware_test.go @@ -147,9 +147,9 @@ func (suite *MiddlewareTestSuite) TestInvalidReceiver() { 0, ) _, ack, _ := suite.FullSendBToA(msg) - suite.Require().Contains(string(ack), "error", + suite.Require().Contains(ack, "error", "acknowledgment is not an error") - suite.Require().Contains(string(ack), fmt.Sprintf("ABCI code: %d", types.ErrBadMessage.ABCICode()), + suite.Require().Contains(ack, fmt.Sprintf("ABCI code: %d", types.ErrBadMessage.ABCICode()), "acknowledgment error is not of the right type") } @@ -218,12 +218,12 @@ func (suite *MiddlewareTestSuite) AssertReceive(success bool, msg sdk.Msg) (stri _, ack, err := suite.FullSendBToA(msg) if success { suite.Require().NoError(err) - suite.Require().NotContains(string(ack), "error", + suite.Require().NotContains(ack, "error", "acknowledgment is an error") } else { - suite.Require().Contains(string(ack), "error", + suite.Require().Contains(ack, "error", "acknowledgment is not an error") - suite.Require().Contains(string(ack), fmt.Sprintf("ABCI code: %d", types.ErrRateLimitExceeded.ABCICode()), + suite.Require().Contains(ack, fmt.Sprintf("ABCI code: %d", types.ErrRateLimitExceeded.ABCICode()), "acknowledgment error is not of the right type") } return ack, err diff --git a/x/superfluid/keeper/concentrated_liquidity_test.go b/x/superfluid/keeper/concentrated_liquidity_test.go index 7b459bcf66f..933e8a2b540 100644 --- a/x/superfluid/keeper/concentrated_liquidity_test.go +++ b/x/superfluid/keeper/concentrated_liquidity_test.go @@ -247,7 +247,7 @@ func (suite *KeeperTestSuite) SetupSuperfluidConcentratedPosition(ctx sdk.Contex } // Set up a single validator. - valAddr = suite.SetupValidator(stakingtypes.BondStatus(stakingtypes.Bonded)) + valAddr = suite.SetupValidator(stakingtypes.Bonded) // Create a cl pool. clPool := suite.PrepareCustomConcentratedPool(poolCreateAcc, defaultPoolAssets[0].Token.Denom, defaultPoolAssets[1].Token.Denom, 1, sdk.ZeroDec()) diff --git a/x/superfluid/keeper/migrate_test.go b/x/superfluid/keeper/migrate_test.go index 153d7adf9bf..15c4592a127 100644 --- a/x/superfluid/keeper/migrate_test.go +++ b/x/superfluid/keeper/migrate_test.go @@ -736,7 +736,7 @@ func (suite *KeeperTestSuite) SetupMigrationTest(ctx sdk.Context, superfluidDele } // Set up a single validator. - valAddr = suite.SetupValidator(stakingtypes.BondStatus(stakingtypes.Bonded)) + valAddr = suite.SetupValidator(stakingtypes.Bonded) // Create a balancer pool of "stake" and "foo". msg := balancer.NewMsgCreateBalancerPool(poolCreateAcc, balancer.PoolParams{ diff --git a/x/superfluid/keeper/unpool_test.go b/x/superfluid/keeper/unpool_test.go index 601848da86d..917d515c273 100644 --- a/x/superfluid/keeper/unpool_test.go +++ b/x/superfluid/keeper/unpool_test.go @@ -108,7 +108,7 @@ func (suite *KeeperTestSuite) TestUnpool() { } // set up validator - valAddr := suite.SetupValidator(stakingtypes.BondStatus(stakingtypes.Bonded)) + valAddr := suite.SetupValidator(stakingtypes.Bonded) // create pool of "stake" and "foo" msg := balancer.NewMsgCreateBalancerPool(poolCreateAcc, balancer.PoolParams{