From 23e864bc987e61af84763d9a3e531707f9dfbc84 Mon Sep 17 00:00:00 2001 From: MD Aleem <72057206+aleem1314@users.noreply.github.com> Date: Tue, 17 Aug 2021 06:22:06 +0530 Subject: [PATCH] refactor(test)!: refactor `simapp.Setup` function (#9938) ## Description ref: #8961 Following up on [#9697](https://github.com/cosmos/cosmos-sdk/pull/9697#pullrequestreview-727295733), this PR is the first step for the #8961. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- CHANGELOG.md | 2 + server/grpc/server_test.go | 2 +- simapp/test_helpers.go | 8 +- types/query/filtered_pagination_test.go | 9 ++- types/query/pagination_test.go | 12 +-- x/auth/ante/sigverify_test.go | 2 +- x/auth/ante/testutil_test.go | 6 +- x/auth/keeper/integration_test.go | 6 +- x/auth/keeper/keeper_bench_test.go | 4 +- x/auth/keeper/keeper_test.go | 10 +-- x/auth/keeper/querier_test.go | 2 +- x/auth/migrations/v043/store_test.go | 2 +- x/auth/module_test.go | 2 +- x/auth/signing/verify_test.go | 6 +- x/auth/simulation/decoder_test.go | 2 +- x/auth/types/account_test.go | 2 + x/auth/types/common_test.go | 1 - x/auth/vesting/types/common_test.go | 9 --- x/auth/vesting/types/vesting_account_test.go | 77 ++++++++++++++------ x/authz/keeper/genesis_test.go | 2 +- x/authz/keeper/keeper_test.go | 2 +- x/authz/simulation/genesis_test.go | 2 +- x/authz/simulation/operations_test.go | 2 +- x/bank/keeper/keeper_test.go | 2 +- x/bank/simulation/operations_test.go | 2 +- x/bank/types/send_authorization_test.go | 2 +- x/capability/capability_test.go | 2 +- x/capability/keeper/keeper_test.go | 2 +- x/crisis/keeper/keeper_test.go | 6 +- x/distribution/keeper/allocation_test.go | 6 +- x/distribution/keeper/delegation_test.go | 18 ++--- x/distribution/keeper/grpc_query_test.go | 2 +- x/distribution/keeper/keeper_test.go | 8 +- x/distribution/keeper/querier_test.go | 2 +- x/distribution/module_test.go | 2 +- x/distribution/proposal_handler_test.go | 4 +- x/distribution/simulation/operations_test.go | 2 +- x/distribution/simulation/proposals_test.go | 2 +- x/evidence/genesis_test.go | 2 +- x/evidence/keeper/keeper_test.go | 2 +- x/evidence/simulation/decoder_test.go | 2 +- x/feegrant/basic_fee_test.go | 2 +- x/feegrant/grant_test.go | 2 +- x/feegrant/keeper/genesis_test.go | 2 +- x/feegrant/keeper/keeper_test.go | 2 +- x/feegrant/periodic_fee_test.go | 2 +- x/feegrant/simulation/genesis_test.go | 2 +- x/feegrant/simulation/operations_test.go | 2 +- x/genutil/gentx_test.go | 2 +- x/gov/abci_test.go | 12 +-- x/gov/genesis_test.go | 6 +- x/gov/keeper/deposit_test.go | 2 +- x/gov/keeper/hooks_test.go | 2 +- x/gov/keeper/keeper_test.go | 6 +- x/gov/keeper/querier_test.go | 4 +- x/gov/keeper/tally_test.go | 30 ++++---- x/gov/keeper/vote_test.go | 2 +- x/gov/module_test.go | 2 +- x/gov/simulation/operations_test.go | 14 ++-- x/mint/keeper/grpc_query_test.go | 2 +- x/mint/keeper/integration_test.go | 6 +- x/mint/keeper/querier_test.go | 8 +- x/mint/module_test.go | 2 +- x/params/keeper/keeper_test.go | 11 +-- x/params/proposal_handler_test.go | 2 +- x/slashing/abci_test.go | 2 +- x/slashing/genesis_test.go | 2 +- x/slashing/keeper/grpc_query_test.go | 2 +- x/slashing/keeper/keeper_test.go | 8 +- x/slashing/keeper/querier_test.go | 4 +- x/slashing/keeper/signing_info_test.go | 8 +- x/slashing/simulation/operations_test.go | 8 +- x/staking/common_test.go | 5 +- x/staking/genesis_test.go | 10 +-- x/staking/keeper/common_test.go | 4 +- x/staking/keeper/delegation_test.go | 30 ++++---- x/staking/keeper/historical_info_test.go | 6 +- x/staking/keeper/keeper_test.go | 4 +- x/staking/keeper/querier_test.go | 16 ++-- x/staking/keeper/slash_test.go | 2 +- x/staking/keeper/validator_test.go | 2 +- x/staking/module_test.go | 2 +- x/staking/simulation/operations_test.go | 16 ++-- x/staking/types/authz_test.go | 2 +- x/upgrade/client/testutil/suite.go | 2 +- x/upgrade/keeper/grpc_query_test.go | 2 +- x/upgrade/keeper/keeper_test.go | 2 +- 87 files changed, 264 insertions(+), 242 deletions(-) delete mode 100644 x/auth/vesting/types/common_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 061baa2e7..a1f181f6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#9576](https://github.com/cosmos/cosmos-sdk/pull/9576) Add debug error message to `sdkerrors.QueryResult` when enabled * [\#9650](https://github.com/cosmos/cosmos-sdk/pull/9650) Removed deprecated message handler implementation from the SDK modules. * (x/bank) [\#9832] (https://github.com/cosmos/cosmos-sdk/pull/9832) `AddressFromBalancesStore` renamed to `AddressAndDenomFromBalancesStore`. +* (tests) [\#9938](https://github.com/cosmos/cosmos-sdk/pull/9938) `simapp.Setup` accepts additional `testing.T` argument. + ### Client Breaking Changes diff --git a/server/grpc/server_test.go b/server/grpc/server_test.go index 9867f9d08..3a4afd45b 100644 --- a/server/grpc/server_test.go +++ b/server/grpc/server_test.go @@ -45,7 +45,7 @@ type IntegrationTestSuite struct { func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") - s.app = simapp.Setup(false) + s.app = simapp.Setup(s.T(), false) s.cfg = network.DefaultConfig() s.cfg.NumValidators = 1 diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 8d7548e10..722fc2b14 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -61,14 +61,14 @@ func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { } // Setup initializes a new SimApp. A Nop logger is set in SimApp. -func Setup(isCheckTx bool) *SimApp { +func Setup(t *testing.T, isCheckTx bool) *SimApp { + t.Helper() + app, genesisState := setup(!isCheckTx, 5) if !isCheckTx { // init chain must be called to stop deliverState from being nil stateBytes, err := json.MarshalIndent(genesisState, "", " ") - if err != nil { - panic(err) - } + require.NoError(t, err) // Initialize the chain app.InitChain( diff --git a/types/query/filtered_pagination_test.go b/types/query/filtered_pagination_test.go index 01228571b..49bfe3486 100644 --- a/types/query/filtered_pagination_test.go +++ b/types/query/filtered_pagination_test.go @@ -2,6 +2,7 @@ package query_test import ( "fmt" + "testing" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -15,7 +16,7 @@ import ( var addr1 = sdk.AccAddress([]byte("addr1")) func (s *paginationTestSuite) TestFilteredPaginations() { - app, ctx, appCodec := setupTest() + app, ctx, appCodec := setupTest(s.T()) var balances sdk.Coins for i := 0; i < numBalances; i++ { @@ -90,7 +91,7 @@ func (s *paginationTestSuite) TestFilteredPaginations() { } func (s *paginationTestSuite) TestReverseFilteredPaginations() { - app, ctx, appCodec := setupTest() + app, ctx, appCodec := setupTest(s.T()) var balances sdk.Coins for i := 0; i < numBalances; i++ { @@ -170,8 +171,8 @@ func (s *paginationTestSuite) TestReverseFilteredPaginations() { } -func ExampleFilteredPaginate() { - app, ctx, _ := setupTest() +func ExampleFilteredPaginate(t *testing.T) { + app, ctx, _ := setupTest(t) var balances sdk.Coins for i := 0; i < numBalances; i++ { diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index efbb0fca1..784ebd5a5 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -61,7 +61,7 @@ func (s *paginationTestSuite) TestParsePagination() { } func (s *paginationTestSuite) TestPagination() { - app, ctx, _ := setupTest() + app, ctx, _ := setupTest(s.T()) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, app.BankKeeper) queryClient := types.NewQueryClient(queryHelper) @@ -170,7 +170,7 @@ func (s *paginationTestSuite) TestPagination() { } func (s *paginationTestSuite) TestReversePagination() { - app, ctx, _ := setupTest() + app, ctx, _ := setupTest(s.T()) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, app.BankKeeper) queryClient := types.NewQueryClient(queryHelper) @@ -293,8 +293,8 @@ func (s *paginationTestSuite) TestReversePagination() { s.Require().Nil(res.Pagination.NextKey) } -func ExamplePaginate() { - app, ctx, _ := setupTest() +func ExamplePaginate(t *testing.T) { + app, ctx, _ := setupTest(t) var balances sdk.Coins @@ -335,8 +335,8 @@ func ExamplePaginate() { // balances: pagination: } -func setupTest() (*simapp.SimApp, sdk.Context, codec.Codec) { - app := simapp.Setup(false) +func setupTest(t *testing.T) (*simapp.SimApp, sdk.Context, codec.Codec) { + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) appCodec := app.AppCodec() diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index 0ddd2d226..074f4c33a 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -192,7 +192,7 @@ func (suite *AnteTestSuite) TestSigVerification() { // In the meantime, we want to make double-sure amino compatibility works. // ref: https://github.com/cosmos/cosmos-sdk/issues/7229 func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { - suite.app, suite.ctx = createTestApp(true) + suite.app, suite.ctx = createTestApp(suite.T(), true) suite.ctx = suite.ctx.WithBlockHeight(1) // Set up TxConfig. diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index 74216420e..15598b3b2 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -41,8 +41,8 @@ type AnteTestSuite struct { } // returns context and app with params set on account keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) +func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) @@ -51,7 +51,7 @@ func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { // SetupTest setups a new test, with new app, context, and anteHandler. func (suite *AnteTestSuite) SetupTest(isCheckTx bool) { - suite.app, suite.ctx = createTestApp(isCheckTx) + suite.app, suite.ctx = createTestApp(suite.T(), isCheckTx) suite.ctx = suite.ctx.WithBlockHeight(1) // Set up TxConfig. diff --git a/x/auth/keeper/integration_test.go b/x/auth/keeper/integration_test.go index d2069d6d3..cbb9223b6 100644 --- a/x/auth/keeper/integration_test.go +++ b/x/auth/keeper/integration_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + "testing" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" @@ -9,8 +11,8 @@ import ( ) // returns context and app with params set on account keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) +func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) diff --git a/x/auth/keeper/keeper_bench_test.go b/x/auth/keeper/keeper_bench_test.go index 3e15783d9..5c25bf11c 100644 --- a/x/auth/keeper/keeper_bench_test.go +++ b/x/auth/keeper/keeper_bench_test.go @@ -8,7 +8,7 @@ import ( func BenchmarkAccountMapperGetAccountFound(b *testing.B) { b.ReportAllocs() - app, ctx := createTestApp(false) + app, ctx := createTestApp(&testing.T{}, false) // assumes b.N < 2**24 for i := 0; i < b.N; i++ { @@ -27,7 +27,7 @@ func BenchmarkAccountMapperGetAccountFound(b *testing.B) { func BenchmarkAccountMapperSetAccount(b *testing.B) { b.ReportAllocs() - app, ctx := createTestApp(false) + app, ctx := createTestApp(&testing.T{}, false) b.ResetTimer() diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index 7b9cd99c3..9121b6929 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -34,7 +34,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - suite.app, suite.ctx = createTestApp(true) + suite.app, suite.ctx = createTestApp(suite.T(), true) queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) types.RegisterQueryServer(queryHelper, suite.app.AccountKeeper) @@ -46,7 +46,7 @@ func TestKeeperTestSuite(t *testing.T) { } func TestAccountMapperGetSet(t *testing.T) { - app, ctx := createTestApp(true) + app, ctx := createTestApp(t, true) addr := sdk.AccAddress([]byte("some---------address")) // no account before its created @@ -76,7 +76,7 @@ func TestAccountMapperGetSet(t *testing.T) { } func TestAccountMapperRemoveAccount(t *testing.T) { - app, ctx := createTestApp(true) + app, ctx := createTestApp(t, true) addr1 := sdk.AccAddress([]byte("addr1---------------")) addr2 := sdk.AccAddress([]byte("addr2---------------")) @@ -109,7 +109,7 @@ func TestAccountMapperRemoveAccount(t *testing.T) { } func TestGetSetParams(t *testing.T) { - app, ctx := createTestApp(true) + app, ctx := createTestApp(t, true) params := types.DefaultParams() app.AccountKeeper.SetParams(ctx, params) @@ -119,7 +119,7 @@ func TestGetSetParams(t *testing.T) { } func TestSupply_ValidatePermissions(t *testing.T) { - app, _ := createTestApp(true) + app, _ := createTestApp(t, true) // add module accounts to supply keeper maccPerms := simapp.GetMaccPerms() diff --git a/x/auth/keeper/querier_test.go b/x/auth/keeper/querier_test.go index b64f971b3..fb5b4e9f5 100644 --- a/x/auth/keeper/querier_test.go +++ b/x/auth/keeper/querier_test.go @@ -16,7 +16,7 @@ import ( ) func TestQueryAccount(t *testing.T) { - app, ctx := createTestApp(true) + app, ctx := createTestApp(t, true) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) req := abci.RequestQuery{ diff --git a/x/auth/migrations/v043/store_test.go b/x/auth/migrations/v043/store_test.go index bb2cdfdee..cae87b968 100644 --- a/x/auth/migrations/v043/store_test.go +++ b/x/auth/migrations/v043/store_test.go @@ -549,7 +549,7 @@ func TestMigrateVestingAccounts(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{ Time: time.Now(), }) diff --git a/x/auth/module_test.go b/x/auth/module_test.go index 0bf268ddb..8e4c270d5 100644 --- a/x/auth/module_test.go +++ b/x/auth/module_test.go @@ -12,7 +12,7 @@ import ( ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( diff --git a/x/auth/signing/verify_test.go b/x/auth/signing/verify_test.go index 4bff68ffb..7a7f015db 100644 --- a/x/auth/signing/verify_test.go +++ b/x/auth/signing/verify_test.go @@ -29,7 +29,7 @@ func TestVerifySignature(t *testing.T) { chainId = "test-chain" ) - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) ctx = ctx.WithBlockHeight(1) cdc := codec.NewLegacyAmino() @@ -97,8 +97,8 @@ func TestVerifySignature(t *testing.T) { } // returns context and app with params set on account keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) +func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, types.DefaultParams()) diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index ee78c511d..c79f5c459 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -21,7 +21,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) cdc := simapp.MakeTestEncodingConfig().Codec acc := types.NewBaseAccountWithAddress(delAddr1) dec := simulation.NewDecodeStore(app.AccountKeeper) diff --git a/x/auth/types/account_test.go b/x/auth/types/account_test.go index 033b1c3ef..45dc460f6 100644 --- a/x/auth/types/account_test.go +++ b/x/auth/types/account_test.go @@ -10,6 +10,7 @@ import ( yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -59,6 +60,7 @@ func TestBaseSequence(t *testing.T) { } func TestBaseAccountMarshal(t *testing.T) { + app := simapp.Setup(t, false) _, pub, addr := testdata.KeyTestPubAddr() acc := types.NewBaseAccountWithAddress(addr) seq := uint64(7) diff --git a/x/auth/types/common_test.go b/x/auth/types/common_test.go index 6c045029f..c47914fc9 100644 --- a/x/auth/types/common_test.go +++ b/x/auth/types/common_test.go @@ -5,7 +5,6 @@ import ( ) var ( - app = simapp.Setup(false) ecdc = simapp.MakeTestEncodingConfig() appCodec, legacyAmino = ecdc.Codec, ecdc.Amino ) diff --git a/x/auth/vesting/types/common_test.go b/x/auth/vesting/types/common_test.go deleted file mode 100644 index 289b2d427..000000000 --- a/x/auth/vesting/types/common_test.go +++ /dev/null @@ -1,9 +0,0 @@ -package types_test - -import ( - "github.com/cosmos/cosmos-sdk/simapp" -) - -var ( - app = simapp.Setup(false) -) diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index 979b02212..f937fae9a 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -5,9 +5,12 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtime "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -19,6 +22,20 @@ var ( feeDenom = "fee" ) +type VestingAccountTestSuite struct { + suite.Suite + + app *simapp.SimApp + ctx sdk.Context +} + +func (s *VestingAccountTestSuite) SetupTest() { + checkTx := false + s.app = simapp.Setup(s.T(), checkTx) + + s.ctx = s.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) +} + func TestGetVestedCoinsContVestingAcc(t *testing.T) { now := tmtime.Now() endTime := now.Add(24 * time.Hour) @@ -735,72 +752,80 @@ func TestGenesisAccountValidate(t *testing.T) { } } -func TestContinuousVestingAccountMarshal(t *testing.T) { +func (s *VestingAccountTestSuite) TestContinuousVestingAccountMarshal() { + app := s.app + require := s.Require() baseAcc, coins := initBaseAccount() baseVesting := types.NewBaseVestingAccount(baseAcc, coins, time.Now().Unix()) acc := types.NewContinuousVestingAccountRaw(baseVesting, baseVesting.EndTime) bz, err := app.AccountKeeper.MarshalAccount(acc) - require.Nil(t, err) + require.Nil(err) acc2, err := app.AccountKeeper.UnmarshalAccount(bz) - require.Nil(t, err) - require.IsType(t, &types.ContinuousVestingAccount{}, acc2) - require.Equal(t, acc.String(), acc2.String()) + require.Nil(err) + require.IsType(&types.ContinuousVestingAccount{}, acc2) + require.Equal(acc.String(), acc2.String()) // error on bad bytes _, err = app.AccountKeeper.UnmarshalAccount(bz[:len(bz)/2]) - require.NotNil(t, err) + require.NotNil(err) } -func TestPeriodicVestingAccountMarshal(t *testing.T) { +func (s *VestingAccountTestSuite) TestPeriodicVestingAccountMarshal() { + app := s.app + require := s.Require() baseAcc, coins := initBaseAccount() acc := types.NewPeriodicVestingAccount(baseAcc, coins, time.Now().Unix(), types.Periods{types.Period{3600, coins}}) bz, err := app.AccountKeeper.MarshalAccount(acc) - require.Nil(t, err) + require.Nil(err) acc2, err := app.AccountKeeper.UnmarshalAccount(bz) - require.Nil(t, err) - require.IsType(t, &types.PeriodicVestingAccount{}, acc2) - require.Equal(t, acc.String(), acc2.String()) + require.Nil(err) + require.IsType(&types.PeriodicVestingAccount{}, acc2) + require.Equal(acc.String(), acc2.String()) // error on bad bytes _, err = app.AccountKeeper.UnmarshalAccount(bz[:len(bz)/2]) - require.NotNil(t, err) + require.NotNil(err) } -func TestDelayedVestingAccountMarshal(t *testing.T) { +func (s *VestingAccountTestSuite) TestDelayedVestingAccountMarshal() { + app := s.app + require := s.Require() baseAcc, coins := initBaseAccount() acc := types.NewDelayedVestingAccount(baseAcc, coins, time.Now().Unix()) bz, err := app.AccountKeeper.MarshalAccount(acc) - require.Nil(t, err) + require.Nil(err) acc2, err := app.AccountKeeper.UnmarshalAccount(bz) - require.Nil(t, err) - require.IsType(t, &types.DelayedVestingAccount{}, acc2) - require.Equal(t, acc.String(), acc2.String()) + require.Nil(err) + require.IsType(&types.DelayedVestingAccount{}, acc2) + require.Equal(acc.String(), acc2.String()) // error on bad bytes _, err = app.AccountKeeper.UnmarshalAccount(bz[:len(bz)/2]) - require.NotNil(t, err) + require.NotNil(err) } -func TestPermanentLockedAccountMarshal(t *testing.T) { +func (s *VestingAccountTestSuite) TestPermanentLockedAccountMarshal() { + app := s.app + require := s.Require() baseAcc, coins := initBaseAccount() acc := types.NewPermanentLockedAccount(baseAcc, coins) bz, err := app.AccountKeeper.MarshalAccount(acc) - require.Nil(t, err) + require.Nil(err) acc2, err := app.AccountKeeper.UnmarshalAccount(bz) - require.Nil(t, err) - require.IsType(t, &types.PermanentLockedAccount{}, acc2) - require.Equal(t, acc.String(), acc2.String()) + require.Nil(err) + require.IsType(&types.PermanentLockedAccount{}, acc2) + require.Equal(acc.String(), acc2.String()) // error on bad bytes _, err = app.AccountKeeper.UnmarshalAccount(bz[:len(bz)/2]) - require.NotNil(t, err) + require.NotNil(err) } func initBaseAccount() (*authtypes.BaseAccount, sdk.Coins) { @@ -810,3 +835,7 @@ func initBaseAccount() (*authtypes.BaseAccount, sdk.Coins) { return bacc, origCoins } + +func TestVestingAccountTestSuite(t *testing.T) { + suite.Run(t, new(VestingAccountTestSuite)) +} diff --git a/x/authz/keeper/genesis_test.go b/x/authz/keeper/genesis_test.go index 0af0c842d..ecf6051de 100644 --- a/x/authz/keeper/genesis_test.go +++ b/x/authz/keeper/genesis_test.go @@ -23,7 +23,7 @@ type GenesisTestSuite struct { func (suite *GenesisTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) suite.keeper = app.AuthzKeeper diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index 2500f7a87..e12a0b0d0 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -28,7 +28,7 @@ type TestSuite struct { } func (s *TestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(s.T(), false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) now := tmtime.Now() ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) diff --git a/x/authz/simulation/genesis_test.go b/x/authz/simulation/genesis_test.go index ef217f92c..4236b0680 100644 --- a/x/authz/simulation/genesis_test.go +++ b/x/authz/simulation/genesis_test.go @@ -15,7 +15,7 @@ import ( ) func TestRandomizedGenState(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) s := rand.NewSource(1) r := rand.New(s) diff --git a/x/authz/simulation/operations_test.go b/x/authz/simulation/operations_test.go index 4202eed73..42255c849 100644 --- a/x/authz/simulation/operations_test.go +++ b/x/authz/simulation/operations_test.go @@ -27,7 +27,7 @@ type SimTestSuite struct { func (suite *SimTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) suite.app = app suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) } diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index d7f840f9e..5b1169ed8 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -94,7 +94,7 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str } func (suite *IntegrationTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index b00716d27..f50c2b944 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -26,7 +26,7 @@ type SimTestSuite struct { func (suite *SimTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) suite.app = app suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) } diff --git a/x/bank/types/send_authorization_test.go b/x/bank/types/send_authorization_test.go index 11d2ae05d..5e058317f 100644 --- a/x/bank/types/send_authorization_test.go +++ b/x/bank/types/send_authorization_test.go @@ -19,7 +19,7 @@ var ( ) func TestSendAuthorization(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) authorization := types.NewSendAuthorization(coins1000) diff --git a/x/capability/capability_test.go b/x/capability/capability_test.go index 45a5f6ea4..6dccd6e71 100644 --- a/x/capability/capability_test.go +++ b/x/capability/capability_test.go @@ -29,7 +29,7 @@ type CapabilityTestSuite struct { func (suite *CapabilityTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) cdc := app.AppCodec() // create new keeper so we can define custom scoping before init and seal diff --git a/x/capability/keeper/keeper_test.go b/x/capability/keeper/keeper_test.go index e7b9b2d4a..9757461db 100644 --- a/x/capability/keeper/keeper_test.go +++ b/x/capability/keeper/keeper_test.go @@ -25,7 +25,7 @@ type KeeperTestSuite struct { func (suite *KeeperTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) cdc := app.AppCodec() // create new keeper so we can define custom scoping before init and seal diff --git a/x/crisis/keeper/keeper_test.go b/x/crisis/keeper/keeper_test.go index 563c0e4b1..da9cb908e 100644 --- a/x/crisis/keeper/keeper_test.go +++ b/x/crisis/keeper/keeper_test.go @@ -12,14 +12,14 @@ import ( ) func TestLogger(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.NewContext(true, tmproto.Header{}) require.Equal(t, ctx.Logger(), app.CrisisKeeper.Logger(ctx)) } func TestInvariants(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) app.Commit() app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}}) @@ -32,7 +32,7 @@ func TestInvariants(t *testing.T) { } func TestAssertInvariants(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) app.Commit() app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}}) diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index bc7058d6f..2a4494198 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -16,7 +16,7 @@ import ( ) func TestAllocateTokensToValidatorWithCommission(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) @@ -45,7 +45,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { } func TestAllocateTokensToManyValidators(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1234)) @@ -116,7 +116,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) { } func TestAllocateTokensTruncation(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 3, sdk.NewInt(1234)) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index c86cb2ef9..aefe60c20 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -15,7 +15,7 @@ import ( ) func TestCalculateRewardsBasic(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -69,7 +69,7 @@ func TestCalculateRewardsBasic(t *testing.T) { } func TestCalculateRewardsAfterSlash(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000)) @@ -132,7 +132,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { } func TestCalculateRewardsAfterManySlashes(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -207,7 +207,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { } func TestCalculateRewardsMultiDelegator(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -270,7 +270,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { } func TestWithdrawDelegationRewardsBasic(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) balancePower := int64(1000) @@ -341,7 +341,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) { } func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) @@ -409,7 +409,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { } func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -483,7 +483,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { } func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) @@ -628,7 +628,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { } func Test100PercentCommissionReward(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper) diff --git a/x/distribution/keeper/grpc_query_test.go b/x/distribution/keeper/grpc_query_test.go index 33f272230..1d80491fd 100644 --- a/x/distribution/keeper/grpc_query_test.go +++ b/x/distribution/keeper/grpc_query_test.go @@ -30,7 +30,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index bdb241051..1f9639838 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -14,7 +14,7 @@ import ( ) func TestSetWithdrawAddr(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000)) @@ -36,7 +36,7 @@ func TestSetWithdrawAddr(t *testing.T) { } func TestWithdrawValidatorCommission(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valCommission := sdk.DecCoins{ @@ -88,7 +88,7 @@ func TestWithdrawValidatorCommission(t *testing.T) { } func TestGetTotalRewards(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valCommission := sdk.DecCoins{ @@ -109,7 +109,7 @@ func TestGetTotalRewards(t *testing.T) { } func TestFundCommunityPool(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 2, sdk.ZeroInt()) diff --git a/x/distribution/keeper/querier_test.go b/x/distribution/keeper/querier_test.go index 9a3da854a..0ffb14bfb 100644 --- a/x/distribution/keeper/querier_test.go +++ b/x/distribution/keeper/querier_test.go @@ -116,7 +116,7 @@ func TestQueries(t *testing.T) { types.RegisterLegacyAminoCodec(cdc) banktypes.RegisterLegacyAminoCodec(cdc) - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000)) diff --git a/x/distribution/module_test.go b/x/distribution/module_test.go index 113622d20..562621d00 100644 --- a/x/distribution/module_test.go +++ b/x/distribution/module_test.go @@ -13,7 +13,7 @@ import ( ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index 08e926821..5e109f5e9 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -26,7 +26,7 @@ func testProposal(recipient sdk.AccAddress, amount sdk.Coins) *types.CommunityPo } func TestProposalHandlerPassed(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) recipient := delAddr1 @@ -55,7 +55,7 @@ func TestProposalHandlerPassed(t *testing.T) { } func TestProposalHandlerFailed(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) recipient := delAddr1 diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index 8129c5b8b..1ef25858c 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -215,7 +215,7 @@ type SimTestSuite struct { func (suite *SimTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) suite.app = app suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) } diff --git a/x/distribution/simulation/proposals_test.go b/x/distribution/simulation/proposals_test.go index 6d5895ea8..aec70fd83 100644 --- a/x/distribution/simulation/proposals_test.go +++ b/x/distribution/simulation/proposals_test.go @@ -15,7 +15,7 @@ import ( ) func TestProposalContents(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) // initialize parameters diff --git a/x/evidence/genesis_test.go b/x/evidence/genesis_test.go index 3ae8eee03..8956e81f9 100644 --- a/x/evidence/genesis_test.go +++ b/x/evidence/genesis_test.go @@ -26,7 +26,7 @@ type GenesisTestSuite struct { func (suite *GenesisTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) suite.keeper = app.EvidenceKeeper diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 5352867de..b0b12176e 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -80,7 +80,7 @@ type KeeperTestSuite struct { func (suite *KeeperTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) // recreate keeper in order to use custom testing types evidenceKeeper := keeper.NewKeeper( diff --git a/x/evidence/simulation/decoder_test.go b/x/evidence/simulation/decoder_test.go index a63beae50..d23d796a0 100644 --- a/x/evidence/simulation/decoder_test.go +++ b/x/evidence/simulation/decoder_test.go @@ -16,7 +16,7 @@ import ( ) func TestDecodeStore(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) dec := simulation.NewDecodeStore(app.EvidenceKeeper) delPk1 := ed25519.GenPrivKey().PubKey() diff --git a/x/feegrant/basic_fee_test.go b/x/feegrant/basic_fee_test.go index 98df14ef7..71d278fa4 100644 --- a/x/feegrant/basic_fee_test.go +++ b/x/feegrant/basic_fee_test.go @@ -14,7 +14,7 @@ import ( ) func TestBasicFeeValidAllow(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) badTime := ctx.BlockTime().AddDate(0, 0, -1) diff --git a/x/feegrant/grant_test.go b/x/feegrant/grant_test.go index 5fbbd8190..f8b56c891 100644 --- a/x/feegrant/grant_test.go +++ b/x/feegrant/grant_test.go @@ -13,7 +13,7 @@ import ( ) func TestGrant(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) addr, err := sdk.AccAddressFromBech32("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") require.NoError(t, err) addr2, err := sdk.AccAddressFromBech32("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") diff --git a/x/feegrant/keeper/genesis_test.go b/x/feegrant/keeper/genesis_test.go index 51203dbb6..0c80780da 100644 --- a/x/feegrant/keeper/genesis_test.go +++ b/x/feegrant/keeper/genesis_test.go @@ -23,7 +23,7 @@ type GenesisTestSuite struct { func (suite *GenesisTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) suite.keeper = app.FeeGrantKeeper } diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index b2e08734b..8397f264f 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -30,7 +30,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) suite.app = app diff --git a/x/feegrant/periodic_fee_test.go b/x/feegrant/periodic_fee_test.go index f09640b5f..b6a8d39bd 100644 --- a/x/feegrant/periodic_fee_test.go +++ b/x/feegrant/periodic_fee_test.go @@ -14,7 +14,7 @@ import ( ) func TestPeriodicFeeValidAllow(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{ Time: time.Now(), }) diff --git a/x/feegrant/simulation/genesis_test.go b/x/feegrant/simulation/genesis_test.go index 5cd22fa67..88f057dd0 100644 --- a/x/feegrant/simulation/genesis_test.go +++ b/x/feegrant/simulation/genesis_test.go @@ -15,7 +15,7 @@ import ( ) func TestRandomizedGenState(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) s := rand.NewSource(1) r := rand.New(s) diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index 2a7427c6d..1d6135e72 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -27,7 +27,7 @@ type SimTestSuite struct { func (suite *SimTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) suite.app = app suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{ Time: time.Now(), diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index 65fd5194d..55891a0b9 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -45,7 +45,7 @@ type GenTxTestSuite struct { func (suite *GenTxTestSuite) SetupTest() { checkTx := false - app := simapp.Setup(checkTx) + app := simapp.Setup(suite.T(), checkTx) suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) suite.app = app suite.encodingConfig = simapp.MakeTestEncodingConfig() diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index 168e544c9..c1f2b121f 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -19,7 +19,7 @@ import ( ) func TestTickExpiredDepositPeriod(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) @@ -72,7 +72,7 @@ func TestTickExpiredDepositPeriod(t *testing.T) { } func TestTickMultipleExpiredDepositPeriod(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) @@ -149,7 +149,7 @@ func TestTickMultipleExpiredDepositPeriod(t *testing.T) { } func TestTickPassedDepositPeriod(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) @@ -202,7 +202,7 @@ func TestTickPassedDepositPeriod(t *testing.T) { } func TestTickPassedVotingPeriod(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) @@ -268,7 +268,7 @@ func TestTickPassedVotingPeriod(t *testing.T) { } func TestProposalPassedEndblocker(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 10, valTokens) @@ -321,7 +321,7 @@ func TestProposalPassedEndblocker(t *testing.T) { } func TestEndBlockerProposalHandlerFailed(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 1, valTokens) diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index 30890937e..d289af470 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -20,7 +20,7 @@ import ( ) func TestImportExportQueues(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 2, valTokens) @@ -113,7 +113,7 @@ func TestImportExportQueues(t *testing.T) { } func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) require.Panics(t, func() { gov.InitGenesis(ctx, app.AccountKeeper, app.BankKeeper, app.GovKeeper, &types.GenesisState{ @@ -134,7 +134,7 @@ func TestImportExportQueues_ErrorUnconsistentState(t *testing.T) { } func TestEqualProposals(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrs(app, ctx, 2, valTokens) diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index d781973ec..218cbd851 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -12,7 +12,7 @@ import ( ) func TestDeposits(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000000)) diff --git a/x/gov/keeper/hooks_test.go b/x/gov/keeper/hooks_test.go index 536fc1983..2e38b386b 100644 --- a/x/gov/keeper/hooks_test.go +++ b/x/gov/keeper/hooks_test.go @@ -44,7 +44,7 @@ func (h *MockGovHooksReceiver) AfterProposalVotingPeriodEnded(ctx sdk.Context, p } func TestHooks(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) minDeposit := app.GovKeeper.GetDepositParams(ctx).MinDeposit diff --git a/x/gov/keeper/keeper_test.go b/x/gov/keeper/keeper_test.go index 105a9d002..e4e0b2cd9 100644 --- a/x/gov/keeper/keeper_test.go +++ b/x/gov/keeper/keeper_test.go @@ -23,7 +23,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) @@ -37,7 +37,7 @@ func (suite *KeeperTestSuite) SetupTest() { } func TestIncrementProposalNumber(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) tp := TestProposal @@ -58,7 +58,7 @@ func TestIncrementProposalNumber(t *testing.T) { } func TestProposalQueues(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) // create test proposals diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index b3cf4dfd9..8f658a218 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -145,7 +145,7 @@ func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, quer } func TestQueries(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) legacyQuerierCdc := app.LegacyAmino() querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc) @@ -304,7 +304,7 @@ func TestQueries(t *testing.T) { } func TestPaginatedVotesQuery(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) legacyQuerierCdc := app.LegacyAmino() diff --git a/x/gov/keeper/tally_test.go b/x/gov/keeper/tally_test.go index 7347cfbe6..3ddec4613 100644 --- a/x/gov/keeper/tally_test.go +++ b/x/gov/keeper/tally_test.go @@ -14,7 +14,7 @@ import ( ) func TestTallyNoOneVotes(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) createValidators(t, ctx, app, []int64{5, 5, 5}) @@ -36,7 +36,7 @@ func TestTallyNoOneVotes(t *testing.T) { } func TestTallyNoQuorum(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) createValidators(t, ctx, app, []int64{2, 5, 0}) @@ -61,7 +61,7 @@ func TestTallyNoQuorum(t *testing.T) { } func TestTallyOnlyValidatorsAllYes(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, _ := createValidators(t, ctx, app, []int64{5, 5, 5}) @@ -87,7 +87,7 @@ func TestTallyOnlyValidatorsAllYes(t *testing.T) { } func TestTallyOnlyValidators51No(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(t, ctx, app, []int64{5, 6, 0}) @@ -111,7 +111,7 @@ func TestTallyOnlyValidators51No(t *testing.T) { } func TestTallyOnlyValidators51Yes(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(t, ctx, app, []int64{5, 6, 0}) @@ -136,7 +136,7 @@ func TestTallyOnlyValidators51Yes(t *testing.T) { } func TestTallyOnlyValidatorsVetoed(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7}) @@ -162,7 +162,7 @@ func TestTallyOnlyValidatorsVetoed(t *testing.T) { } func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7}) @@ -188,7 +188,7 @@ func TestTallyOnlyValidatorsAbstainPasses(t *testing.T) { } func TestTallyOnlyValidatorsAbstainFails(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(t, ctx, app, []int64{6, 6, 7}) @@ -214,7 +214,7 @@ func TestTallyOnlyValidatorsAbstainFails(t *testing.T) { } func TestTallyOnlyValidatorsNonVoter(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) valAccAddrs, _ := createValidators(t, ctx, app, []int64{5, 6, 7}) @@ -240,7 +240,7 @@ func TestTallyOnlyValidatorsNonVoter(t *testing.T) { } func TestTallyDelgatorOverride(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, valAddrs := createValidators(t, ctx, app, []int64{5, 6, 7}) @@ -276,7 +276,7 @@ func TestTallyDelgatorOverride(t *testing.T) { } func TestTallyDelgatorInherit(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, vals := createValidators(t, ctx, app, []int64{5, 6, 7}) @@ -311,7 +311,7 @@ func TestTallyDelgatorInherit(t *testing.T) { } func TestTallyDelgatorMultipleOverride(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, vals := createValidators(t, ctx, app, []int64{5, 6, 7}) @@ -351,7 +351,7 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) { } func TestTallyDelgatorMultipleInherit(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) createValidators(t, ctx, app, []int64{25, 6, 7}) @@ -392,7 +392,7 @@ func TestTallyDelgatorMultipleInherit(t *testing.T) { } func TestTallyJailedValidator(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, valAddrs := createValidators(t, ctx, app, []int64{25, 6, 7}) @@ -435,7 +435,7 @@ func TestTallyJailedValidator(t *testing.T) { } func TestTallyValidatorMultipleDelegations(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs, valAddrs := createValidators(t, ctx, app, []int64{10, 10, 10}) diff --git a/x/gov/keeper/vote_test.go b/x/gov/keeper/vote_test.go index 80df46716..2db792fb5 100644 --- a/x/gov/keeper/vote_test.go +++ b/x/gov/keeper/vote_test.go @@ -12,7 +12,7 @@ import ( ) func TestVotes(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) diff --git a/x/gov/module_test.go b/x/gov/module_test.go index 4e54c0b79..fa07f9e30 100644 --- a/x/gov/module_test.go +++ b/x/gov/module_test.go @@ -13,7 +13,7 @@ import ( ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( diff --git a/x/gov/simulation/operations_test.go b/x/gov/simulation/operations_test.go index 83f612a83..bce345de0 100644 --- a/x/gov/simulation/operations_test.go +++ b/x/gov/simulation/operations_test.go @@ -56,7 +56,7 @@ func mockWeightedProposalContent(n int) []simtypes.WeightedProposalContent { // TestWeightedOperations tests the weights of the operations. func TestWeightedOperations(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) ctx.WithChainID("test-chain") cdc := app.AppCodec() @@ -98,7 +98,7 @@ func TestWeightedOperations(t *testing.T) { // TestSimulateMsgSubmitProposal tests the normal scenario of a valid message of type TypeMsgSubmitProposal. // Abonormal scenarios, where the message is created by an errors are not tested here. func TestSimulateMsgSubmitProposal(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) // setup 3 accounts s := rand.NewSource(1) @@ -128,7 +128,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) { // TestSimulateMsgDeposit tests the normal scenario of a valid message of type TypeMsgDeposit. // Abonormal scenarios, where the message is created by an errors are not tested here. func TestSimulateMsgDeposit(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) @@ -170,7 +170,7 @@ func TestSimulateMsgDeposit(t *testing.T) { // TestSimulateMsgVote tests the normal scenario of a valid message of type TypeMsgVote. // Abonormal scenarios, where the message is created by an errors are not tested here. func TestSimulateMsgVote(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) @@ -212,7 +212,7 @@ func TestSimulateMsgVote(t *testing.T) { // TestSimulateMsgVoteWeighted tests the normal scenario of a valid message of type TypeMsgVoteWeighted. // Abonormal scenarios, where the message is created by an errors are not tested here. func TestSimulateMsgVoteWeighted(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) @@ -252,8 +252,8 @@ func TestSimulateMsgVoteWeighted(t *testing.T) { } // returns context and an app with updated mint keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) +func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, minttypes.DefaultParams()) diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index 11b627669..cc2733d25 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -22,7 +22,7 @@ type MintTestSuite struct { } func (suite *MintTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) diff --git a/x/mint/keeper/integration_test.go b/x/mint/keeper/integration_test.go index df321c33b..c293751a2 100644 --- a/x/mint/keeper/integration_test.go +++ b/x/mint/keeper/integration_test.go @@ -1,6 +1,8 @@ package keeper_test import ( + "testing" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" @@ -9,8 +11,8 @@ import ( ) // returns context and an app with updated mint keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) +func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, types.DefaultParams()) diff --git a/x/mint/keeper/querier_test.go b/x/mint/keeper/querier_test.go index 2e987aa04..5e8d00ecc 100644 --- a/x/mint/keeper/querier_test.go +++ b/x/mint/keeper/querier_test.go @@ -15,7 +15,7 @@ import ( ) func TestNewQuerier(t *testing.T) { - app, ctx := createTestApp(true) + app, ctx := createTestApp(t, true) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) @@ -38,7 +38,7 @@ func TestNewQuerier(t *testing.T) { } func TestQueryParams(t *testing.T) { - app, ctx := createTestApp(true) + app, ctx := createTestApp(t, true) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) @@ -54,7 +54,7 @@ func TestQueryParams(t *testing.T) { } func TestQueryInflation(t *testing.T) { - app, ctx := createTestApp(true) + app, ctx := createTestApp(t, true) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) @@ -70,7 +70,7 @@ func TestQueryInflation(t *testing.T) { } func TestQueryAnnualProvisions(t *testing.T) { - app, ctx := createTestApp(true) + app, ctx := createTestApp(t, true) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) diff --git a/x/mint/module_test.go b/x/mint/module_test.go index 3b2df369e..d35f2f824 100644 --- a/x/mint/module_test.go +++ b/x/mint/module_test.go @@ -13,7 +13,7 @@ import ( ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index 795a9aac6..92e2afb91 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -26,7 +26,8 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - suite.app, suite.ctx = createTestApp(true) + suite.app = simapp.Setup(suite.T(), false) + suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) proposal.RegisterQueryServer(queryHelper, suite.app.ParamsKeeper) @@ -37,14 +38,6 @@ func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } -// returns context and app -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) - - return app, ctx -} - func validateNoOp(_ interface{}) error { return nil } func TestKeeper(t *testing.T) { diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index b5c79669a..39f72fb6d 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -24,7 +24,7 @@ type HandlerTestSuite struct { } func (suite *HandlerTestSuite) SetupTest() { - suite.app = simapp.Setup(false) + suite.app = simapp.Setup(suite.T(), false) suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{}) suite.govHandler = params.NewParamChangeProposalHandler(suite.app.ParamsKeeper) } diff --git a/x/slashing/abci_test.go b/x/slashing/abci_test.go index 6121e3572..f2958d4d3 100644 --- a/x/slashing/abci_test.go +++ b/x/slashing/abci_test.go @@ -17,7 +17,7 @@ import ( ) func TestBeginBlocker(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) pks := simapp.CreateTestPubKeys(1) diff --git a/x/slashing/genesis_test.go b/x/slashing/genesis_test.go index 1467fac6e..7cd0792bd 100644 --- a/x/slashing/genesis_test.go +++ b/x/slashing/genesis_test.go @@ -15,7 +15,7 @@ import ( ) func TestExportAndInitGenesis(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.SlashingKeeper.SetParams(ctx, testslashing.TestParams()) diff --git a/x/slashing/keeper/grpc_query_test.go b/x/slashing/keeper/grpc_query_test.go index 6290b94e0..ddb6694d0 100644 --- a/x/slashing/keeper/grpc_query_test.go +++ b/x/slashing/keeper/grpc_query_test.go @@ -28,7 +28,7 @@ type SlashingTestSuite struct { } func (suite *SlashingTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) diff --git a/x/slashing/keeper/keeper_test.go b/x/slashing/keeper/keeper_test.go index c0cf24985..a5bdd4e0a 100644 --- a/x/slashing/keeper/keeper_test.go +++ b/x/slashing/keeper/keeper_test.go @@ -16,7 +16,7 @@ import ( ) func TestUnJailNotBonded(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) p := app.StakingKeeper.GetParams(ctx) @@ -82,7 +82,7 @@ func TestUnJailNotBonded(t *testing.T) { // Ensure that SigningInfo.StartHeight is set correctly // and that they are not immediately jailed func TestHandleNewValidator(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200)) @@ -126,7 +126,7 @@ func TestHandleNewValidator(t *testing.T) { // Ensure that they're only slashed once func TestHandleAlreadyJailed(t *testing.T) { // initial setup - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200)) @@ -180,7 +180,7 @@ func TestValidatorDippingInAndOut(t *testing.T) { // initial setup // TestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500 - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.SlashingKeeper.SetParams(ctx, testslashing.TestParams()) diff --git a/x/slashing/keeper/querier_test.go b/x/slashing/keeper/querier_test.go index bda5fe4bc..0b9fb6b51 100644 --- a/x/slashing/keeper/querier_test.go +++ b/x/slashing/keeper/querier_test.go @@ -16,7 +16,7 @@ import ( ) func TestNewQuerier(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.SlashingKeeper.SetParams(ctx, testslashing.TestParams()) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) @@ -34,7 +34,7 @@ func TestNewQuerier(t *testing.T) { func TestQueryParams(t *testing.T) { cdc := codec.NewLegacyAmino() legacyQuerierCdc := codec.NewAminoCodec(cdc) - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.SlashingKeeper.SetParams(ctx, testslashing.TestParams()) diff --git a/x/slashing/keeper/signing_info_test.go b/x/slashing/keeper/signing_info_test.go index 2748042b3..cee32a0d5 100644 --- a/x/slashing/keeper/signing_info_test.go +++ b/x/slashing/keeper/signing_info_test.go @@ -13,7 +13,7 @@ import ( ) func TestGetSetValidatorSigningInfo(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200)) @@ -37,7 +37,7 @@ func TestGetSetValidatorSigningInfo(t *testing.T) { } func TestGetSetValidatorMissedBlockBitArray(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200)) @@ -49,7 +49,7 @@ func TestGetSetValidatorMissedBlockBitArray(t *testing.T) { } func TestTombstoned(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200)) @@ -73,7 +73,7 @@ func TestTombstoned(t *testing.T) { } func TestJailUntil(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, app.StakingKeeper.TokensFromConsensusPower(ctx, 200)) diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index 8b25711bd..fa7a6edf3 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -23,7 +23,7 @@ import ( // TestWeightedOperations tests the weights of the operations. func TestWeightedOperations(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) ctx.WithChainID("test-chain") cdc := app.AppCodec() @@ -54,7 +54,7 @@ func TestWeightedOperations(t *testing.T) { // TestSimulateMsgUnjail tests the normal scenario of a valid message of type types.MsgUnjail. // Abonormal scenarios, where the message is created by an errors, are not tested here. func TestSimulateMsgUnjail(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) @@ -104,8 +104,8 @@ func TestSimulateMsgUnjail(t *testing.T) { } // returns context and an app with updated mint keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) +func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, minttypes.DefaultParams()) diff --git a/x/staking/common_test.go b/x/staking/common_test.go index 5d8897b1c..93193e459 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -2,6 +2,7 @@ package staking_test import ( "math/big" + "testing" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -35,8 +36,8 @@ var ( // getBaseSimappWithCustomKeeper Returns a simapp with custom StakingKeeper // to avoid messing with the hooks. -func getBaseSimappWithCustomKeeper() (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) { - app := simapp.Setup(false) +func getBaseSimappWithCustomKeeper(t *testing.T) (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) appCodec := app.AppCodec() diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index 93fea369e..587986870 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -20,15 +20,15 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking/types" ) -func bootstrapGenesisTest(numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress) { - _, app, ctx := getBaseSimappWithCustomKeeper() +func bootstrapGenesisTest(t *testing.T, numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress) { + _, app, ctx := getBaseSimappWithCustomKeeper(t) addrDels, _ := generateAddresses(app, ctx, numAddrs, sdk.NewInt(10000)) return app, ctx, addrDels } func TestInitGenesis(t *testing.T) { - app, ctx, addrs := bootstrapGenesisTest(10) + app, ctx, addrs := bootstrapGenesisTest(t, 10) valTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 1) @@ -107,7 +107,7 @@ func TestInitGenesis(t *testing.T) { } func TestInitGenesis_PoolsBalanceMismatch(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.NewContext(false, tmproto.Header{}) consPub, err := codectypes.NewAnyWithValue(PKs[0]) @@ -155,7 +155,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) { size := 200 require.True(t, size > 100) - app, ctx, addrs := bootstrapGenesisTest(200) + app, ctx, addrs := bootstrapGenesisTest(t, 200) params := app.StakingKeeper.GetParams(ctx) delegations := []types.Delegation{} diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index fb07d8694..6833ea4c0 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -23,8 +23,8 @@ func init() { // createTestInput Returns a simapp with custom StakingKeeper // to avoid messing with the hooks. -func createTestInput() (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) { - app := simapp.Setup(false) +func createTestInput(t *testing.T) (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.StakingKeeper = keeper.NewKeeper( diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index 9a6699eb8..395a32e61 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -17,7 +17,7 @@ import ( // tests GetDelegation, GetDelegatorDelegations, SetDelegation, RemoveDelegation, GetDelegatorDelegations func TestDelegation(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(addrDels) @@ -133,7 +133,7 @@ func TestDelegation(t *testing.T) { // tests Get/Set/Remove UnbondingDelegation func TestUnbondingDelegation(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(delAddrs) @@ -179,7 +179,7 @@ func TestUnbondingDelegation(t *testing.T) { } func TestUnbondDelegation(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) delAddrs := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(delAddrs) @@ -218,7 +218,7 @@ func TestUnbondDelegation(t *testing.T) { } func TestUnbondingDelegationsMaxEntries(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -300,7 +300,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { //// test undelegating self delegation from a validator pushing it below MinSelfDelegation //// shift it from the bonded to unbonding state and jailed func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(10000)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -360,7 +360,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { } func TestUndelegateFromUnbondingValidator(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) @@ -446,7 +446,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { } func TestUndelegateFromUnbondedValidator(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) @@ -527,7 +527,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { } func TestUnbondingAllDelegationFromValidator(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) @@ -600,7 +600,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { // Make sure that that the retrieving the delegations doesn't affect the state func TestGetRedelegationsFromSrcValidator(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -627,7 +627,7 @@ func TestGetRedelegationsFromSrcValidator(t *testing.T) { // tests Get/Set/Remove/Has UnbondingDelegation func TestRedelegation(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -690,7 +690,7 @@ func TestRedelegation(t *testing.T) { } func TestRedelegateToSameValidator(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 1, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -719,7 +719,7 @@ func TestRedelegateToSameValidator(t *testing.T) { } func TestRedelegationMaxEntries(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -775,7 +775,7 @@ func TestRedelegationMaxEntries(t *testing.T) { } func TestRedelegateSelfDelegation(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -831,7 +831,7 @@ func TestRedelegateSelfDelegation(t *testing.T) { } func TestRedelegateFromUnbondingValidator(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -913,7 +913,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { } func TestRedelegateFromUnbondedValidator(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) diff --git a/x/staking/keeper/historical_info_test.go b/x/staking/keeper/historical_info_test.go index db6c6a6b4..6e7063a77 100644 --- a/x/staking/keeper/historical_info_test.go +++ b/x/staking/keeper/historical_info_test.go @@ -24,7 +24,7 @@ func IsValSetSorted(data []types.Validator, powerReduction sdk.Int) bool { } func TestHistoricalInfo(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -51,7 +51,7 @@ func TestHistoricalInfo(t *testing.T) { } func TestTrackHistoricalInfo(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) @@ -129,7 +129,7 @@ func TestTrackHistoricalInfo(t *testing.T) { } func TestGetAllHistoricalInfo(t *testing.T) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels := simapp.AddTestAddrsIncremental(app, ctx, 50, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index b0533c8ab..f717528f4 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -26,7 +26,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) querier := keeper.Querier{Keeper: app.StakingKeeper} @@ -51,7 +51,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.app, suite.ctx, suite.queryClient, suite.addrs, suite.vals = app, ctx, queryClient, addrs, validators } func TestParams(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) expParams := types.DefaultParams() diff --git a/x/staking/keeper/querier_test.go b/x/staking/keeper/querier_test.go index 6abe7d53c..16755d5e1 100644 --- a/x/staking/keeper/querier_test.go +++ b/x/staking/keeper/querier_test.go @@ -17,7 +17,7 @@ import ( ) func TestNewQuerier(t *testing.T) { - cdc, app, ctx := createTestInput() + cdc, app, ctx := createTestInput(t) addrs := simapp.AddTestAddrs(app, ctx, 500, sdk.NewInt(10000)) _, addrAcc2 := addrs[0], addrs[1] @@ -109,7 +109,7 @@ func TestNewQuerier(t *testing.T) { } func TestQueryParametersPool(t *testing.T) { - cdc, app, ctx := createTestInput() + cdc, app, ctx := createTestInput(t) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) @@ -135,7 +135,7 @@ func TestQueryParametersPool(t *testing.T) { } func TestQueryValidators(t *testing.T) { - cdc, app, ctx := createTestInput() + cdc, app, ctx := createTestInput(t) params := app.StakingKeeper.GetParams(ctx) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) @@ -203,7 +203,7 @@ func TestQueryValidators(t *testing.T) { } func TestQueryDelegation(t *testing.T) { - cdc, app, ctx := createTestInput() + cdc, app, ctx := createTestInput(t) params := app.StakingKeeper.GetParams(ctx) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) @@ -452,7 +452,7 @@ func TestQueryValidatorDelegations_Pagination(t *testing.T) { }, } - cdc, app, ctx := createTestInput() + cdc, app, ctx := createTestInput(t) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) @@ -537,7 +537,7 @@ func TestQueryValidatorDelegations_Pagination(t *testing.T) { } func TestQueryRedelegations(t *testing.T) { - cdc, app, ctx := createTestInput() + cdc, app, ctx := createTestInput(t) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) @@ -609,7 +609,7 @@ func TestQueryRedelegations(t *testing.T) { } func TestQueryUnbondingDelegation(t *testing.T) { - cdc, app, ctx := createTestInput() + cdc, app, ctx := createTestInput(t) legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) @@ -705,7 +705,7 @@ func TestQueryUnbondingDelegation(t *testing.T) { } func TestQueryHistoricalInfo(t *testing.T) { - cdc, app, ctx := createTestInput() + cdc, app, ctx := createTestInput(t) legacyQuerierCdc := codec.NewAminoCodec(cdc) querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index 73fae5cce..8b987d0e8 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -18,7 +18,7 @@ import ( // bootstrapSlashTest creates 3 validators and bootstrap the app. func bootstrapSlashTest(t *testing.T, power int64) (*simapp.SimApp, sdk.Context, []sdk.AccAddress, []sdk.ValAddress) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(t) addrDels, addrVals := generateAddresses(app, ctx, 100) diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index 3017ffb92..74aa03b49 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -26,7 +26,7 @@ func newMonikerValidator(t testing.TB, operator sdk.ValAddress, pubKey cryptotyp } func bootstrapValidatorTest(t testing.TB, power int64, numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress, []sdk.ValAddress) { - _, app, ctx := createTestInput() + _, app, ctx := createTestInput(&testing.T{}) addrDels, addrVals := generateAddresses(app, ctx, numAddrs) diff --git a/x/staking/module_test.go b/x/staking/module_test.go index b1d126d0c..a9ebb6d9a 100644 --- a/x/staking/module_test.go +++ b/x/staking/module_test.go @@ -13,7 +13,7 @@ import ( ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) app.InitChain( diff --git a/x/staking/simulation/operations_test.go b/x/staking/simulation/operations_test.go index bfa27d802..0f3f2c730 100644 --- a/x/staking/simulation/operations_test.go +++ b/x/staking/simulation/operations_test.go @@ -24,7 +24,7 @@ import ( // TestWeightedOperations tests the weights of the operations. func TestWeightedOperations(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) ctx.WithChainID("test-chain") @@ -64,7 +64,7 @@ func TestWeightedOperations(t *testing.T) { // TestSimulateMsgCreateValidator tests the normal scenario of a valid message of type TypeMsgCreateValidator. // Abonormal scenarios, where the message are created by an errors are not tested here. func TestSimulateMsgCreateValidator(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) // setup 3 accounts s := rand.NewSource(1) @@ -96,7 +96,7 @@ func TestSimulateMsgCreateValidator(t *testing.T) { // TestSimulateMsgEditValidator tests the normal scenario of a valid message of type TypeMsgEditValidator. // Abonormal scenarios, where the message is created by an errors are not tested here. func TestSimulateMsgEditValidator(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) @@ -133,7 +133,7 @@ func TestSimulateMsgEditValidator(t *testing.T) { // TestSimulateMsgDelegate tests the normal scenario of a valid message of type TypeMsgDelegate. // Abonormal scenarios, where the message is created by an errors are not tested here. func TestSimulateMsgDelegate(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) @@ -169,7 +169,7 @@ func TestSimulateMsgDelegate(t *testing.T) { // TestSimulateMsgUndelegate tests the normal scenario of a valid message of type TypeMsgUndelegate. // Abonormal scenarios, where the message is created by an errors are not tested here. func TestSimulateMsgUndelegate(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) @@ -215,7 +215,7 @@ func TestSimulateMsgUndelegate(t *testing.T) { // TestSimulateMsgBeginRedelegate tests the normal scenario of a valid message of type TypeMsgBeginRedelegate. // Abonormal scenarios, where the message is created by an errors, are not tested here. func TestSimulateMsgBeginRedelegate(t *testing.T) { - app, ctx := createTestApp(false) + app, ctx := createTestApp(t, false) blockTime := time.Now().UTC() ctx = ctx.WithBlockTime(blockTime) @@ -263,9 +263,9 @@ func TestSimulateMsgBeginRedelegate(t *testing.T) { } // returns context and an app with updated mint keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { +func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { // sdk.PowerReduction = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)) - app := simapp.Setup(isCheckTx) + app := simapp.Setup(t, isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, minttypes.DefaultParams()) diff --git a/x/staking/types/authz_test.go b/x/staking/types/authz_test.go index 5a8828d1d..d1d740e17 100644 --- a/x/staking/types/authz_test.go +++ b/x/staking/types/authz_test.go @@ -21,7 +21,7 @@ var ( ) func TestAuthzAuthorizations(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) // verify ValidateBasic returns error for the AUTHORIZATION_TYPE_UNSPECIFIED authorization type diff --git a/x/upgrade/client/testutil/suite.go b/x/upgrade/client/testutil/suite.go index bfa785908..93ed107cc 100644 --- a/x/upgrade/client/testutil/suite.go +++ b/x/upgrade/client/testutil/suite.go @@ -28,7 +28,7 @@ type IntegrationTestSuite struct { func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") - app := simapp.Setup(false) + app := simapp.Setup(s.T(), false) s.app = app s.ctx = app.BaseApp.NewContext(false, tmproto.Header{}) diff --git a/x/upgrade/keeper/grpc_query_test.go b/x/upgrade/keeper/grpc_query_test.go index 2b65105e5..506ea0a07 100644 --- a/x/upgrade/keeper/grpc_query_test.go +++ b/x/upgrade/keeper/grpc_query_test.go @@ -24,7 +24,7 @@ type UpgradeTestSuite struct { } func (suite *UpgradeTestSuite) SetupTest() { - suite.app = simapp.Setup(false) + suite.app = simapp.Setup(suite.T(), false) suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index fc95d8416..c8df562f5 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -24,7 +24,7 @@ type KeeperTestSuite struct { } func (s *KeeperTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(s.T(), false) homeDir := filepath.Join(s.T().TempDir(), "x_upgrade_keeper_test") app.UpgradeKeeper = keeper.NewKeeper( // recreate keeper in order to use a custom home path make(map[int64]bool), app.GetKey(types.StoreKey), app.AppCodec(), homeDir, app.BaseApp,