-
Notifications
You must be signed in to change notification settings - Fork 611
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove gofumpt from required lints, directly use it in make format (#…
…1318) ## What is the purpose of the change Closes: #1309 , context is in the issue. TL;DR, remove gofumpt from being required in CI due to barriers to entry / lack of ease of use with default IDE setups. Its kept in make format, and make format is intended to be ran pre-releases ## Brief change log Remove gofumpt from being required. ## Testing and Verifying This change is a trivial rework / code cleanup without any test coverage. ## Documentation and Release Note - Does this pull request introduce a new feature or user-facing behavior changes? yes - Is a relevant changelog entry added to the `Unreleased` section in `CHANGELOG.md`? No -- This is not done, as gofumpt was also added in unreleased code, so this is no net change - How is the feature or change documented? N/A (cherry picked from commit ed10116) # Conflicts: # .golangci.yml # .vscode/settings.json # Makefile # x/epochs/types/hooks_test.go
- Loading branch information
1 parent
17afb0b
commit 6a20b57
Showing
5 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"tabnine.experimentalAutoImports": true, | ||
"go.lintTool": "golangci-lint", | ||
"go.formatTool": "goimports", | ||
"go.useLanguageServer": true, | ||
"[go.mod]": { | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
} | ||
}, | ||
"[go]": { | ||
"editor.snippetSuggestions": "none", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
} | ||
}, | ||
"gopls": { | ||
"local": "github.com/osmosis-labs/osmosis" | ||
}, | ||
"files.eol": "\n", | ||
"[proto3]": { | ||
"editor.defaultFormatter": "xaver.clang-format" | ||
}, | ||
"clang-format.style": "{BasedOnStyle: Google, IndentWidth: 2, ColumnLimit: 120, AlignConsecutiveAssignments: true, AlignConsecutiveDeclarations: true, SpacesInSquareBrackets: true}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/osmosis-labs/osmosis/v7/app/apptesting" | ||
"github.com/osmosis-labs/osmosis/v7/x/epochs/types" | ||
) | ||
|
||
type KeeperTestSuite struct { | ||
apptesting.KeeperTestHelper | ||
|
||
queryClient types.QueryClient | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(KeeperTestSuite)) | ||
} | ||
|
||
func (suite *KeeperTestSuite) SetupTest() { | ||
suite.Setup() | ||
|
||
suite.queryClient = types.NewQueryClient(suite.QueryHelper) | ||
} | ||
|
||
// dummyEpochHook is a struct satisfying the epoch hook interface, | ||
// that maintains a counter for how many times its been succesfully called, | ||
// and a boolean for whether it should panic during its execution. | ||
type dummyEpochHook struct { | ||
successCounter int | ||
shouldPanic bool | ||
} | ||
|
||
func (hook *dummyEpochHook) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) { | ||
if hook.shouldPanic { | ||
panic("dummyEpochHook is panicking") | ||
} | ||
hook.successCounter += 1 | ||
} | ||
|
||
func (hook *dummyEpochHook) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) { | ||
if hook.shouldPanic { | ||
panic("dummyEpochHook is panicking") | ||
} | ||
hook.successCounter += 1 | ||
} | ||
|
||
func (hook *dummyEpochHook) Clone() *dummyEpochHook { | ||
newHook := dummyEpochHook{shouldPanic: hook.shouldPanic, successCounter: hook.successCounter} | ||
return &newHook | ||
} | ||
|
||
var _ types.EpochHooks = &dummyEpochHook{} | ||
|
||
func (suite *KeeperTestSuite) TestHooksPanicRecovery() { | ||
panicHook := dummyEpochHook{shouldPanic: true} | ||
noPanicHook := dummyEpochHook{shouldPanic: false} | ||
simpleHooks := []dummyEpochHook{panicHook, noPanicHook} | ||
|
||
tests := []struct { | ||
hooks []dummyEpochHook | ||
expectedCounterValues []int | ||
}{ | ||
{[]dummyEpochHook{noPanicHook}, []int{1}}, | ||
{simpleHooks, []int{0, 1}}, | ||
} | ||
|
||
for tcIndex, tc := range tests { | ||
for epochActionSelector := 0; epochActionSelector < 2; epochActionSelector++ { | ||
suite.SetupTest() | ||
hookRefs := []types.EpochHooks{} | ||
|
||
for _, hook := range tc.hooks { | ||
hookRefs = append(hookRefs, hook.Clone()) | ||
} | ||
|
||
hooks := types.NewMultiEpochHooks(hookRefs...) | ||
suite.NotPanics(func() { | ||
if epochActionSelector == 0 { | ||
hooks.BeforeEpochStart(suite.Ctx, "id", 0) | ||
} else if epochActionSelector == 1 { | ||
hooks.AfterEpochEnd(suite.Ctx, "id", 0) | ||
} | ||
}) | ||
|
||
for i := 0; i < len(hooks); i++ { | ||
epochHook := hookRefs[i].(*dummyEpochHook) | ||
suite.Require().Equal(tc.expectedCounterValues[i], epochHook.successCounter, "test case index %d", tcIndex) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters