Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move x/{moduleName}/test{ModuleName} to x/{moduleName}/testutil #13427

Merged
merged 6 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* (x/slashing) [#13427](https://github.com/cosmos/cosmos-sdk/pull/13427) Move `x/slashing/testslashing` to `x/slashing/testutil` for consistency with other modules.
* (x/staking) [#13427](https://github.com/cosmos/cosmos-sdk/pull/13427) Move `x/staking/teststaking` to `x/staking/testutil` for consistency with other modules.
* (simapp) [#13402](https://github.com/cosmos/cosmos-sdk/pull/13402) Move simulation flags to `x/simulation/client/cli`.
* (simapp) [#13402](https://github.com/cosmos/cosmos-sdk/pull/13402) Move simulation helpers functions (`SetupSimulation`, `SimulationOperations`, `CheckExportSimulation`, `PrintStats`, `GetSimulationLog`) to `testutil/sims`.
* (simapp) [#13402](https://github.com/cosmos/cosmos-sdk/pull/13402) Move `testutil/rest` package to `testutil`.
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ func (suite *IntegrationTestSuite) SetupTest() {
suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
suite.fetchStoreKey = app.UnsafeFindStoreKey

// suite.Require().NoError(suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams()))
suite.Require().NoError(suite.bankKeeper.SetParams(suite.ctx, types.DefaultParams()))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to set params here, given that we use an app.


queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, interfaceRegistry)
types.RegisterQueryServer(queryHelper, suite.bankKeeper)
queryClient := types.NewQueryClient(queryHelper)
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/distribution/keeper/allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution/testutil"
disttypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -40,7 +40,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) {

addrs := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 3, sdk.NewInt(1234))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)

// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) {

addrs := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1234))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)

// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
Expand Down Expand Up @@ -179,7 +179,7 @@ func TestAllocateTokensTruncation(t *testing.T) {

addrs := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 3, sdk.NewInt(1234))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)

// create validator with 10% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(1, 1), sdk.NewDecWithPrec(1, 1), math.LegacyNewDec(0))
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/distribution/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution/testutil"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -38,7 +38,7 @@ func TestCalculateRewardsBasic(t *testing.T) {

distrKeeper.DeleteAllValidatorHistoricalRewards(ctx)

tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)

addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {

addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(100000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)

// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {

ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(100000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)

Expand Down Expand Up @@ -267,7 +267,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {

ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(100000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)

Expand Down Expand Up @@ -350,7 +350,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
balanceTokens := stakingKeeper.TokensFromConsensusPower(ctx, balancePower)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 1, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)

// set module account coins
distrAcc := distrKeeper.GetDistributionAccount(ctx)
Expand Down Expand Up @@ -431,7 +431,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {

addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 1, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)

// create validator with 50% commission
valPower := int64(100)
Expand Down Expand Up @@ -509,7 +509,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {

ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)

Expand Down Expand Up @@ -599,7 +599,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {

distrKeeper.DeleteAllValidatorHistoricalRewards(ctx)

tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
initial := int64(20)
Expand Down Expand Up @@ -758,7 +758,7 @@ func Test100PercentCommissionReward(t *testing.T) {

ctx := app.BaseApp.NewContext(false, tmproto.Header{})

tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
tstaking := stakingtestutil.NewHelper(t, ctx, stakingKeeper)
addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.NewInt(1000000000))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addr)
initial := int64(20)
Expand Down
6 changes: 2 additions & 4 deletions tests/integration/distribution/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand Down Expand Up @@ -60,8 +60,6 @@ func (suite *KeeperTestSuite) SetupTest() {

suite.addrs = simtestutil.AddTestAddrs(suite.bankKeeper, suite.stakingKeeper, ctx, 2, sdk.NewInt(1000000000))
suite.valAddrs = simtestutil.ConvertAddrsToValAddrs(suite.addrs)

suite.NoError(suite.distrKeeper.SetParams(suite.ctx, types.DefaultParams()))
suite.msgServer = keeper.NewMsgServerImpl(suite.distrKeeper)
}

Expand Down Expand Up @@ -362,7 +360,7 @@ func (suite *KeeperTestSuite) TestGRPCValidatorSlashes() {
func (suite *KeeperTestSuite) TestGRPCDelegationRewards() {
ctx, addrs, valAddrs := suite.ctx, suite.addrs, suite.valAddrs

tstaking := teststaking.NewHelper(suite.T(), ctx, suite.stakingKeeper)
tstaking := stakingtestutil.NewHelper(suite.T(), ctx, suite.stakingKeeper)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), math.LegacyNewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk0, sdk.NewInt(100), true)

Expand Down
24 changes: 7 additions & 17 deletions tests/integration/slashing/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,16 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/slashing/testslashing"
"github.com/cosmos/cosmos-sdk/x/slashing/testutil"
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"

authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
Expand Down Expand Up @@ -57,10 +54,8 @@ func (s *KeeperTestSuite) SetupTest() {

ctx := app.BaseApp.NewContext(false, tmproto.Header{})

s.accountKeeper.SetParams(ctx, authtypes.DefaultParams())
s.bankKeeper.SetParams(ctx, banktypes.DefaultParams())
s.slashingKeeper.SetParams(ctx, testslashing.TestParams())

// TestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500
s.slashingKeeper.SetParams(ctx, testutil.TestParams())
addrDels := simtestutil.AddTestAddrsIncremental(s.bankKeeper, s.stakingKeeper, ctx, 5, s.stakingKeeper.TokensFromConsensusPower(ctx, 200))

info1 := slashingtypes.NewValidatorSigningInfo(sdk.ConsAddress(addrDels[0]), int64(4), int64(3),
Expand Down Expand Up @@ -91,7 +86,7 @@ func (s *KeeperTestSuite) TestUnJailNotBonded() {
addrDels := simtestutil.AddTestAddrsIncremental(s.bankKeeper, s.stakingKeeper, ctx, 6, s.stakingKeeper.TokensFromConsensusPower(ctx, 200))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrDels)
pks := simtestutil.CreateTestPubKeys(6)
tstaking := teststaking.NewHelper(s.T(), ctx, s.stakingKeeper)
tstaking := stakingtestutil.NewHelper(s.T(), ctx, s.stakingKeeper)

// create max (5) validators all with the same power
for i := uint32(0); i < p.MaxValidators; i++ {
Expand Down Expand Up @@ -153,7 +148,7 @@ func (s *KeeperTestSuite) TestHandleNewValidator() {
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrDels)
pks := simtestutil.CreateTestPubKeys(1)
addr, val := valAddrs[0], pks[0]
tstaking := teststaking.NewHelper(s.T(), ctx, s.stakingKeeper)
tstaking := stakingtestutil.NewHelper(s.T(), ctx, s.stakingKeeper)
ctx = ctx.WithBlockHeight(s.slashingKeeper.SignedBlocksWindow(ctx) + 1)

// Validator created
Expand Down Expand Up @@ -192,15 +187,14 @@ func (s *KeeperTestSuite) TestHandleNewValidator() {
// Ensure that they're only slashed once
func (s *KeeperTestSuite) TestHandleAlreadyJailed() {
// initial setup

ctx := s.ctx

addrDels := simtestutil.AddTestAddrsIncremental(s.bankKeeper, s.stakingKeeper, ctx, 1, s.stakingKeeper.TokensFromConsensusPower(ctx, 200))
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrDels)
pks := simtestutil.CreateTestPubKeys(1)
addr, val := valAddrs[0], pks[0]
power := int64(100)
tstaking := teststaking.NewHelper(s.T(), ctx, s.stakingKeeper)
tstaking := stakingtestutil.NewHelper(s.T(), ctx, s.stakingKeeper)

amt := tstaking.CreateValidatorWithValPower(addr, val, power, true)

Expand Down Expand Up @@ -244,11 +238,7 @@ func (s *KeeperTestSuite) TestHandleAlreadyJailed() {
// the start height of the signing info is reset correctly
func (s *KeeperTestSuite) TestValidatorDippingInAndOut() {
// initial setup
// TestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500

ctx := s.ctx
s.slashingKeeper.SetParams(ctx, testslashing.TestParams())

params := s.stakingKeeper.GetParams(ctx)
params.MaxValidators = 1
s.stakingKeeper.SetParams(ctx, params)
Expand All @@ -259,7 +249,7 @@ func (s *KeeperTestSuite) TestValidatorDippingInAndOut() {

addr, val := pks[0].Address(), pks[0]
consAddr := sdk.ConsAddress(addr)
tstaking := teststaking.NewHelper(s.T(), ctx, s.stakingKeeper)
tstaking := stakingtestutil.NewHelper(s.T(), ctx, s.stakingKeeper)
valAddr := sdk.ValAddress(addr)

tstaking.CreateValidatorWithValPower(valAddr, val, power, true)
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/staking/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand Down Expand Up @@ -67,8 +67,8 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

val1 := teststaking.NewValidator(t, valAddrs[0], pks[0])
val2 := teststaking.NewValidator(t, valAddrs[1], pks[1])
val1 := testutil.NewValidator(t, valAddrs[0], pks[0])
val2 := testutil.NewValidator(t, valAddrs[1], pks[1])
vals := []types.Validator{val1, val2}

app.StakingKeeper.SetValidator(ctx, val1)
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/staking/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"cosmossdk.io/simapp"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
"github.com/cosmos/cosmos-sdk/x/staking/testutil"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -27,11 +27,11 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) {
bondDenom := app.StakingKeeper.BondDenom(ctx)
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)

require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(bondDenom, startTokens))))
require.NoError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(bondDenom, startTokens))))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)

// create a validator and a delegator to that validator
validator := teststaking.NewValidator(t, addrVals[0], PKs[0])
validator := testutil.NewValidator(t, addrVals[0], PKs[0])

validator, issuedShares := validator.AddTokensFromDel(startTokens)
require.Equal(t, startTokens, issuedShares.RoundInt())
Expand Down
18 changes: 0 additions & 18 deletions tests/integration/staking/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper_test
import (
"testing"

"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
Expand Down Expand Up @@ -54,23 +53,6 @@ func (suite *IntegrationTestSuite) SetupTest() {
suite.app, suite.ctx, suite.queryClient, suite.addrs, suite.vals = app, ctx, queryClient, addrs, validators
}

func TestParams(t *testing.T) {
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

expParams := types.DefaultParams()

// check that the empty keeper loads the default
resParams := app.StakingKeeper.GetParams(ctx)
require.True(t, expParams.Equal(resParams))

// modify a params, save, and retrieve
expParams.MaxValidators = 777
app.StakingKeeper.SetParams(ctx, expParams)
resParams = app.StakingKeeper.GetParams(ctx)
require.True(t, expParams.Equal(resParams))
}

func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}
27 changes: 27 additions & 0 deletions tests/integration/staking/keeper/params_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package keeper

import (
"testing"

"cosmossdk.io/simapp"
"github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)

func TestParams(t *testing.T) {
app := simapp.Setup(t, false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

expParams := types.DefaultParams()

// check that the empty keeper loads the default
resParams := app.StakingKeeper.GetParams(ctx)
require.True(t, expParams.Equal(resParams))

// modify a params, save, and retrieve
expParams.MaxValidators = 777
app.StakingKeeper.SetParams(ctx, expParams)
resParams = app.StakingKeeper.GetParams(ctx)
require.True(t, expParams.Equal(resParams))
}
Loading