Skip to content

Commit

Permalink
Merge pull request #587 from faddat/faddat/testifylint
Browse files Browse the repository at this point in the history
Linter pr 1: testifylint
  • Loading branch information
chipshort authored Jan 27, 2025
2 parents 20e730c + 7f39401 commit 50c6e4a
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 113 deletions.
37 changes: 34 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
run:
tests: true

linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- gofumpt
- goimports
- gci
- testifylint

linters-settings:
goimports:
local-prefixes: github.com/CosmWasm/wasmvm
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/cosmos/cosmos-sdk) # Custom section: groups all imports with the specified Prefix.
- prefix(github.com/cosmos/ibc-go)
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: false
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
# Drops lexical ordering for custom sections.
# Default: false
no-lex-order: true

issues:
max-issues-per-linter: 0
max-same-issues: 0
10 changes: 5 additions & 5 deletions ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestIBCHandshake(t *testing.T) {
require.NoError(t, err)
assert.NotNil(t, i.Ok)
iResponse := i.Ok
require.Equal(t, 0, len(iResponse.Messages))
require.Empty(t, iResponse.Messages)

// channel open
gasMeter2 := api.NewMockGasMeter(TESTING_GAS_LIMIT)
Expand All @@ -132,7 +132,7 @@ func TestIBCHandshake(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, conn.Ok)
connResponse := conn.Ok
require.Equal(t, 1, len(connResponse.Messages))
require.Len(t, connResponse.Messages, 1)

// check for the expected custom event
expected_events := []types.Event{{
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestIBCPacketDispatch(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, conn.Ok)
connResponse := conn.Ok
require.Equal(t, 1, len(connResponse.Messages))
require.Len(t, connResponse.Messages, 1)
id := connResponse.Messages[0].ID

// mock reflect init callback (to store address)
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestIBCPacketDispatch(t *testing.T) {
var accounts ListAccountsResponse
err = json.Unmarshal(qResponse, &accounts)
require.NoError(t, err)
require.Equal(t, 1, len(accounts.Accounts))
require.Len(t, accounts.Accounts, 1)
require.Equal(t, CHANNEL_ID, accounts.Accounts[0].ChannelID)
require.Equal(t, REFLECT_ADDR, accounts.Accounts[0].Account)

Expand Down Expand Up @@ -332,7 +332,7 @@ func TestIBCMsgGetChannel(t *testing.T) {
require.Equal(t, msg1.GetChannel(), msg4.GetChannel())
require.Equal(t, msg1.GetChannel(), msg5.GetChannel())
require.Equal(t, msg1.GetChannel(), msg6.GetChannel())
require.Equal(t, msg1.GetChannel().Endpoint.ChannelID, CHANNEL_ID)
require.Equal(t, CHANNEL_ID, msg1.GetChannel().Endpoint.ChannelID)
}

func TestIBCMsgGetCounterVersion(t *testing.T) {
Expand Down
7 changes: 3 additions & 4 deletions internal/api/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"sync"
"testing"

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

"github.com/CosmWasm/wasmvm/v2/internal/api/testdb"
Expand Down Expand Up @@ -202,14 +201,14 @@ func TestQueueIteratorSimple(t *testing.T) {
err = json.Unmarshal(data, &reduced)
require.NoError(t, err)
require.Equal(t, "", reduced.Err)
require.Equal(t, `{"counters":[[17,22],[22,0]]}`, string(reduced.Ok))
require.JSONEq(t, `{"counters":[[17,22],[22,0]]}`, string(reduced.Ok))
}

func TestQueueIteratorRaces(t *testing.T) {
cache, cleanup := withCache(t)
defer cleanup()

assert.Equal(t, 0, len(iteratorFrames))
require.Empty(t, iteratorFrames)

contract1 := setupQueueContractWithData(t, cache, 17, 22)
contract2 := setupQueueContractWithData(t, cache, 1, 19, 6, 35, 8)
Expand Down Expand Up @@ -256,7 +255,7 @@ func TestQueueIteratorRaces(t *testing.T) {
wg.Wait()

// when they finish, we should have removed all frames
assert.Equal(t, 0, len(iteratorFrames))
require.Empty(t, iteratorFrames)
}

func TestQueueIteratorLimit(t *testing.T) {
Expand Down
Loading

0 comments on commit 50c6e4a

Please sign in to comment.