Skip to content

Commit 003a38c

Browse files
Merge branch 'main' into aditya/multi-payload
2 parents c3f52f3 + 1dae432 commit 003a38c

File tree

301 files changed

+9629
-9794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

301 files changed

+9629
-9794
lines changed

.golangci.yml

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ linters:
55
default: none
66
enable:
77
- errcheck
8+
- errorlint
89
- goconst
910
- gocritic
1011
- gosec
@@ -18,73 +19,78 @@ linters:
1819
- unconvert
1920
- unparam
2021
- unused
22+
- mirror
23+
- copyloopvar
24+
- iface
25+
- importas
26+
- intrange
27+
- nakedret
28+
- nilnesserr
29+
- nilnil
30+
- nonamedreturns
31+
- prealloc
32+
- predeclared
33+
- reassign
34+
- recvcheck
35+
- testifylint
36+
- testpackage
37+
- usestdlibvars
38+
- usetesting
39+
- wastedassign
2140
settings:
22-
gocritic:
23-
disabled-checks:
24-
- appendAssign
2541
gosec:
2642
excludes:
27-
- G101
28-
- G107
29-
- G115
30-
- G404
31-
confidence: medium
43+
- G107 # Url provided to HTTP request as taint input
44+
- G115 # Potential integer overflow when converting between integer types
45+
- G404 # Insecure random number source (rand)
46+
confidence: low
47+
nakedret:
48+
max-func-lines: 0
3249
revive:
3350
enable-all-rules: true
51+
# See the rule descriptions here: https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md
3452
rules:
35-
- name: redundant-import-alias
36-
disabled: true
37-
- name: use-any
53+
# Rules with configuration
54+
- name: receiver-naming
55+
disabled: false
56+
arguments:
57+
- max-length: 4
58+
- name: unhandled-error
59+
disabled: false
60+
arguments: # Disable for these ones only
61+
- fmt.Printf
62+
- fmt.Print
63+
- fmt.Println
64+
# Disabled rules
65+
# TODO: Some of these are kinda code smelly, should reconsider some of them
66+
- name: add-constant
3867
disabled: true
39-
- name: if-return
68+
- name: argument-limit
4069
disabled: true
41-
- name: max-public-structs
70+
- name: banned-characters
4271
disabled: true
4372
- name: cognitive-complexity
4473
disabled: true
45-
- name: argument-limit
74+
- name: confusing-naming
75+
disabled: true
76+
- name: confusing-results
4677
disabled: true
4778
- name: cyclomatic
4879
disabled: true
49-
- name: file-header
80+
- name: deep-exit
5081
disabled: true
5182
- name: function-length
5283
disabled: true
53-
- name: function-result-limit
54-
disabled: true
55-
- name: line-length-limit
56-
disabled: true
5784
- name: flag-parameter
5885
disabled: true
59-
- name: add-constant
60-
disabled: true
61-
- name: empty-lines
62-
disabled: true
63-
- name: banned-characters
64-
disabled: true
65-
- name: deep-exit
66-
disabled: true
67-
- name: confusing-results
68-
disabled: true
69-
- name: unused-parameter
70-
disabled: true
71-
- name: modifies-value-receiver
72-
disabled: true
73-
- name: early-return
86+
- name: function-result-limit
7487
disabled: true
75-
- name: confusing-naming
88+
- name: line-length-limit
7689
disabled: true
77-
- name: defer
90+
- name: max-public-structs
7891
disabled: true
7992
- name: unused-parameter
8093
disabled: true
81-
- name: unhandled-error
82-
arguments:
83-
- fmt.Printf
84-
- fmt.Print
85-
- fmt.Println
86-
- myFunction
87-
disabled: false
8894
exclusions:
8995
generated: lax
9096
presets:
@@ -93,25 +99,24 @@ linters:
9399
- legacy
94100
- std-error-handling
95101
rules:
96-
- linters:
97-
- revive
98-
text: differs only by capitalization to method
99-
- linters:
100-
- gosec
101-
text: Use of weak random number generator
102-
- linters:
103-
- gosec
104-
text: 'G115: integer overflow conversion'
105102
- linters:
106103
- staticcheck
107-
text: 'SA1019:'
108-
- linters:
109-
- gosec
110-
text: 'G115: integer overflow conversion'
104+
text: 'SA1019:' # TODO: This should really be removed!
105+
- path: _test\.go
106+
linters:
107+
- prealloc
108+
- path: e2e/*
109+
linters:
110+
- prealloc
111+
- testpackage
112+
- path: testing/*
113+
linters:
114+
- prealloc
111115
paths:
112116
- third_party$
113117
- builtin$
114118
- examples$
119+
- testing/mock/*
115120
issues:
116121
max-issues-per-linter: 10000
117122
max-same-issues: 10000

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This file provides guidance for automated agents contributing to this repository
3030
## Development Workflow
3131

3232
1. **Formatting and linting**
33-
- Run `make lint-all` to lint all modules
33+
- Run `make lint` to lint all modules
3434
- Run `make lint-fix` to automatically fix lint issues via `golangci-lint`.
3535
- Run `make format` to format Go code with `gofumpt`.
3636
2. **Testing**

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
3939
### Features
4040

4141
* [\#8285](https://github.com/cosmos/ibc-go/pull/8285) Packet forward middleware.
42+
* [\#8545](https://github.com/cosmos/ibc-go/pull/8545) Support sending multiple payloads in the same packet for atomic payload execution.
43+
* [\#8473](https://github.com/cosmos/ibc-go/pull/8473) Support sending v2 packets on v1 channel identifiers using aliasing.
4244

4345
### Dependencies
4446

@@ -64,8 +66,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
6466

6567
### Features
6668

67-
* [\#8545](https://github.com/cosmos/ibc-go/pull/8545) Support sending multiple payloads in the same packet for atomic payload execution.
68-
6969
### Dependencies
7070

7171
* [\#8369](https://github.com/cosmos/ibc-go/pull/8369) Bump **github.com/CosmWasm/wasmvm** to **2.2.4**

cmd/build_test_matrix/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func getGithubActionMatrixForTests(e2eRootDirectory, testName string, suite stri
9090
fset := token.NewFileSet()
9191
err := filepath.Walk(e2eRootDirectory, func(path string, info fs.FileInfo, err error) error {
9292
if err != nil {
93-
return fmt.Errorf("error walking e2e directory: %s", err)
93+
return fmt.Errorf("error walking e2e directory: %w", err)
9494
}
9595

9696
// only look at test files
@@ -100,7 +100,7 @@ func getGithubActionMatrixForTests(e2eRootDirectory, testName string, suite stri
100100

101101
f, err := parser.ParseFile(fset, path, nil, 0)
102102
if err != nil {
103-
return fmt.Errorf("failed parsing file: %s", err)
103+
return fmt.Errorf("failed parsing file: %w", err)
104104
}
105105

106106
suiteNameForFile, testCases, err := extractSuiteAndTestNames(f)

cmd/build_test_matrix/main_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"strings"
88
"testing"
99

10-
"github.com/stretchr/testify/assert"
10+
"github.com/stretchr/testify/require"
1111
)
1212

1313
const (
@@ -20,15 +20,15 @@ func TestGetGithubActionMatrixForTests(t *testing.T) {
2020
t.Run("empty dir with no test cases fails", func(t *testing.T) {
2121
testingDir := t.TempDir()
2222
_, err := getGithubActionMatrixForTests(testingDir, "", "", nil)
23-
assert.Error(t, err)
23+
require.Error(t, err)
2424
})
2525

2626
t.Run("only test functions are picked up", func(t *testing.T) {
2727
testingDir := t.TempDir()
2828
createFileWithTestSuiteAndTests(t, "FeeMiddlewareTestSuite", "TestA", "TestB", testingDir, goTestFileNameOne)
2929

3030
gh, err := getGithubActionMatrixForTests(testingDir, "", "", nil)
31-
assert.NoError(t, err)
31+
require.NoError(t, err)
3232

3333
expected := GithubActionTestMatrix{
3434
Include: []TestSuitePair{
@@ -51,7 +51,7 @@ func TestGetGithubActionMatrixForTests(t *testing.T) {
5151
createFileWithTestSuiteAndTests(t, "TransferTestSuite", "TestC", "TestD", testingDir, goTestFileNameTwo)
5252

5353
gh, err := getGithubActionMatrixForTests(testingDir, "", "", nil)
54-
assert.NoError(t, err)
54+
require.NoError(t, err)
5555

5656
expected := GithubActionTestMatrix{
5757
Include: []TestSuitePair{
@@ -83,7 +83,7 @@ func TestGetGithubActionMatrixForTests(t *testing.T) {
8383
createFileWithTestSuiteAndTests(t, "TransferTestSuite", "TestC", "TestD", testingDir, goTestFileNameTwo)
8484

8585
gh, err := getGithubActionMatrixForTests(testingDir, "TestA", "TestFeeMiddlewareTestSuite", nil)
86-
assert.NoError(t, err)
86+
require.NoError(t, err)
8787

8888
expected := GithubActionTestMatrix{
8989
Include: []TestSuitePair{
@@ -102,16 +102,16 @@ func TestGetGithubActionMatrixForTests(t *testing.T) {
102102
createFileWithTestSuiteAndTests(t, "FeeMiddlewareTestSuite", "TestA", "TestB", testingDir, goTestFileNameOne)
103103

104104
_, err := getGithubActionMatrixForTests(testingDir, "TestThatDoesntExist", "TestFeeMiddlewareTestSuite", nil)
105-
assert.Error(t, err)
105+
require.Error(t, err)
106106
})
107107

108108
t.Run("non test files are skipped", func(t *testing.T) {
109109
testingDir := t.TempDir()
110110
createFileWithTestSuiteAndTests(t, "FeeMiddlewareTestSuite", "TestA", "TestB", testingDir, nonTestFile)
111111

112112
gh, err := getGithubActionMatrixForTests(testingDir, "", "", nil)
113-
assert.Error(t, err)
114-
assert.Empty(t, gh.Include)
113+
require.Error(t, err)
114+
require.Empty(t, gh.Include)
115115
})
116116

117117
t.Run("fails when there are multiple suite runs", func(t *testing.T) {
@@ -131,10 +131,10 @@ type FeeMiddlewareTestSuite struct {}
131131
`
132132

133133
err := os.WriteFile(path.Join(testingDir, goTestFileNameOne), []byte(fileWithTwoSuites), os.FileMode(0o777))
134-
assert.NoError(t, err)
134+
require.NoError(t, err)
135135

136136
_, err = getGithubActionMatrixForTests(testingDir, "", "", nil)
137-
assert.Error(t, err)
137+
require.Error(t, err)
138138
})
139139
}
140140

@@ -159,7 +159,7 @@ func assertGithubActionTestMatricesEqual(t *testing.T, expected, actual GithubAc
159159
}
160160
return memberI.EntryPoint < memberJ.EntryPoint
161161
})
162-
assert.Equal(t, expected.Include, actual.Include)
162+
require.Equal(t, expected.Include, actual.Include)
163163
}
164164

165165
func goTestFileContents(suiteName, fnName1, fnName2 string) string {
@@ -187,5 +187,5 @@ func createFileWithTestSuiteAndTests(t *testing.T, suiteName, fn1Name, fn2Name,
187187
t.Helper()
188188
goFileContents := goTestFileContents(suiteName, fn1Name, fn2Name)
189189
err := os.WriteFile(path.Join(dir, filename), []byte(goFileContents), os.FileMode(0o777))
190-
assert.NoError(t, err)
190+
require.NoError(t, err)
191191
}

docs/dev/go-style-guide.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ b := f
5050

5151
## Linting
5252

53-
- Run `make lint-fix` to fix any linting errors.
53+
- Run `make lint` to see linting errors and `make lint-fix` to fix many issues (some linters do not support auto-fix).
5454

5555
## Various
5656

@@ -119,7 +119,7 @@ sdkerrors.Wrapf(
119119
)
120120
```
121121

122-
## Common Mistakes
122+
## Common mistakes
123123

124124
This is a compilation of some of the common mistakes we see in the repo that should be avoided.
125125

@@ -242,7 +242,7 @@ cases := []struct {
242242
243243
**Testing context**
244244
245-
Go 1.24 added a (testing.TB).Context() method. In tests, prefer using (testing.TB).Context() over context.Background() to provide the initial context.Context used by the test. Helper functions, environment or test double setup, and other functions called from the test function body that require a context should have one explicitly passed. [Referance](https://google.github.io/styleguide/go/decisions#contexts)
245+
Go 1.24 added a (testing.TB).Context() method. In tests, prefer using (testing.TB).Context() over context.Background() to provide the initial context.Context used by the test. Helper functions, environment or test double setup, and other functions called from the test function body that require a context should have one explicitly passed. [Reference](https://google.github.io/styleguide/go/decisions#contexts)
246246
247247
---
248248
**Error Logging**
@@ -253,7 +253,7 @@ If you return an error, it’s usually better not to log it yourself but rather
253253
---
254254
**Struct defined outside of the package**
255255
256-
Must have fields specified. [Referance](https://google.github.io/styleguide/go/decisions#field-names)
256+
Must have fields specified. [Reference](https://google.github.io/styleguide/go/decisions#field-names)
257257
258258
```go
259259
// Good:
@@ -270,7 +270,7 @@ r := csv.Reader{',', '#', 4, false, false, false, false}
270270
```
271271
272272
---
273-
**Naming struct fileds in tabular tests**
273+
**Naming struct fields in tabular tests**
274274
275275
If tabular test struct has more than two fields, consider explicitly naming them. If the test struct has one name and one error field, then we can allow upto three fields. If test struct has more fields, consider naming them when writing test cases.
276276
@@ -342,26 +342,13 @@ testCases := []struct {
342342
343343
## Known Anti Patterns
344344
345-
It's strongly recommended [not to create a custom context](https://google.github.io/styleguide/go/decisions#custom-contexts). The cosmos sdk has it's own context that is passed around, and we should not try to work against that pattern to avoid confusion.
345+
It's strongly recommended [not to create a custom context](https://google.github.io/styleguide/go/decisions#custom-contexts). The Cosmos SDK has it's own context that is passed around, and we should not try to work against that pattern to avoid confusion.
346346
347347
---
348-
Test outputs should include the actual value that the function returned before printing the value that was expected. A standard format for printing test outputs is YourFunc(%v) = %v, want %v. Where you would write “actual” and “expected”, prefer using the words “got” and “want”, respectively. [Referance](https://google.github.io/styleguide/go/decisions#got-before-want)
348+
Test outputs should include the actual value that the function returned before printing the value that was expected. A standard format for printing test outputs is YourFunc(%v) = %v, want %v. Where you would write “actual” and “expected”, prefer using the words “got” and “want”, respectively. [Reference](https://google.github.io/styleguide/go/decisions#got-before-want)
349349
350350
But testify has it other way around.
351351
352352
`Require.Equal(Expected, Actual)`
353353
354354
This is a known anti pattern that we allow as the testify package is used heavily in tests.
355-
356-
---
357-
In tests suites we are embedding `testify/require` package for assertions. Since it's embedded and there are no name collision on `require` types methods, when calling, we should "promote" those methods to the suite. But throughout the repo we make explicit calls.
358-
359-
```go
360-
s.Require().NoError(err)
361-
```
362-
363-
A better and more cleaner approach could be,
364-
365-
```go
366-
s.NoError(err)
367-
```

e2e/dockerutil/dockerutil.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func GetTestContainers(ctx context.Context, suiteName string, dc *dockerclient.C
2828
),
2929
})
3030
if err != nil {
31-
return nil, fmt.Errorf("failed listing containers: %s", err)
31+
return nil, fmt.Errorf("failed listing containers: %w", err)
3232
}
3333

3434
return testContainers, nil
@@ -41,7 +41,7 @@ func GetContainerLogs(ctx context.Context, dc *dockerclient.Client, containerNam
4141
ShowStderr: true,
4242
})
4343
if err != nil {
44-
return nil, fmt.Errorf("failed reading logs in test cleanup: %s", err)
44+
return nil, fmt.Errorf("failed reading logs in test cleanup: %w", err)
4545
}
4646
return io.ReadAll(readCloser)
4747
}

0 commit comments

Comments
 (0)