github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/modules/core/simulation/genesis_test.go (about) 1 package simulation_test 2 3 import ( 4 "encoding/json" 5 "math/rand" 6 "testing" 7 8 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/codec" 9 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types/module" 10 simtypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/simulation" 11 12 "github.com/stretchr/testify/require" 13 14 // "github.com/cosmos/cosmos-sdk/codec" 15 // codectypes "github.com/cosmos/cosmos-sdk/codec/types" 16 // "github.com/cosmos/cosmos-sdk/types/module" 17 // simtypes "github.com/cosmos/cosmos-sdk/types/simulation" 18 host "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/24-host" 19 "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/simulation" 20 "github.com/fibonacci-chain/fbc/libs/ibc-go/modules/core/types" 21 ) 22 23 // TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. 24 // Abonormal scenarios are not tested here. 25 func TestRandomizedGenState(t *testing.T) { 26 // interfaceRegistry := codectypes.NewInterfaceRegistry() 27 // cdc := codec.NewProtoCodec(interfaceRegistry) 28 cdc := codec.New() 29 30 s := rand.NewSource(1) 31 r := rand.New(s) 32 33 simState := module.SimulationState{ 34 AppParams: make(simtypes.AppParams), 35 Cdc: cdc, 36 Rand: r, 37 NumBonded: 3, 38 Accounts: simtypes.RandomAccounts(r, 3), 39 InitialStake: 1000, 40 GenState: make(map[string]json.RawMessage), 41 } 42 43 // Remark: the current RandomizedGenState function 44 // is actually not random as it does not utilize concretely the random value r. 45 // This tests will pass for any value of r. 46 simulation.RandomizedGenState(&simState) 47 48 var ibcGenesis types.GenesisState 49 simState.Cdc.MustUnmarshalJSON(simState.GenState[host.ModuleName], &ibcGenesis) 50 51 require.NotNil(t, ibcGenesis.ClientGenesis) 52 require.NotNil(t, ibcGenesis.ConnectionGenesis) 53 require.NotNil(t, ibcGenesis.ChannelGenesis) 54 }