Skip to content

Commit 50c6e4a

Browse files
authored
Merge pull request #587 from faddat/faddat/testifylint
Linter pr 1: testifylint
2 parents 20e730c + 7f39401 commit 50c6e4a

13 files changed

+151
-113
lines changed

.golangci.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
1+
run:
2+
tests: true
3+
14
linters:
25
# Enable specific linter
36
# https://golangci-lint.run/usage/linters/#enabled-by-default
47
enable:
58
- gofumpt
6-
- goimports
9+
- gci
10+
- testifylint
711

812
linters-settings:
9-
goimports:
10-
local-prefixes: github.com/CosmWasm/wasmvm
13+
gci:
14+
# Section configuration to compare against.
15+
# Section names are case-insensitive and may contain parameters in ().
16+
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
17+
# If `custom-order` is `true`, it follows the order of `sections` option.
18+
# Default: ["standard", "default"]
19+
sections:
20+
- standard # Standard section: captures all standard packages.
21+
- default # Default section: contains all imports that could not be matched to another section type.
22+
- prefix(github.com/cosmos/cosmos-sdk) # Custom section: groups all imports with the specified Prefix.
23+
- prefix(github.com/cosmos/ibc-go)
24+
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
25+
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
26+
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
27+
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
28+
# Skip generated files.
29+
# Default: true
30+
skip-generated: false
31+
# Enable custom order of sections.
32+
# If `true`, make the section order the same as the order of `sections`.
33+
# Default: false
34+
custom-order: true
35+
# Drops lexical ordering for custom sections.
36+
# Default: false
37+
no-lex-order: true
38+
39+
issues:
40+
max-issues-per-linter: 0
41+
max-same-issues: 0

ibc_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func TestIBCHandshake(t *testing.T) {
109109
require.NoError(t, err)
110110
assert.NotNil(t, i.Ok)
111111
iResponse := i.Ok
112-
require.Equal(t, 0, len(iResponse.Messages))
112+
require.Empty(t, iResponse.Messages)
113113

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

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

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

@@ -332,7 +332,7 @@ func TestIBCMsgGetChannel(t *testing.T) {
332332
require.Equal(t, msg1.GetChannel(), msg4.GetChannel())
333333
require.Equal(t, msg1.GetChannel(), msg5.GetChannel())
334334
require.Equal(t, msg1.GetChannel(), msg6.GetChannel())
335-
require.Equal(t, msg1.GetChannel().Endpoint.ChannelID, CHANNEL_ID)
335+
require.Equal(t, CHANNEL_ID, msg1.GetChannel().Endpoint.ChannelID)
336336
}
337337

338338
func TestIBCMsgGetCounterVersion(t *testing.T) {

internal/api/iterator_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"sync"
77
"testing"
88

9-
"github.com/stretchr/testify/assert"
109
"github.com/stretchr/testify/require"
1110

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

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

212-
assert.Equal(t, 0, len(iteratorFrames))
211+
require.Empty(t, iteratorFrames)
213212

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

258257
// when they finish, we should have removed all frames
259-
assert.Equal(t, 0, len(iteratorFrames))
258+
require.Empty(t, iteratorFrames)
260259
}
261260

262261
func TestQueueIteratorLimit(t *testing.T) {

0 commit comments

Comments
 (0)