@@ -152,12 +152,26 @@ func TestHeaderHooks(t *testing.T) {
152152 }
153153
154154 setStub ()
155- _ , err := json .Marshal (hdr )
156- assert .ErrorIs (t , err , errMarshal , "via json.Marshal()" ) //nolint:testifylint // require is inappropriate here as we wish to keep going
157- assert .Equal (t , errUnmarshal , json .Unmarshal ([]byte ("{}" ), hdr ), "via json.Unmarshal()" )
155+ // The { } blocks are defensive, avoiding accidentally having the wrong
156+ // error checked in a future refactor. The verbosity is acceptable for
157+ // clarity in tests.
158+ {
159+ _ , err := json .Marshal (hdr )
160+ assert .ErrorIs (t , err , errMarshal , "via json.Marshal()" ) //nolint:testifylint // require is inappropriate here as we wish to keep going
161+ }
162+ {
163+ err := json .Unmarshal ([]byte ("{}" ), hdr )
164+ assert .Equal (t , errUnmarshal , err , "via json.Unmarshal()" )
165+ }
158166
159167 setStub () // [stubHeaderHooks] completely overrides the Header
160- assert .Equal (t , errEncode , rlp .Encode (io .Discard , hdr ), "via rlp.Encode()" )
161- assert .Equal (t , errDecode , rlp .DecodeBytes ([]byte {0 }, hdr ), "via rlp.DecodeBytes()" )
168+ {
169+ err := rlp .Encode (io .Discard , hdr )
170+ assert .Equal (t , errEncode , err , "via rlp.Encode()" )
171+ }
172+ {
173+ err := rlp .DecodeBytes ([]byte {0 }, hdr )
174+ assert .Equal (t , errDecode , err , "via rlp.DecodeBytes()" )
175+ }
162176 })
163177}
0 commit comments