Files
cosmos-sdk/x/feegrant/simulation/genesis_test.go
T
Facundo MedicaandMarko a2000ffb0b refactor: Use mocks for x/feegrant testing (#12472)
* add expected keepers mocks

* progress

* progress

* progress

* more progress

* progress

* remove debug prints

* undo simulation changes

* revert some more stuff

* Update x/feegrant/keeper/keeper.go

Co-authored-by: Marko <marbar3778@yahoo.com>

Co-authored-by: Marko <marbar3778@yahoo.com>
2022-07-13 10:25:26 -03:00

42 lines
1.2 KiB
Go

package simulation_test
import (
"encoding/json"
"math/rand"
"testing"
"github.com/stretchr/testify/require"
sdkmath "cosmossdk.io/math"
moduletypes "github.com/cosmos/cosmos-sdk/types/module"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/feegrant"
"github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/feegrant/simulation"
)
func TestRandomizedGenState(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{})
s := rand.NewSource(1)
r := rand.New(s)
accounts := simtypes.RandomAccounts(r, 3)
simState := moduletypes.SimulationState{
AppParams: make(simtypes.AppParams),
Cdc: encCfg.Codec,
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)
}