From c2028d344d4b7ec7ffbd6f82991cab9635d4978c Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Fri, 27 Oct 2023 16:57:55 -0500 Subject: [PATCH 1/8] test: refactors cli.network suites with 'Integration' to use common function --- wasmbinding/test/cli_test.go | 7 ++----- x/common/testutil/cases.go | 16 ++++++++++++++++ x/devgas/v1/keeper/grpc_query_test.go | 10 +++++----- x/devgas/v1/keeper/keeper_test.go | 10 +++++----- x/devgas/v1/keeper/msg_server_test.go | 14 +++++++------- x/perp/v2/client/cli/cli_test.go | 12 ++---------- x/spot/client/testutil/suite.go | 12 ++---------- x/sudo/cli/cli_test.go | 1 + x/tokenfactory/cli/cli_test.go | 11 +---------- 9 files changed, 41 insertions(+), 52 deletions(-) diff --git a/wasmbinding/test/cli_test.go b/wasmbinding/test/cli_test.go index cc3972fdb..19ee618f1 100644 --- a/wasmbinding/test/cli_test.go +++ b/wasmbinding/test/cli_test.go @@ -18,6 +18,7 @@ import ( "github.com/NibiruChain/nibiru/x/common" "github.com/NibiruChain/nibiru/x/common/asset" "github.com/NibiruChain/nibiru/x/common/denoms" + "github.com/NibiruChain/nibiru/x/common/testutil" testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli" "github.com/NibiruChain/nibiru/x/common/testutil/genesis" epochstypes "github.com/NibiruChain/nibiru/x/epochs/types" @@ -39,11 +40,7 @@ type IntegrationTestSuite struct { } func (s *IntegrationTestSuite) SetupSuite() { - if testing.Short() { - s.T().Skip("skipping integration test suite") - } - - s.T().Log("setting up integration test suite") + testutil.BeforeIntegrationSuite(s.T()) app.SetPrefixes(app.AccountAddressPrefix) diff --git a/x/common/testutil/cases.go b/x/common/testutil/cases.go index 457ce26a4..cb0553754 100644 --- a/x/common/testutil/cases.go +++ b/x/common/testutil/cases.go @@ -18,3 +18,19 @@ func RunFunctionTests(t *testing.T, testCases []FunctionTestCase) { }) } } + +/* +BeforeIntegrationSuite: Skips a test if the `-short` flag is not used: + +All tests: `go test ./...` +Unit tests only: `go test ./... -short` +Integration tests only: `go test ./... -run Integration` + +See: https://stackoverflow.com/a/41407042/13305627 +*/ +func BeforeIntegrationSuite(suiteT *testing.T) { + if testing.Short() { + suiteT.Skip("skipping integration test suite") + } + suiteT.Log("setting up integration test suite") +} diff --git a/x/devgas/v1/keeper/grpc_query_test.go b/x/devgas/v1/keeper/grpc_query_test.go index cee8cd6ff..8acc59d01 100644 --- a/x/devgas/v1/keeper/grpc_query_test.go +++ b/x/devgas/v1/keeper/grpc_query_test.go @@ -9,7 +9,7 @@ import ( devgastypes "github.com/NibiruChain/nibiru/x/devgas/v1/types" ) -func (s *IntegrationTestSuite) TestQueryFeeShares() { +func (s *KeeperTestSuite) TestQueryFeeShares() { s.SetupTest() _, _, sender := testdata.KeyTestPubAddr() _ = s.FundAccount( @@ -70,7 +70,7 @@ func (s *IntegrationTestSuite) TestQueryFeeShares() { }) } -func (s *IntegrationTestSuite) TestFeeShare() { +func (s *KeeperTestSuite) TestFeeShare() { s.SetupTest() _, _, sender := testdata.KeyTestPubAddr() _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) @@ -102,7 +102,7 @@ func (s *IntegrationTestSuite) TestFeeShare() { s.Require().Equal(resp.Feeshare, feeShare) } -func (s *IntegrationTestSuite) TestFeeSharesByWithdrawer() { +func (s *KeeperTestSuite) TestFeeSharesByWithdrawer() { s.SetupTest() _, _, sender := testdata.KeyTestPubAddr() _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) @@ -141,7 +141,7 @@ func (s *IntegrationTestSuite) TestFeeSharesByWithdrawer() { }) } -func (s *IntegrationTestSuite) TestQueryParams() { +func (s *KeeperTestSuite) TestQueryParams() { s.SetupTest() goCtx := sdk.WrapSDKContext(s.ctx) resp, err := s.queryClient.Params(goCtx, nil) @@ -149,7 +149,7 @@ func (s *IntegrationTestSuite) TestQueryParams() { s.NotNil(resp) } -func (s *IntegrationTestSuite) TestNilRequests() { +func (s *KeeperTestSuite) TestNilRequests() { s.SetupTest() goCtx := sdk.WrapSDKContext(s.ctx) querier := devgaskeeper.NewQuerier(s.app.DevGasKeeper) diff --git a/x/devgas/v1/keeper/keeper_test.go b/x/devgas/v1/keeper/keeper_test.go index 22c3806b1..9be7553eb 100644 --- a/x/devgas/v1/keeper/keeper_test.go +++ b/x/devgas/v1/keeper/keeper_test.go @@ -25,7 +25,7 @@ type BankKeeper interface { SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error } -type IntegrationTestSuite struct { +type KeeperTestSuite struct { suite.Suite ctx sdk.Context @@ -35,7 +35,7 @@ type IntegrationTestSuite struct { wasmMsgServer wasmtypes.MsgServer } -func (s *IntegrationTestSuite) SetupTest() { +func (s *KeeperTestSuite) SetupTest() { nibiruApp, ctx := testapp.NewNibiruTestAppAndContext() s.app = nibiruApp s.ctx = ctx @@ -52,16 +52,16 @@ func (s *IntegrationTestSuite) SetupTest() { s.wasmMsgServer = wasmkeeper.NewMsgServerImpl(&s.app.WasmKeeper) } -func (s *IntegrationTestSuite) SetupSuite() { +func (s *KeeperTestSuite) SetupSuite() { s.SetupTest() } -func (s *IntegrationTestSuite) FundAccount( +func (s *KeeperTestSuite) FundAccount( ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins, ) error { return testapp.FundAccount(s.app.BankKeeper, ctx, addr, amounts) } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) + suite.Run(t, new(KeeperTestSuite)) } diff --git a/x/devgas/v1/keeper/msg_server_test.go b/x/devgas/v1/keeper/msg_server_test.go index 68b7e34a1..ee62a7495 100644 --- a/x/devgas/v1/keeper/msg_server_test.go +++ b/x/devgas/v1/keeper/msg_server_test.go @@ -20,7 +20,7 @@ import ( //go:embed testdata/reflect.wasm var wasmContract []byte -func (s *IntegrationTestSuite) StoreCode() { +func (s *KeeperTestSuite) StoreCode() { _, _, sender := testdata.KeyTestPubAddr() msg := wasmtypes.MsgStoreCodeFixture(func(m *wasmtypes.MsgStoreCode) { m.WASMByteCode = wasmContract @@ -41,7 +41,7 @@ func (s *IntegrationTestSuite) StoreCode() { s.Require().Equal(wasmtypes.DefaultParams().InstantiateDefaultPermission.With(sender), info.InstantiateConfig) } -func (s *IntegrationTestSuite) InstantiateContract(sender string, admin string) string { +func (s *KeeperTestSuite) InstantiateContract(sender string, admin string) string { msgStoreCode := wasmtypes.MsgStoreCodeFixture(func(m *wasmtypes.MsgStoreCode) { m.WASMByteCode = wasmContract m.Sender = sender @@ -66,7 +66,7 @@ func (s *IntegrationTestSuite) InstantiateContract(sender string, admin string) return result.Address } -func (s *IntegrationTestSuite) TestGetContractAdminOrCreatorAddress() { +func (s *KeeperTestSuite) TestGetContractAdminOrCreatorAddress() { _, _, sender := testdata.KeyTestPubAddr() _, _, admin := testdata.KeyTestPubAddr() _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) @@ -117,7 +117,7 @@ func (s *IntegrationTestSuite) TestGetContractAdminOrCreatorAddress() { } } -func (s *IntegrationTestSuite) TestRegisterFeeShare() { +func (s *KeeperTestSuite) TestRegisterFeeShare() { _, _, sender := testdata.KeyTestPubAddr() _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) @@ -245,7 +245,7 @@ func (s *IntegrationTestSuite) TestRegisterFeeShare() { } } -func (s *IntegrationTestSuite) TestUpdateFeeShare() { +func (s *KeeperTestSuite) TestUpdateFeeShare() { _, _, sender := testdata.KeyTestPubAddr() _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) @@ -342,7 +342,7 @@ func (s *IntegrationTestSuite) TestUpdateFeeShare() { } } -func (s *IntegrationTestSuite) TestCancelFeeShare() { +func (s *KeeperTestSuite) TestCancelFeeShare() { _, _, sender := testdata.KeyTestPubAddr() _ = s.FundAccount(s.ctx, sender, sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1_000_000)))) @@ -409,7 +409,7 @@ func (s *IntegrationTestSuite) TestCancelFeeShare() { } } -func (s *IntegrationTestSuite) TestUpdateParams() { +func (s *KeeperTestSuite) TestUpdateParams() { govModuleAddr := authtypes.NewModuleAddress(govtypes.ModuleName).String() goCtx := sdk.WrapSDKContext(s.ctx) diff --git a/x/perp/v2/client/cli/cli_test.go b/x/perp/v2/client/cli/cli_test.go index 55fca13da..95bf784ef 100644 --- a/x/perp/v2/client/cli/cli_test.go +++ b/x/perp/v2/client/cli/cli_test.go @@ -15,6 +15,7 @@ import ( "github.com/NibiruChain/nibiru/x/common" "github.com/NibiruChain/nibiru/x/common/asset" "github.com/NibiruChain/nibiru/x/common/denoms" + "github.com/NibiruChain/nibiru/x/common/testutil" testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli" "github.com/NibiruChain/nibiru/x/common/testutil/genesis" oracletypes "github.com/NibiruChain/nibiru/x/oracle/types" @@ -32,16 +33,7 @@ type IntegrationTestSuite struct { } func (s *IntegrationTestSuite) SetupSuite() { - /* Make test skip if -short is not used: - All tests: `go test ./...` - Unit tests only: `go test ./... -short` - Integration tests only: `go test ./... -run Integration` - https://stackoverflow.com/a/41407042/13305627 */ - if testing.Short() { - s.T().Skip("skipping integration test suite") - } - - s.T().Log("setting up integration test suite") + testutil.BeforeIntegrationSuite(s.T()) app.SetPrefixes(app.AccountAddressPrefix) diff --git a/x/spot/client/testutil/suite.go b/x/spot/client/testutil/suite.go index decff8fc0..8df087127 100644 --- a/x/spot/client/testutil/suite.go +++ b/x/spot/client/testutil/suite.go @@ -12,6 +12,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/suite" + "github.com/NibiruChain/nibiru/x/common/testutil" testutilcli "github.com/NibiruChain/nibiru/x/common/testutil/cli" "github.com/NibiruChain/nibiru/x/spot/client/cli" "github.com/NibiruChain/nibiru/x/spot/types" @@ -30,16 +31,7 @@ func NewIntegrationTestSuite(homeDir string, cfg testutilcli.Config) *Integratio } func (s *IntegrationTestSuite) SetupSuite() { - /* Make test skip if -short is not used: - All tests: `go test ./...` - Unit tests only: `go test ./... -short` - Integration tests only: `go test ./... -run Integration` - https://stackoverflow.com/a/41407042/13305627 */ - if testing.Short() { - s.T().Skip("skipping integration test suite") - } - - s.T().Log("setting up integration test suite") + testutil.BeforeIntegrationSuite(s.T()) network, err := testutilcli.New( s.T(), diff --git a/x/sudo/cli/cli_test.go b/x/sudo/cli/cli_test.go index 4b365575c..defafd0b1 100644 --- a/x/sudo/cli/cli_test.go +++ b/x/sudo/cli/cli_test.go @@ -101,6 +101,7 @@ func TestSuite_IntegrationSuite_RunAll(t *testing.T) { // ——————————————————————————————————————————————————————————————————— func (s *IntegrationSuite) SetupSuite() { + testutil.BeforeIntegrationSuite(s.T()) app.SetPrefixes(app.AccountAddressPrefix) genState := genesis.NewTestGenesisState(app.MakeEncodingConfig()) diff --git a/x/tokenfactory/cli/cli_test.go b/x/tokenfactory/cli/cli_test.go index c7b90b03b..fb99138a6 100644 --- a/x/tokenfactory/cli/cli_test.go +++ b/x/tokenfactory/cli/cli_test.go @@ -39,16 +39,7 @@ func (s *IntegrationTestSuite) TestTokenFactory() { } func (s *IntegrationTestSuite) SetupSuite() { - // Make test skip if -short is not used: - // All tests: `go test ./...` - // Unit tests only: `go test ./... -short` - // Integration tests only: `go test ./... -run Integration` - // See: https://stackoverflow.com/a/41407042/13305627 - if testing.Short() { - s.T().Skip("skipping integration test suite") - } - - s.T().Log("setting up integration test suite") + testutil.BeforeIntegrationSuite(s.T()) testapp.EnsureNibiruPrefix() encodingConfig := app.MakeEncodingConfig() From 6a1a459a8306974bb28ad6acb0e0ffd998eed07a Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Fri, 27 Oct 2023 17:03:05 -0500 Subject: [PATCH 2/8] change log --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 252fcb64e..0053efbe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1631](https://github.com/NibiruChain/nibiru/pull/1631) - fix(.goreleaser.yml): Load version for wasmvm dynamically. * [#1638](https://github.com/NibiruChain/nibiru/pull/1638) - test(tokenfactory): integration test core logic with a real smart contract using `nibiru-std` * [#1639](https://github.com/NibiruChain/nibiru/pull/1639) - fix(perp): by default, disable new markets until they are toggled on. +* [#1652](https://github.com/NibiruChain/nibiru/pull/1652) - test: refactors cli.network suites with 'Integration' to use common function ### Dependencies - Bump `github.com/prometheus/client_golang` from 1.16.0 to 1.17.0 ([#1605](https://github.com/NibiruChain/nibiru/pull/1605)) @@ -779,4 +780,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Testing * [#695](https://github.com/NibiruChain/nibiru/pull/695) Add `OpenPosition` integration tests. -* [#692](https://github.com/NibiruChain/nibiru/pull/692) Add test coverage for Perp MsgServer methods. \ No newline at end of file +* [#692](https://github.com/NibiruChain/nibiru/pull/692) Add test coverage for Perp MsgServer methods. From de8acbfdbf1ee4f628ba6a84753ae5ab6070040a Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Fri, 27 Oct 2023 17:38:03 -0500 Subject: [PATCH 3/8] linter --- x/spot/client/testutil/suite.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/spot/client/testutil/suite.go b/x/spot/client/testutil/suite.go index 8df087127..c1ade770d 100644 --- a/x/spot/client/testutil/suite.go +++ b/x/spot/client/testutil/suite.go @@ -2,7 +2,6 @@ package testutil import ( "fmt" - "testing" sdkmath "cosmossdk.io/math" From 932cface9605e517d2faaa05fc7dfda8b27b3843 Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Sat, 28 Oct 2023 16:17:50 -0500 Subject: [PATCH 4/8] test fix to use correct bech32 prefix --- x/sudo/cli/gen_root_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/sudo/cli/gen_root_test.go b/x/sudo/cli/gen_root_test.go index ef21536ca..68458a548 100644 --- a/x/sudo/cli/gen_root_test.go +++ b/x/sudo/cli/gen_root_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" "github.com/NibiruChain/nibiru/x/common/testutil" + "github.com/NibiruChain/nibiru/x/common/testutil/testapp" "github.com/NibiruChain/nibiru/x/sudo/cli" ) @@ -26,6 +27,7 @@ func TestAddSudoRootAccountCmd(t *testing.T) { for _, tc := range tests { tc := tc t.Run(tc.name, func(t *testing.T) { + testapp.EnsureNibiruPrefix() ctx := testutil.SetupClientCtx(t) cmd := cli.AddSudoRootAccountCmd(t.TempDir()) cmd.SetArgs([]string{ From 65d43d38de3d85e282cb8272d2746f70029499a3 Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Sat, 28 Oct 2023 16:43:33 -0500 Subject: [PATCH 5/8] test: make it so that simulations don't need to be fitered for explicitly --- .github/workflows/unit-tests.yml | 18 ++++++------ contrib/make/test.mk | 10 ++++--- simapp/sim_test.go | 47 ++++++++++++++++++++++++-------- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c91bf48af..febdcf890 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -4,7 +4,7 @@ on: pull_request: paths: ["**.go", "**.proto", "go.mod", "go.sum"] -# Allow concurrent runs on main/release branches but isolates other branches +# Allow concurrent runs on main/release branches but isolates other branches concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }} cancel-in-progress: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }} @@ -22,17 +22,17 @@ jobs: cache: true - name: Run all unit tests. - run: make test-coverage + run: make test-unit build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 1.19 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.19 - - name: Build the nibid binary - run: make build + - name: Build the nibid binary + run: make build diff --git a/contrib/make/test.mk b/contrib/make/test.mk index 0b64c37c6..766d98dd5 100644 --- a/contrib/make/test.mk +++ b/contrib/make/test.mk @@ -2,11 +2,13 @@ # Tests ######################################################################### -PACKAGES_NOSIMULATION = ${shell go list ./... | grep -v simapp} +.PHONY: test-unit +test-unit: + go test ./... -short -.PHONY: test-coverage -test-coverage: - go test ./... $(PACKAGES_NOSIMULATION) -short \ +.PHONY: test-coverage-unit +test-coverage-unit: + go test ./... -short \ -coverprofile=coverage.txt \ -covermode=atomic \ -race diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 2b0871a94..7f3dfeb98 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -16,20 +16,45 @@ import ( "github.com/cosmos/cosmos-sdk/x/simulation" simcli "github.com/cosmos/cosmos-sdk/x/simulation/client/cli" "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" "github.com/NibiruChain/nibiru/app" appsim "github.com/NibiruChain/nibiru/app/sim" + "github.com/NibiruChain/nibiru/x/common/testutil" "github.com/NibiruChain/nibiru/x/common/testutil/testapp" ) // SimAppChainID hardcoded chainID for simulation const SimAppChainID = "simulation-app" -func init() { +type SimulationTestSuite struct { + suite.Suite +} + +func TestSimulationTestSuite(t *testing.T) { + suite.Run(t, new(SimulationTestSuite)) +} + +var _ suite.SetupTestSuite = (*SimulationTestSuite)(nil) +var _ suite.SetupAllSuite = (*SimulationTestSuite)(nil) + +// SetupSuite: Runs before the entire test suite. +func (s *SimulationTestSuite) SetupSuite() { + // We call GetSimulatorFlags here in order to set the value for + // 'simapp.FlagEnabledValue', which enables simulations appsim.GetSimulatorFlags() } -func TestFullAppSimulation(tb *testing.T) { +// SetupTest: Runs before every test in the suite. +func (s *SimulationTestSuite) SetupTest() { + testutil.BeforeIntegrationSuite(s.T()) + if !simapp.FlagEnabledValue { + s.T().Skip("skipping application simulation") + } +} + +func (s *SimulationTestSuite) TestFullAppSimulation() { + t := s.T() config := simcli.NewConfigFromFlags() config.ChainID = SimAppChainID @@ -40,15 +65,15 @@ func TestFullAppSimulation(tb *testing.T) { simcli.FlagVerboseValue, simcli.FlagEnabledValue, ) if skip { - tb.Skip("skipping application simulation") + t.Skip("skipping application simulation") } - require.NoError(tb, err, "simulation setup failed") + require.NoError(t, err, "simulation setup failed") defer func() { db.Close() err = os.RemoveAll(dir) if err != nil { - tb.Fatal(err) + t.Fatal(err) } }() @@ -57,7 +82,7 @@ func TestFullAppSimulation(tb *testing.T) { // Run randomized simulation: _, simParams, simErr := simulation.SimulateFromSeed( - /* tb */ tb, + /* tb */ t, /* w */ os.Stdout, /* app */ app.BaseApp, /* appStateFn */ AppStateFn(app.AppCodec(), app.SimulationManager()), @@ -70,11 +95,11 @@ func TestFullAppSimulation(tb *testing.T) { // export state and simParams before the simulation error is checked if err = helpers.CheckExportSimulation(app, config, simParams); err != nil { - tb.Fatal(err) + t.Fatal(err) } if simErr != nil { - tb.Fatal(simErr) + t.Fatal(simErr) } if config.Commit { @@ -82,10 +107,8 @@ func TestFullAppSimulation(tb *testing.T) { } } -func TestAppStateDeterminism(t *testing.T) { - if !simapp.FlagEnabledValue { - t.Skip("skipping application simulation") - } +func (s *SimulationTestSuite) TestAppStateDeterminism() { + t := s.T() encoding := app.MakeEncodingConfig() From 5a0347a8030c11f10c0318979926f4a329226cda Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Sat, 28 Oct 2023 16:57:44 -0500 Subject: [PATCH 6/8] test(simapp): flag retrieval must be inside the fn --- simapp/sim_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 7f3dfeb98..5454d709d 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -36,10 +36,8 @@ func TestSimulationTestSuite(t *testing.T) { } var _ suite.SetupTestSuite = (*SimulationTestSuite)(nil) -var _ suite.SetupAllSuite = (*SimulationTestSuite)(nil) -// SetupSuite: Runs before the entire test suite. -func (s *SimulationTestSuite) SetupSuite() { +func init() { // We call GetSimulatorFlags here in order to set the value for // 'simapp.FlagEnabledValue', which enables simulations appsim.GetSimulatorFlags() From 376ca24413395d345aec97ae78707d2b4c4ce413 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Sun, 29 Oct 2023 12:39:24 -0500 Subject: [PATCH 7/8] typo: Update cases.go --- x/common/testutil/cases.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/common/testutil/cases.go b/x/common/testutil/cases.go index cb0553754..547738d00 100644 --- a/x/common/testutil/cases.go +++ b/x/common/testutil/cases.go @@ -20,7 +20,7 @@ func RunFunctionTests(t *testing.T, testCases []FunctionTestCase) { } /* -BeforeIntegrationSuite: Skips a test if the `-short` flag is not used: +BeforeIntegrationSuite: Skips a test if the `-short` flag is used: All tests: `go test ./...` Unit tests only: `go test ./... -short` From 22a4865a885eb6a6dbcc0b2717dd0aba9caac81b Mon Sep 17 00:00:00 2001 From: Unique-Divine Date: Wed, 1 Nov 2023 09:55:44 -0500 Subject: [PATCH 8/8] test(cases.go) --- x/common/testutil/cases_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 x/common/testutil/cases_test.go diff --git a/x/common/testutil/cases_test.go b/x/common/testutil/cases_test.go new file mode 100644 index 000000000..3cef90842 --- /dev/null +++ b/x/common/testutil/cases_test.go @@ -0,0 +1,29 @@ +package testutil_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/NibiruChain/nibiru/x/common/testutil" +) + +func TestRunFunctionTests(t *testing.T) { + testutil.RunFunctionTests(t, testutil.FunctionTestCases{ + { + Name: "test case A", + Test: func() { + }, + }, + }) +} + +func TestBeforeIntegrationSuite(t *testing.T) { + testutil.BeforeIntegrationSuite(t) + + if testing.Short() { + require.True(t, t.Skipped()) + } else { + require.False(t, t.Skipped()) + } +}