From 90eb8fe74de2aa5e4f0007aee6a1e9d91abd8228 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 3 May 2023 14:49:36 +0700 Subject: [PATCH 1/3] use thelper in golangci-lint without linting every test --- .golangci.yml | 1 + simulation/executor/log.go | 1 + simulation/executor/simulate.go | 4 +++- simulation/executor/simulate_dev.go | 3 ++- simulation/executor/util.go | 1 + tests/e2e/configurer/chain/chain.go | 1 + tests/e2e/configurer/chain/node.go | 1 + tests/e2e/configurer/current.go | 1 + tests/e2e/configurer/factory.go | 1 + tests/e2e/configurer/upgrade.go | 1 + tests/e2e/containers/containers.go | 5 +++++ x/poolmanager/client/testutil/test_helpers.go | 1 + x/txfees/keeper/keeper_test.go | 2 +- 13 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 27fdada5b66..5d9cde87231 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -35,6 +35,7 @@ linters: - staticcheck - stylecheck - tenv + - thelper - testpackage - typecheck - unconvert diff --git a/simulation/executor/log.go b/simulation/executor/log.go index d429497a484..000c39c5178 100644 --- a/simulation/executor/log.go +++ b/simulation/executor/log.go @@ -16,6 +16,7 @@ type LogWriter interface { // LogWriter - return a dummy or standard log writer given the testingmode func NewLogWriter(tb testing.TB) LogWriter { + tb.Helper() // TODO: Figure out whats going on / why here testingMode, _, _ := getTestingMode(tb) diff --git a/simulation/executor/simulate.go b/simulation/executor/simulate.go index ef65f3ab6b6..ffc060ad5f4 100644 --- a/simulation/executor/simulate.go +++ b/simulation/executor/simulate.go @@ -45,6 +45,7 @@ func SimulateFromSeed( initFunctions InitFunctions, config Config, ) (lastCommitId storetypes.CommitID, stopEarly bool, err error) { + tb.Helper() // in case we have to end early, don't os.Exit so that we can run cleanup code. // TODO: Understand exit pattern, this is so screwed up. Then delete ^ @@ -122,6 +123,7 @@ func cursedInitializationLogic( initFunctions InitFunctions, config *Config, ) (*simtypes.SimCtx, *simState, Params, error) { + tb.Helper() fmt.Fprintf(w, "Starting SimulateFromSeed with randomness created with seed %d\n", int(config.Seed)) r := rand.New(rand.NewSource(config.Seed)) @@ -156,7 +158,7 @@ func cursedInitializationLogic( // must set version in order to generate hashes initialHeader.Version.Block = 11 - simState := newSimulatorState(simParams, initialHeader, tb, w, validators, *config) + simState := newSimulatorState(tb, simParams, initialHeader, w, validators, *config) // TODO: If simulation has a param export path configured, export params here. diff --git a/simulation/executor/simulate_dev.go b/simulation/executor/simulate_dev.go index da0584e3e99..0f629e1e78c 100644 --- a/simulation/executor/simulate_dev.go +++ b/simulation/executor/simulate_dev.go @@ -50,7 +50,8 @@ type simState struct { config Config } -func newSimulatorState(simParams Params, initialHeader tmproto.Header, tb testing.TB, w io.Writer, validators mockValidators, config Config) *simState { +func newSimulatorState(tb testing.TB, simParams Params, initialHeader tmproto.Header, w io.Writer, validators mockValidators, config Config) *simState { + tb.Helper() return &simState{ simParams: simParams, header: initialHeader, diff --git a/simulation/executor/util.go b/simulation/executor/util.go index f9b777fd5bf..d0d886aa425 100644 --- a/simulation/executor/util.go +++ b/simulation/executor/util.go @@ -9,6 +9,7 @@ import ( ) func getTestingMode(tb testing.TB) (testingMode bool, t *testing.T, b *testing.B) { + tb.Helper() testingMode = false if _t, ok := tb.(*testing.T); ok { diff --git a/tests/e2e/configurer/chain/chain.go b/tests/e2e/configurer/chain/chain.go index ace37b761b6..2d7f2319be7 100644 --- a/tests/e2e/configurer/chain/chain.go +++ b/tests/e2e/configurer/chain/chain.go @@ -59,6 +59,7 @@ const ( ) func New(t *testing.T, containerManager *containers.Manager, id string, initValidatorConfigs []*initialization.NodeConfig) *Config { + t.Helper() numVal := float32(len(initValidatorConfigs)) return &Config{ ChainMeta: initialization.ChainMeta{ diff --git a/tests/e2e/configurer/chain/node.go b/tests/e2e/configurer/chain/node.go index 425902ba8df..d71629ea544 100644 --- a/tests/e2e/configurer/chain/node.go +++ b/tests/e2e/configurer/chain/node.go @@ -32,6 +32,7 @@ type NodeConfig struct { // NewNodeConfig returens new initialized NodeConfig. func NewNodeConfig(t *testing.T, initNode *initialization.Node, initConfig *initialization.NodeConfig, chainId string, containerManager *containers.Manager) *NodeConfig { + t.Helper() return &NodeConfig{ Node: *initNode, SnapshotInterval: initConfig.SnapshotInterval, diff --git a/tests/e2e/configurer/current.go b/tests/e2e/configurer/current.go index 31c0bcf1cd7..d344c84041a 100644 --- a/tests/e2e/configurer/current.go +++ b/tests/e2e/configurer/current.go @@ -17,6 +17,7 @@ type CurrentBranchConfigurer struct { var _ Configurer = (*CurrentBranchConfigurer)(nil) func NewCurrentBranchConfigurer(t *testing.T, chainConfigs []*chain.Config, setupTests setupFn, containerManager *containers.Manager) Configurer { + t.Helper() return &CurrentBranchConfigurer{ baseConfigurer: baseConfigurer{ chainConfigs: chainConfigs, diff --git a/tests/e2e/configurer/factory.go b/tests/e2e/configurer/factory.go index 4e902ef946c..c745430b836 100644 --- a/tests/e2e/configurer/factory.go +++ b/tests/e2e/configurer/factory.go @@ -106,6 +106,7 @@ var ( // - If !isIBCEnabled and !isUpgradeEnabled, we only need one chain at the current // Git branch version of the Osmosis code. func New(t *testing.T, isIBCEnabled, isDebugLogEnabled bool, upgradeSettings UpgradeSettings) (Configurer, error) { + t.Helper() containerManager, err := containers.NewManager(upgradeSettings.IsEnabled, upgradeSettings.ForkHeight > 0, isDebugLogEnabled) if err != nil { return nil, err diff --git a/tests/e2e/configurer/upgrade.go b/tests/e2e/configurer/upgrade.go index db913239d32..c137bcc6cdd 100644 --- a/tests/e2e/configurer/upgrade.go +++ b/tests/e2e/configurer/upgrade.go @@ -31,6 +31,7 @@ type UpgradeConfigurer struct { var _ Configurer = (*UpgradeConfigurer)(nil) func NewUpgradeConfigurer(t *testing.T, chainConfigs []*chain.Config, setupTests setupFn, containerManager *containers.Manager, upgradeVersion string, forkHeight int64) Configurer { + t.Helper() return &UpgradeConfigurer{ baseConfigurer: baseConfigurer{ chainConfigs: chainConfigs, diff --git a/tests/e2e/containers/containers.go b/tests/e2e/containers/containers.go index 1a8a63cf3f8..ee716c7c38b 100644 --- a/tests/e2e/containers/containers.go +++ b/tests/e2e/containers/containers.go @@ -72,6 +72,7 @@ func NewManager(isUpgrade bool, isFork bool, isDebugLogEnabled bool) (docker *Ma // ExecTxCmd Runs ExecTxCmdWithSuccessString searching for `code: 0` func (m *Manager) ExecTxCmd(t *testing.T, chainId string, containerName string, command []string) (bytes.Buffer, bytes.Buffer, error) { + t.Helper() return m.ExecTxCmdWithSuccessString(t, chainId, containerName, command, "code: 0") } @@ -79,6 +80,7 @@ func (m *Manager) ExecTxCmd(t *testing.T, chainId string, containerName string, // namely adding flags `--chain-id={chain-id} -b=block --yes --keyring-backend=test "--log_format=json" --gas=400000`, // and searching for `successStr` func (m *Manager) ExecTxCmdWithSuccessString(t *testing.T, chainId string, containerName string, command []string, successStr string) (bytes.Buffer, bytes.Buffer, error) { + t.Helper() allTxArgs := []string{fmt.Sprintf("--chain-id=%s", chainId)} allTxArgs = append(allTxArgs, txArgs...) // parse to see if command has gas flags. If not, add default gas flags. @@ -97,6 +99,7 @@ func (m *Manager) ExecTxCmdWithSuccessString(t *testing.T, chainId string, conta // ExecHermesCmd executes command on the hermes relaer container. func (m *Manager) ExecHermesCmd(t *testing.T, command []string, success string) (bytes.Buffer, bytes.Buffer, error) { + t.Helper() return m.ExecCmd(t, hermesContainerName, command, success) } @@ -106,9 +109,11 @@ func (m *Manager) ExecHermesCmd(t *testing.T, command []string, success string) // returns container std out, container std err, and error if any. // An error is returned if the command fails to execute or if the success string is not found in the output. func (m *Manager) ExecCmd(t *testing.T, containerName string, command []string, success string) (bytes.Buffer, bytes.Buffer, error) { + t.Helper() if _, ok := m.resources[containerName]; !ok { return bytes.Buffer{}, bytes.Buffer{}, fmt.Errorf("no resource %s found", containerName) } + t.Helper() containerId := m.resources[containerName].Container.ID var ( diff --git a/x/poolmanager/client/testutil/test_helpers.go b/x/poolmanager/client/testutil/test_helpers.go index 16978f5527c..b583cd9268c 100644 --- a/x/poolmanager/client/testutil/test_helpers.go +++ b/x/poolmanager/client/testutil/test_helpers.go @@ -36,6 +36,7 @@ func MsgCreatePool( futureGovernor string, extraArgs ...string, ) (testutil.BufferWriter, error) { + t.Helper() args := []string{} jsonFile := testutil.WriteToNewTempFile(t, diff --git a/x/txfees/keeper/keeper_test.go b/x/txfees/keeper/keeper_test.go index 8df6eb46185..762c8440d61 100644 --- a/x/txfees/keeper/keeper_test.go +++ b/x/txfees/keeper/keeper_test.go @@ -34,7 +34,7 @@ func (suite *KeeperTestSuite) SetupTest(isCheckTx bool) { WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). WithLegacyAmino(encodingConfig.Amino). - WithJSONCodec(encodingConfig.Marshaler) + WithCodec(encodingConfig.Marshaler) // Mint some assets to the accounts. for _, acc := range suite.TestAccs { From 85150643424a101c9a287ff75f2190718df129b6 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Wed, 3 May 2023 16:25:35 +0700 Subject: [PATCH 2/3] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd1dff88aaf..1409459733d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Misc Improvements + * [#5064](https://github.com/osmosis-labs/osmosis/pull/5064) Use thelper in golangci-lint without linting every test * [#4549](https://github.com/osmosis-labs/osmosis/pull/4549) Add single pool price estimate queries * [#4767](https://github.com/osmosis-labs/osmosis/pull/4767) Disable create pool with non-zero exit fee * [#4847](https://github.com/osmosis-labs/osmosis/pull/4847) Update `make build` command to build only `osmosisd` binary From 3e24830bba5414cfe4470fb0847d66805bb947e9 Mon Sep 17 00:00:00 2001 From: Jacob Gadikian Date: Sun, 7 May 2023 08:24:17 +0700 Subject: [PATCH 3/3] Update tests/e2e/containers/containers.go Co-authored-by: Roman --- tests/e2e/containers/containers.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/containers/containers.go b/tests/e2e/containers/containers.go index ee716c7c38b..ac5611384ff 100644 --- a/tests/e2e/containers/containers.go +++ b/tests/e2e/containers/containers.go @@ -113,7 +113,6 @@ func (m *Manager) ExecCmd(t *testing.T, containerName string, command []string, if _, ok := m.resources[containerName]; !ok { return bytes.Buffer{}, bytes.Buffer{}, fmt.Errorf("no resource %s found", containerName) } - t.Helper() containerId := m.resources[containerName].Container.ID var (