Unverified Commit 1f8327e3 authored by mconcat's avatar mconcat Committed by GitHub
Browse files

Gas test to work with maximum amount (#839)

* gas test Equal -> Less

* Less -> LessOrEqual

* add error margin on max limit
parent 33ec9921
Showing with 9 additions and 9 deletions
+9 -9
......@@ -71,7 +71,7 @@ func (suite *KeeperTestSuite) TestJoinPoolGas() {
suite.Require().NoError(err)
firstJoinGas := suite.measureJoinPoolGas(defaultAddr, poolId, minShareOutAmount, defaultCoins)
suite.Assert().Equal(74604, int(firstJoinGas))
suite.Assert().LessOrEqual(int(firstJoinGas), 100000)
for i := 1; i < startAveragingAt; i++ {
err := suite.app.GAMMKeeper.JoinPool(suite.ctx, defaultAddr, poolId, minShareOutAmount, sdk.Coins{})
......@@ -80,8 +80,8 @@ func (suite *KeeperTestSuite) TestJoinPoolGas() {
avgGas, maxGas := suite.measureAvgAndMaxJoinPoolGas(totalNumJoins, defaultAddr, poolIDFn, minShareOutAmountFn, maxCoinsFn)
fmt.Printf("test deets: total %d of pools joined, begin average at %d\n", totalNumJoins, startAveragingAt)
suite.Assert().Equal(76119, int(avgGas), "average gas / join pool")
suite.Assert().Equal(76218, int(maxGas), "max gas / join pool")
suite.Assert().LessOrEqual(int(avgGas), 100000, "average gas / join pool")
suite.Assert().LessOrEqual(int(maxGas), 100000, "max gas / join pool")
}
func (suite *KeeperTestSuite) TestRepeatedJoinPoolDistinctDenom() {
......@@ -143,5 +143,5 @@ func (suite *KeeperTestSuite) TestRepeatedJoinPoolDistinctDenom() {
lastJoinGas := suite.measureJoinPoolGas(defaultAddr, lastPoolId, minShareOutAmount, defaultCoins)
gasIncrease := lastJoinGas - firstJoinGas
suite.Require().Less(gasIncrease, uint64(2000))
suite.Require().LessOrEqual(gasIncrease, uint64(5000))
}
......@@ -56,15 +56,15 @@ func (suite *KeeperTestSuite) TestRepeatedLockTokensGas() {
totalNumLocks := 10000
firstLockGasAmount := suite.measureLockGas(defaultAddr, defaultCoins, time.Second)
suite.Assert().Equal(87871, int(firstLockGasAmount))
suite.Assert().LessOrEqual(int(firstLockGasAmount), 100000)
for i := 1; i < startAveragingAt; i++ {
suite.LockTokens(defaultAddr, defaultCoins, time.Second)
}
avgGas, maxGas := suite.measureAvgAndMaxLockGas(totalNumLocks-startAveragingAt, defaultAddr, coinsFn, durFn)
fmt.Printf("test deets: total locks created %d, begin average at %d\n", totalNumLocks, startAveragingAt)
suite.Assert().Equal(75074, int(avgGas), "average gas / lock")
suite.Assert().Equal(75164, int(maxGas), "max gas / lock")
suite.Assert().LessOrEqual(int(avgGas), 100000, "average gas / lock")
suite.Assert().LessOrEqual(int(maxGas), 100000, "max gas / lock")
}
func (suite *KeeperTestSuite) TestRepeatedLockTokensDistinctDurationGas() {
......@@ -76,6 +76,6 @@ func (suite *KeeperTestSuite) TestRepeatedLockTokensDistinctDurationGas() {
avgGas, maxGas := suite.measureAvgAndMaxLockGas(totalNumLocks, defaultAddr, coinsFn, durFn)
fmt.Printf("test deets: total locks created %d\n", totalNumLocks)
suite.Assert().EqualValues(125249, int(avgGas), "average gas / lock")
suite.Assert().EqualValues(254947, int(maxGas), "max gas / lock")
suite.Assert().LessOrEqual(int(avgGas), 150000, "average gas / lock")
suite.Assert().LessOrEqual(int(maxGas), 300000, "max gas / lock")
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment