From 32673f6704f5a364c91d793f527bbacc6cc31d2e Mon Sep 17 00:00:00 2001 From: John Jannotti Date: Tue, 6 Dec 2022 11:26:47 -0500 Subject: [PATCH 1/2] Fix some details around the hashKind -> HashKind change --- ledger/catchpointtracker_test.go | 7 ++++--- ledger/store/hashing.go | 6 +++--- ledger/store/hashkind_string.go | 12 ++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ledger/catchpointtracker_test.go b/ledger/catchpointtracker_test.go index 473d559a05..553222b3ab 100644 --- a/ledger/catchpointtracker_test.go +++ b/ledger/catchpointtracker_test.go @@ -1353,7 +1353,7 @@ func TestSecondStageDeletesUnfinishedCatchpointRecordAfterRestart(t *testing.T) // before the change != hash calculated now. Accepting the new hash risks // breaking backwards compatibility. // -// The test also confirms each hashKind has at least 1 test case. The check +// The test also confirms each HashKind has at least 1 test case. The check // defends against the addition of a hashed data type without test coverage. func TestHashContract(t *testing.T) { partitiontest.PartitionTest(t) @@ -1475,9 +1475,10 @@ func TestHashContract(t *testing.T) { return false } + require.True(t, strings.HasPrefix(store.HashKind(255).String(), "HashKind(")) for i := byte(0); i < 255; i++ { - if !strings.HasPrefix(store.HashKind(i).String(), "hashKind(") { - require.True(t, hasTestCoverageForKind(store.HashKind(i)), fmt.Sprintf("Missing test coverage for hashKind ordinal value = %d", i)) + if !strings.HasPrefix(store.HashKind(i).String(), "HashKind(") { + require.True(t, hasTestCoverageForKind(store.HashKind(i)), fmt.Sprintf("Missing test coverage for HashKind ordinal value = %d", i)) } } } diff --git a/ledger/store/hashing.go b/ledger/store/hashing.go index aa3f85eb56..40a5b6c311 100644 --- a/ledger/store/hashing.go +++ b/ledger/store/hashing.go @@ -25,11 +25,11 @@ import ( ) // HashKind enumerates the possible data types hashed into a catchpoint merkle -// trie. Each merkle trie hash includes the hashKind byte at a known-offset. -// By encoding hashKind at a known-offset, it's possible for hash readers to +// trie. Each merkle trie hash includes the HashKind byte at a known-offset. +// By encoding HashKind at a known-offset, it's possible for hash readers to // disambiguate the hashed resource. // -//go:generate stringer -type=hashKind +//go:generate stringer -type=HashKind //msgp:ignore HashKind type HashKind byte diff --git a/ledger/store/hashkind_string.go b/ledger/store/hashkind_string.go index a20405fc31..3b60c2f1e9 100644 --- a/ledger/store/hashkind_string.go +++ b/ledger/store/hashkind_string.go @@ -1,4 +1,4 @@ -// Code generated by "stringer -type=hashKind"; DO NOT EDIT. +// Code generated by "stringer -type=HashKind"; DO NOT EDIT. package store @@ -14,13 +14,13 @@ func _() { _ = x[KvHK-3] } -const _hashKind_name = "accountHKassetHKappHKkvHK" +const _HashKind_name = "AccountHKAssetHKAppHKKvHK" -var _hashKind_index = [...]uint8{0, 9, 16, 21, 25} +var _HashKind_index = [...]uint8{0, 9, 16, 21, 25} func (i HashKind) String() string { - if i >= HashKind(len(_hashKind_index)-1) { - return "hashKind(" + strconv.FormatInt(int64(i), 10) + ")" + if i >= HashKind(len(_HashKind_index)-1) { + return "HashKind(" + strconv.FormatInt(int64(i), 10) + ")" } - return _hashKind_name[_hashKind_index[i]:_hashKind_index[i+1]] + return _HashKind_name[_HashKind_index[i]:_HashKind_index[i+1]] } From 8e28c2495e29c778577c87888c88cfa0d8cbd8d2 Mon Sep 17 00:00:00 2001 From: John Jannotti Date: Tue, 6 Dec 2022 11:38:08 -0500 Subject: [PATCH 2/2] CI should do full `make generate` --- scripts/travis/codegen_verification.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/travis/codegen_verification.sh b/scripts/travis/codegen_verification.sh index 8ba594d7b1..f531101f6d 100755 --- a/scripts/travis/codegen_verification.sh +++ b/scripts/travis/codegen_verification.sh @@ -33,8 +33,8 @@ echo "Running check_license..." echo "Rebuild swagger.json files" make rebuild_swagger -echo "Regenerate config files" -go generate ./config +echo "Regenerate for stringer et el." +make generate echo "Running fixcheck" GOPATH=$(go env GOPATH)