Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit 8ca5efd

Browse files
committed
Revert to using assertNonZero function in allExportedFieldsSet
1 parent 0a95f5e commit 8ca5efd

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

core/types/header_ext_test.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,22 @@ func allExportedFieldsSet[T interface {
131131

132132
t.Run(field.Name, func(t *testing.T) {
133133
switch f := v.Field(i).Interface().(type) {
134-
case common.Hash, common.Address, BlockNonce, Bloom, uint64:
135-
assert.NotZero(t, f)
134+
case common.Hash:
135+
assertNonZero(t, f)
136+
case common.Address:
137+
assertNonZero(t, f)
138+
case BlockNonce:
139+
assertNonZero(t, f)
140+
case Bloom:
141+
assertNonZero(t, f)
142+
case uint64:
143+
assertNonZero(t, f)
136144
case *big.Int:
137-
assert.NotZero(t, *f)
145+
assertNonZero(t, f)
138146
case *common.Hash:
139-
assert.NotZero(t, *f)
147+
assertNonZero(t, f)
140148
case *uint64:
141-
assert.NotZero(t, *f)
149+
assertNonZero(t, f)
142150
case []uint8:
143151
assert.NotEmpty(t, f)
144152
default:
@@ -148,4 +156,15 @@ func allExportedFieldsSet[T interface {
148156
}
149157
}
150158

159+
func assertNonZero[T interface {
160+
common.Hash | common.Address | BlockNonce | uint64 | Bloom |
161+
*big.Int | *common.Hash | *uint64
162+
}](t *testing.T, v T) {
163+
t.Helper()
164+
var zero T
165+
if v == zero {
166+
t.Errorf("must not be zero value for %T", v)
167+
}
168+
}
169+
151170
func ptrTo[T any](x T) *T { return &x }

0 commit comments

Comments
 (0)