@@ -48,29 +48,6 @@ func (s *GenesisTestSuite) SetupTestWithChainID(chainID testconstants.ChainID) {
4848 })
4949}
5050
51- func (s * GenesisTestSuite ) adjustModuleBalance (expectedAmt sdkmath.Int ) {
52- moduleAddr := s .network .App .GetAccountKeeper ().GetModuleAddress (types .ModuleName )
53- balance := s .network .App .GetBankKeeper ().GetBalance (s .network .GetContext (), moduleAddr , types .IntegerCoinDenom ())
54-
55- if balance .Amount .GT (expectedAmt ) {
56- // Burn excess
57- err := s .network .App .GetBankKeeper ().BurnCoins (
58- s .network .GetContext (),
59- types .ModuleName ,
60- sdk .NewCoins (sdk .NewCoin (types .IntegerCoinDenom (), balance .Amount .Sub (expectedAmt ))),
61- )
62- s .Require ().NoError (err )
63- } else if balance .Amount .LT (expectedAmt ) {
64- // Mint deficit
65- err := s .network .App .GetBankKeeper ().MintCoins (
66- s .network .GetContext (),
67- types .ModuleName ,
68- sdk .NewCoins (sdk .NewCoin (types .IntegerCoinDenom (), expectedAmt .Sub (balance .Amount ))),
69- )
70- s .Require ().NoError (err )
71- }
72- }
73-
7451func (s * GenesisTestSuite ) TestInitGenesis () {
7552 tests := []struct {
7653 name string
@@ -93,9 +70,13 @@ func (s *GenesisTestSuite) TestInitGenesis() {
9370 {
9471 "valid - module balance matches non-zero amount" ,
9572 func () {
96- // The network setup creates an initial balance of 1, so we need to mint 1 more
97- // to get to the expected amount of 2 for this test case
98- s .adjustModuleBalance (sdkmath .NewInt (2 ))
73+ // Mint the expected amount of 2 integer coins to back the fractional balances
74+ err := s .network .App .GetBankKeeper ().MintCoins (
75+ s .network .GetContext (),
76+ types .ModuleName ,
77+ sdk .NewCoins (sdk .NewCoin (types .IntegerCoinDenom (), sdkmath .NewInt (2 ))),
78+ )
79+ s .Require ().NoError (err )
9980 },
10081 types .NewGenesisState (
10182 types.FractionalBalances {
@@ -123,9 +104,7 @@ func (s *GenesisTestSuite) TestInitGenesis() {
123104 {
124105 "invalid - module balance insufficient" ,
125106 func () {
126- // The network setup creates an initial balance of 1, so we need to burn that
127- // to get to 0 balance for this test case
128- s .adjustModuleBalance (sdkmath .ZeroInt ())
107+ // Module account starts with 0 balance (no setup needed)
129108 },
130109 types .NewGenesisState (
131110 types.FractionalBalances {
@@ -141,9 +120,13 @@ func (s *GenesisTestSuite) TestInitGenesis() {
141120 {
142121 "invalid - module balance excessive" ,
143122 func () {
144- // The network setup creates an initial balance of 1, so we need to mint 99 more
145- // to get to 100 total balance for this test case
146- s .adjustModuleBalance (sdkmath .NewInt (100 ))
123+ // Mint 100 integer coins (excessive for expected 2)
124+ err := s .network .App .GetBankKeeper ().MintCoins (
125+ s .network .GetContext (),
126+ types .ModuleName ,
127+ sdk .NewCoins (sdk .NewCoin (types .IntegerCoinDenom (), sdkmath .NewInt (100 ))),
128+ )
129+ s .Require ().NoError (err )
147130 },
148131 types .NewGenesisState (
149132 types.FractionalBalances {
@@ -242,8 +225,13 @@ func (s *GenesisTestSuite) TestExportGenesis() {
242225 {
243226 "balances, no remainder" ,
244227 func () * types.GenesisState {
245- // Burn the initial balance created by network setup, then mint the expected amount
246- s .adjustModuleBalance (sdkmath .NewInt (1 ))
228+ // Mint the expected amount to back the fractional balances
229+ err := s .network .App .GetBankKeeper ().MintCoins (
230+ s .network .GetContext (),
231+ types .ModuleName ,
232+ sdk .NewCoins (sdk .NewCoin (types .IntegerCoinDenom (), sdkmath .NewInt (1 ))),
233+ )
234+ s .Require ().NoError (err )
247235
248236 return types .NewGenesisState (
249237 types.FractionalBalances {
@@ -257,8 +245,13 @@ func (s *GenesisTestSuite) TestExportGenesis() {
257245 {
258246 "balances, remainder" ,
259247 func () * types.GenesisState {
260- // Burn the initial balance created by network setup, then mint the expected amount
261- s .adjustModuleBalance (sdkmath .NewInt (1 ))
248+ // Mint the expected amount to back the fractional balances
249+ err := s .network .App .GetBankKeeper ().MintCoins (
250+ s .network .GetContext (),
251+ types .ModuleName ,
252+ sdk .NewCoins (sdk .NewCoin (types .IntegerCoinDenom (), sdkmath .NewInt (1 ))),
253+ )
254+ s .Require ().NoError (err )
262255
263256 return types .NewGenesisState (
264257 types.FractionalBalances {
0 commit comments