Skip to content

Commit

Permalink
Add a unit test on the invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
0Tech committed Sep 1, 2023
1 parent e85305f commit a779379
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions x/collection/keeper/invariants_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package keeper_test

import (
sdk "github.com/Finschia/finschia-sdk/types"
"github.com/Finschia/finschia-sdk/x/collection/keeper"
)

func (s *KeeperTestSuite) TestTotalSupplyInvariant() {
testCases := map[string]struct {
malleate func(ctx sdk.Context)
valid bool
}{
"invariant not broken": {
valid: true,
},
}

for name, tc := range testCases {
s.Run(name, func() {
ctx, _ := s.ctx.CacheContext()
if tc.malleate != nil {
tc.malleate(ctx)
}

invariant := keeper.TotalFTSupplyInvariant(s.keeper)
_, broken := invariant(ctx)
s.Require().Equal(!tc.valid, broken)
})
}
}

0 comments on commit a779379

Please sign in to comment.