Skip to content

Commit

Permalink
eliminate unnecessary type conversions from tests (#5115)
Browse files Browse the repository at this point in the history
* eliminate unnecessary type conversions from tests

* fix breakage of TestQueryTotalShares

* TestQueryBalancerPoolTotalLiquidity fix

* fix TestQueryBalancerPoolTotalLiquidity -- correct call
  • Loading branch information
faddat authored May 8, 2023
1 parent 5f21a77 commit 6e1b7a7
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 3 additions & 5 deletions tests/e2e/helpers_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions x/concentrated-liquidity/incentives_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}

Expand Down
2 changes: 1 addition & 1 deletion x/gamm/pool-models/balancer/pool_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions x/ibc-rate-limit/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x/superfluid/keeper/concentrated_liquidity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion x/superfluid/keeper/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion x/superfluid/keeper/unpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 6e1b7a7

Please sign in to comment.