From 5d2968e8c42b560628278e7219484e34ea495395 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Tue, 13 Aug 2024 19:42:34 -0400 Subject: [PATCH 1/5] chore(schema/testing): upgrade to go 1.23 iterators --- .github/workflows/test.yml | 2 +- schema/testing/go.mod | 2 +- schema/testing/statesim/app_diff.go | 12 +++++------- schema/testing/statesim/module_diff.go | 12 +++++------- schema/testing/statesim/object_coll_diff.go | 15 ++++++--------- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 92c9914c14dc..f0bf2625d9f1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -485,7 +485,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" cache: true cache-dependency-path: schema/testing/go.sum - uses: technote-space/get-diff-action@v6.1.2 diff --git a/schema/testing/go.mod b/schema/testing/go.mod index e1cfc343bcdf..e6693e96a163 100644 --- a/schema/testing/go.mod +++ b/schema/testing/go.mod @@ -17,4 +17,4 @@ require ( replace cosmossdk.io/schema => ./.. -go 1.22 +go 1.23 diff --git a/schema/testing/statesim/app_diff.go b/schema/testing/statesim/app_diff.go index 93735093a7db..82628e550293 100644 --- a/schema/testing/statesim/app_diff.go +++ b/schema/testing/statesim/app_diff.go @@ -27,21 +27,21 @@ func DiffAppStates(expected, actual view.AppState) string { res += fmt.Sprintf("MODULE COUNT ERROR: expected %d, got %d\n", expectNumModules, actualNumModules) } - expected.Modules(func(expectedMod view.ModuleState, err error) bool { + for expectedMod, err := range expected.Modules { if err != nil { res += fmt.Sprintf("ERROR getting expected module: %s\n", err) - return true + continue } moduleName := expectedMod.ModuleName() actualMod, err := actual.GetModule(moduleName) if err != nil { res += fmt.Sprintf("ERROR getting actual module: %s\n", err) - return true + continue } if actualMod == nil { res += fmt.Sprintf("Module %s: actual module NOT FOUND\n", moduleName) - return true + continue } diff := DiffModuleStates(expectedMod, actualMod) @@ -49,9 +49,7 @@ func DiffAppStates(expected, actual view.AppState) string { res += "Module " + moduleName + "\n" res += indentAllLines(diff) } - - return true - }) + } return res } diff --git a/schema/testing/statesim/module_diff.go b/schema/testing/statesim/module_diff.go index 29ee19fb01a9..6570b900be29 100644 --- a/schema/testing/statesim/module_diff.go +++ b/schema/testing/statesim/module_diff.go @@ -27,21 +27,21 @@ func DiffModuleStates(expected, actual view.ModuleState) string { res += fmt.Sprintf("OBJECT COLLECTION COUNT ERROR: expected %d, got %d\n", expectedNumObjectCollections, actualNumObjectCollections) } - expected.ObjectCollections(func(expectedColl view.ObjectCollection, err error) bool { + for expectedColl, err := range expected.ObjectCollections { if err != nil { res += fmt.Sprintf("ERROR getting expected object collection: %s\n", err) - return true + continue } objTypeName := expectedColl.ObjectType().Name actualColl, err := actual.GetObjectCollection(objTypeName) if err != nil { res += fmt.Sprintf("ERROR getting actual object collection: %s\n", err) - return true + continue } if actualColl == nil { res += fmt.Sprintf("Object Collection %s: actuall collection NOT FOUND\n", objTypeName) - return true + continue } diff := DiffObjectCollections(expectedColl, actualColl) @@ -49,9 +49,7 @@ func DiffModuleStates(expected, actual view.ModuleState) string { res += "Object Collection " + objTypeName + "\n" res += indentAllLines(diff) } - - return true - }) + } return res } diff --git a/schema/testing/statesim/object_coll_diff.go b/schema/testing/statesim/object_coll_diff.go index cfd33b0b2a40..ce4f87efbef7 100644 --- a/schema/testing/statesim/object_coll_diff.go +++ b/schema/testing/statesim/object_coll_diff.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "cosmossdk.io/schema" schematesting "cosmossdk.io/schema/testing" "cosmossdk.io/schema/view" ) @@ -30,21 +29,21 @@ func DiffObjectCollections(expected, actual view.ObjectCollection) string { res += fmt.Sprintf("OBJECT COUNT ERROR: expected %d, got %d\n", expectedNumObjects, actualNumObjects) } - expected.AllState(func(expectedUpdate schema.ObjectUpdate, err error) bool { + for expectedUpdate, err := range expected.AllState { if err != nil { res += fmt.Sprintf("ERROR getting expected object: %s\n", err) - return true + continue } keyStr := fmtObjectKey(expected.ObjectType(), expectedUpdate.Key) actualUpdate, found, err := actual.GetObject(expectedUpdate.Key) if err != nil { res += fmt.Sprintf("Object %s: ERROR: %v\n", keyStr, err) - return true + continue } if !found { res += fmt.Sprintf("Object %s: NOT FOUND\n", keyStr) - return true + continue } if expectedUpdate.Delete != actualUpdate.Delete { @@ -52,7 +51,7 @@ func DiffObjectCollections(expected, actual view.ObjectCollection) string { } if expectedUpdate.Delete { - return true + continue } valueDiff := schematesting.DiffObjectValues(expected.ObjectType().ValueFields, expectedUpdate.Value, actualUpdate.Value) @@ -62,9 +61,7 @@ func DiffObjectCollections(expected, actual view.ObjectCollection) string { res += "\n" res += indentAllLines(valueDiff) } - - return true - }) + } return res } From 684cc2eae474c540f8eb0260c0077b454d93b879 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Tue, 13 Aug 2024 19:57:25 -0400 Subject: [PATCH 2/5] update lint to go 1.23 --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1b61aa2b1748..43c93dd3c4f2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@main - uses: actions/setup-go@v5 with: - go-version: "1.22.2" + go-version: "1.23.0" check-latest: true - uses: technote-space/get-diff-action@v6.1.2 id: git_diff From 19768289979f58ca0786bed3b26c3d36b0c6442c Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Tue, 13 Aug 2024 19:57:36 -0400 Subject: [PATCH 3/5] update lint to go 1.23 --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 43c93dd3c4f2..4b4ce5a76bff 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@main - uses: actions/setup-go@v5 with: - go-version: "1.23.0" + go-version: "1.23" check-latest: true - uses: technote-space/get-diff-action@v6.1.2 id: git_diff From 342eca8a42fed9f8b01ab4e92f6dddeefd619f23 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Wed, 14 Aug 2024 09:19:38 -0400 Subject: [PATCH 4/5] update golangci-lint version --- scripts/build/linting.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/linting.mk b/scripts/build/linting.mk index eeeecc484c0a..58d481a235fb 100644 --- a/scripts/build/linting.mk +++ b/scripts/build/linting.mk @@ -1,4 +1,4 @@ -golangci_version=v1.59.0 +golangci_version=v1.60.1 #? setup-pre-commit: Set pre-commit git hook setup-pre-commit: From 2fb239cfbf6d7391ef99b86f8b5935633d3a34b4 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 15 Aug 2024 22:43:39 +0200 Subject: [PATCH 5/5] tidy --- schema/testing/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/testing/go.mod b/schema/testing/go.mod index 8757584a83bc..cc96f2267fc8 100644 --- a/schema/testing/go.mod +++ b/schema/testing/go.mod @@ -18,4 +18,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace cosmossdk.io/schema => ./.. \ No newline at end of file +replace cosmossdk.io/schema => ./..