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