mukan-ibc/modules/core/simulation/genesis.go
Mukan Erkin Törük 6852832fe8
Some checks failed
CodeQL / Analyze (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Tests / Code Coverage / build (amd64) (push) Waiting to run
Tests / Code Coverage / build (arm64) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[additional-args:-tags="test_e2e" name:e2e path:./e2e]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:08-wasm path:./modules/light-clients/08-wasm]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:ibc-go path:.]) (push) Waiting to run
Deploy to GitHub Pages / Deploy to GitHub Pages (push) Has been cancelled
Buf-Push / push (push) Has been cancelled
initial: sovereign Mukan Network fork
2026-05-11 03:18:28 +03:00

64 lines
2.1 KiB
Go

package simulation
// DONTCOVER
import (
"encoding/json"
"fmt"
"math/rand"
"github.com/cosmos/cosmos-sdk/types/module"
clientsims "github.com/cosmos/ibc-go/v10/modules/core/02-client/simulation"
clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types"
connectionsims "github.com/cosmos/ibc-go/v10/modules/core/03-connection/simulation"
connectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types"
channelsims "github.com/cosmos/ibc-go/v10/modules/core/04-channel/simulation"
channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
"github.com/cosmos/ibc-go/v10/modules/core/types"
)
// Simulation parameter constants
const (
clientGenesis = "client_genesis"
connectionGenesis = "connection_genesis"
channelGenesis = "channel_genesis"
)
// RandomizedGenState generates a random GenesisState for evidence
func RandomizedGenState(simState *module.SimulationState) {
var (
clientGenesisState clienttypes.GenesisState
connectionGenesisState connectiontypes.GenesisState
channelGenesisState channeltypes.GenesisState
)
simState.AppParams.GetOrGenerate(
clientGenesis, &clientGenesisState, simState.Rand,
func(r *rand.Rand) { clientGenesisState = clientsims.GenClientGenesis(r, simState.Accounts) },
)
simState.AppParams.GetOrGenerate(
connectionGenesis, &connectionGenesisState, simState.Rand,
func(r *rand.Rand) { connectionGenesisState = connectionsims.GenConnectionGenesis(r, simState.Accounts) },
)
simState.AppParams.GetOrGenerate(
channelGenesis, &channelGenesisState, simState.Rand,
func(r *rand.Rand) { channelGenesisState = channelsims.GenChannelGenesis(r, simState.Accounts) },
)
ibcGenesis := types.GenesisState{
ClientGenesis: clientGenesisState,
ConnectionGenesis: connectionGenesisState,
ChannelGenesis: channelGenesisState,
}
bz, err := json.MarshalIndent(&ibcGenesis, "", " ")
if err != nil {
panic(err)
}
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", ibcexported.ModuleName, bz)
simState.GenState[ibcexported.ModuleName] = simState.Cdc.MustMarshalJSON(&ibcGenesis)
}