Skip to content

Commit

Permalink
fix genesis test
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 committed Feb 8, 2024
1 parent cb177b2 commit 253b275
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions x/collection/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func DefaultGenesisState() *GenesisState {
DepthLimit: DefaultDepthLimit,
WidthLimit: DefaultWidthLimit,
},
ClassState: &ClassState{
Nonce: cmath.ZeroUint(),
},
}
}

Expand Down
15 changes: 8 additions & 7 deletions x/collection/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ import (
"github.com/Finschia/finschia-sdk/x/collection"
)

// TODO: Add more test cases
func (s *KeeperTestSuite) TestImportExportGenesis() {
// export
genesis := s.keeper.ExportGenesis(s.ctx)

// forge
// forge & import
ctx, _ := s.ctx.CacheContext()
amount := collection.NewCoins(collection.NewFTCoin(s.ftClassID, s.balance))
err := s.keeper.SendCoins(s.ctx, s.contractID, s.vendor, s.customer, amount)
err := s.keeper.SendCoins(ctx, s.contractID, s.vendor, s.customer, amount)
s.Require().NoError(err)

err = s.keeper.SendCoins(s.ctx, s.contractID, s.customer, s.operator, amount)
err = s.keeper.SendCoins(ctx, s.contractID, s.customer, s.operator, amount)
s.Require().NoError(err)

_, err = s.keeper.BurnCoins(s.ctx, s.contractID, s.operator, amount)
_, err = s.keeper.BurnCoins(ctx, s.contractID, s.operator, amount)
s.Require().NoError(err)

s.keeper.Abandon(s.ctx, s.contractID, s.vendor, collection.PermissionMint)
s.keeper.Abandon(ctx, s.contractID, s.vendor, collection.PermissionMint)

// restore
s.keeper.InitGenesis(s.ctx, genesis)
s.keeper.InitGenesis(ctx, genesis)

// export again and compare
newGenesis := s.keeper.ExportGenesis(s.ctx)
Expand Down

0 comments on commit 253b275

Please sign in to comment.