Some checks failed
CodeQL / Analyze (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
Docker Build & Push Simapp (main) / docker-build (push) Has been cancelled
70 lines
2.1 KiB
Go
70 lines
2.1 KiB
Go
package simulation
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"math/rand"
|
|
|
|
"git.cw.tr/mukan-network/mukan-sdk/types/module"
|
|
|
|
controllertypes "git.cw.tr/mukan-network/mukan-ibc/modules/apps/27-interchain-accounts/controller/types"
|
|
genesistypes "git.cw.tr/mukan-network/mukan-ibc/modules/apps/27-interchain-accounts/genesis/types"
|
|
hosttypes "git.cw.tr/mukan-network/mukan-ibc/modules/apps/27-interchain-accounts/host/types"
|
|
"git.cw.tr/mukan-network/mukan-ibc/modules/apps/27-interchain-accounts/types"
|
|
)
|
|
|
|
// RandomEnabled randomized controller or host enabled param with 75% prob of being true.
|
|
func RandomEnabled(r *rand.Rand) bool {
|
|
return r.Int63n(101) <= 75
|
|
}
|
|
|
|
// RandomizedGenState generates a random GenesisState for ics27.
|
|
// Only the params are non nil
|
|
func RandomizedGenState(simState *module.SimulationState) {
|
|
var controllerEnabled bool
|
|
simState.AppParams.GetOrGenerate(
|
|
string(controllertypes.KeyControllerEnabled), &controllerEnabled, simState.Rand,
|
|
func(r *rand.Rand) { controllerEnabled = RandomEnabled(r) },
|
|
)
|
|
|
|
controllerParams := controllertypes.Params{
|
|
ControllerEnabled: controllerEnabled,
|
|
}
|
|
|
|
controllerGenesisState := genesistypes.ControllerGenesisState{
|
|
ActiveChannels: nil,
|
|
InterchainAccounts: nil,
|
|
Ports: []string{},
|
|
Params: controllerParams,
|
|
}
|
|
|
|
var hostEnabled bool
|
|
simState.AppParams.GetOrGenerate(
|
|
string(hosttypes.KeyHostEnabled), &hostEnabled, simState.Rand,
|
|
func(r *rand.Rand) { hostEnabled = RandomEnabled(r) },
|
|
)
|
|
|
|
hostParams := hosttypes.Params{
|
|
HostEnabled: hostEnabled,
|
|
AllowMessages: []string{"*"}, // allow all messages
|
|
}
|
|
|
|
hostGenesisState := genesistypes.HostGenesisState{
|
|
ActiveChannels: nil,
|
|
InterchainAccounts: nil,
|
|
Port: types.HostPortID,
|
|
Params: hostParams,
|
|
}
|
|
|
|
icaGenesis := genesistypes.GenesisState{
|
|
ControllerGenesisState: controllerGenesisState,
|
|
HostGenesisState: hostGenesisState,
|
|
}
|
|
|
|
bz, err := json.MarshalIndent(&icaGenesis, "", " ")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz)
|
|
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&icaGenesis)
|
|
}
|