Skip to content

Commit

Permalink
chore: add more tests + clean useless .env
Browse files Browse the repository at this point in the history
  • Loading branch information
kioqq committed Nov 23, 2023
1 parent 0d17288 commit c945041
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 36 deletions.
Empty file removed .env
Empty file.
120 changes: 84 additions & 36 deletions x/coinomics/keeper/mint_info_test.go
Original file line number Diff line number Diff line change
@@ -1,38 +1,86 @@
package keeper_test

// func (suite *KeeperTestSuite) TestSetGetPeriod() {
// expEra := uint64(9)

// testCases := []struct {
// name string
// malleate func()
// ok bool
// }{
// {
// "default era",
// func() {},
// false,
// },
// {
// "period set",
// func() {
// suite.app.CoinomicsKeeper.SetEra(suite.ctx, expEra)
// },
// true,
// },
// }
// for _, tc := range testCases {
// suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
// suite.SetupTest() // reset

// tc.malleate()

// period := suite.app.CoinomicsKeeper.GetEra(suite.ctx)
// if tc.ok {
// suite.Require().Equal(expEra, period, tc.name)
// } else {
// suite.Require().Zero(period, tc.name)
// }
// })
// }
// }
import (
"fmt"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (suite *KeeperTestSuite) TestSetGetPrevBlockTs() {
expEra := math.NewInt(100)

testCases := []struct {
name string
malleate func()
ok bool
}{
{
"default prevblockts",
func() {},
false,
},
{
"prevblockts set",
func() {
suite.app.CoinomicsKeeper.SetPrevBlockTS(suite.ctx, expEra)
},
true,
},
}
for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
suite.SetupTest() // reset

tc.malleate()

prevBlockTS := suite.app.CoinomicsKeeper.GetPrevBlockTS(suite.ctx)
if tc.ok {
suite.Require().Equal(expEra, prevBlockTS, tc.name)
} else {
suite.Require().Equal(sdk.ZeroInt(), prevBlockTS, tc.name)
}
})
}
}

func (suite *KeeperTestSuite) TestSetGetMaxSupply() {
defaultMaxSupply := sdk.Coin{Denom: "aISLM", Amount: math.NewIntWithDecimal(100_000_000_000, 18)}
expMaxSupply := sdk.Coin{Denom: "aISLM", Amount: math.NewIntWithDecimal(1337, 18)}

testCases := []struct {
name string
malleate func()
ok bool
}{
{
"default MaxSupply",
func() {},
false,
},
{
"MaxSupply set",
func() {
suite.app.CoinomicsKeeper.SetMaxSupply(suite.ctx, expMaxSupply)
},
true,
},
}
for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
suite.SetupTest() // reset

tc.malleate()

maxSupply := suite.app.CoinomicsKeeper.GetMaxSupply(suite.ctx)

fmt.Printf("maxSupply: %v\n testname: %v\n", maxSupply, tc.name)

if tc.ok {
suite.Require().Equal(expMaxSupply, maxSupply, tc.name)
} else {
suite.Require().Equal(defaultMaxSupply, maxSupply, tc.name)
}
})
}
}

0 comments on commit c945041

Please sign in to comment.