github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/erc20/genesis_test.go (about)

     1  package erc20_test
     2  
     3  import (
     4  	"github.com/fibonacci-chain/fbc/x/erc20"
     5  	"github.com/fibonacci-chain/fbc/x/erc20/types"
     6  )
     7  
     8  func (suite *Erc20TestSuite) TestInitGenesis() {
     9  	testCases := []struct {
    10  		name     string
    11  		malleate func()
    12  		genState types.GenesisState
    13  		expPanic bool
    14  	}{
    15  		{
    16  			"default",
    17  			func() {},
    18  			types.DefaultGenesisState(),
    19  			false,
    20  		},
    21  		{
    22  			"Wrong denom in token mapping",
    23  			func() {},
    24  			types.GenesisState{
    25  				TokenMappings: []types.TokenMapping{
    26  					{
    27  						Denom:    "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865",
    28  						Contract: "0x0000000000000000000000000000000000000000",
    29  					},
    30  				},
    31  			},
    32  			true,
    33  		},
    34  		{
    35  			"Wrong denom in token mapping",
    36  			func() {},
    37  			types.GenesisState{
    38  				TokenMappings: []types.TokenMapping{
    39  					{
    40  						Denom:    "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865",
    41  						Contract: "0x0000000000000000000000000000000000000000",
    42  					},
    43  				},
    44  			},
    45  			true,
    46  		},
    47  		{
    48  			"Wrong contract in token mapping",
    49  			func() {},
    50  			types.GenesisState{
    51  				TokenMappings: []types.TokenMapping{
    52  					{
    53  						Denom:    "ibc/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865",
    54  						Contract: "0x00000000000000000000000000000000000000",
    55  					},
    56  				},
    57  			},
    58  			true,
    59  		},
    60  		{
    61  			"Wrong contract in token mapping",
    62  			func() {},
    63  			types.GenesisState{
    64  				TokenMappings: []types.TokenMapping{
    65  					{
    66  						Denom:    "ibc/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865",
    67  						Contract: "0x00000000000000000000000000000000000000",
    68  					},
    69  				},
    70  			},
    71  			true,
    72  		},
    73  		{
    74  			"Correct token mapping",
    75  			func() {},
    76  			types.GenesisState{
    77  				Params: types.DefaultParams(),
    78  				TokenMappings: []types.TokenMapping{
    79  					{
    80  						Denom:    "ibc/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865",
    81  						Contract: "0x0000000000000000000000000000000000000000",
    82  					},
    83  				},
    84  			},
    85  			false,
    86  		},
    87  	}
    88  
    89  	for _, tc := range testCases {
    90  		suite.Run(tc.name, func() {
    91  			tc.malleate()
    92  			if tc.expPanic {
    93  				suite.Require().Panics(
    94  					func() {
    95  						erc20.InitGenesis(suite.ctx, suite.app.Erc20Keeper, tc.genState)
    96  					},
    97  				)
    98  			} else {
    99  				suite.Require().NotPanics(
   100  					func() {
   101  						erc20.InitGenesis(suite.ctx, suite.app.Erc20Keeper, tc.genState)
   102  					},
   103  				)
   104  			}
   105  		})
   106  	}
   107  }
   108  
   109  func (suite *Erc20TestSuite) TestExportGenesis() {
   110  	genesisState := erc20.ExportGenesis(suite.ctx, suite.app.Erc20Keeper)
   111  	suite.Require().Equal(genesisState.Params.IbcTimeout, types.DefaultParams().IbcTimeout)
   112  	suite.Require().Equal(genesisState.Params.EnableAutoDeployment, types.DefaultParams().EnableAutoDeployment)
   113  }