cosmos-sdk/x/feegrant/simulation/genesis_test.go
Facundo Medica 78618dbfa0
fix: change SimulationState.InitialStake to sdkmath.Int (#11855)
* fix: change SimulationState.InitialStake to sdkmath.Int

* cl

* aleks' suggestion
2022-05-03 00:57:44 +02:00

42 lines
1.0 KiB
Go

package simulation_test
import (
"encoding/json"
"math/rand"
"testing"
"github.com/stretchr/testify/require"
sdkmath "cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant/simulation"
)
func TestRandomizedGenState(t *testing.T) {
app := simapp.Setup(t, false)
s := rand.NewSource(1)
r := rand.New(s)
accounts := simtypes.RandomAccounts(r, 3)
simState := module.SimulationState{
AppParams: make(simtypes.AppParams),
Cdc: app.AppCodec(),
Rand: r,
NumBonded: 3,
Accounts: accounts,
InitialStake: sdkmath.NewInt(1000),
GenState: make(map[string]json.RawMessage),
}
simulation.RandomizedGenState(&simState)
var feegrantGenesis feegrant.GenesisState
simState.Cdc.MustUnmarshalJSON(simState.GenState[feegrant.ModuleName], &feegrantGenesis)
require.Len(t, feegrantGenesis.Allowances, len(accounts)-1)
}