boulder/grpc
Aaron Gable 4ad66729d2
Tests: use reflect.IsNil() to avoid boxed nil issues (#6305)
Add a new `test.AssertNil()` helper to facilitate asserting that a given
unit test result is a non-boxed nil. Update `test.AssertNotNil()` to use
the reflect package's `.IsNil()` method to catch boxed nils.

In Go, variables whose type is constrained to be an interface type (e.g.
a function parameter which takes an interface, or the return value of a
function which returns `error`, itself an interface type) should
actually be thought of as a (T, V) tuple, where T is their underlying
concrete type and V is their underlying value. Thus, there are two ways
for such a variable to be nil-like: it can be truly nil where T=nil and
V is uninitialized, or it can be a "boxed nil" where T is a nillable
type such as a pointer or a slice and V=nil.

Unfortunately, only the former of these is == nil. The latter is the
cause of frequent bugs, programmer frustration, a whole entry in the Go
FAQ, and considerable design effort to remove from Go 2.

Therefore these two test helpers both call `t.Fatal()` when passed a
boxed nil. We want to avoid passing around boxed nils whenever possible,
and having our tests fail whenever we do is a good way to enforce good
nil hygiene.

Fixes #3279
2022-08-19 14:47:34 -07:00
..
creds Update gRPC TLS handshake (#5968) 2022-02-24 14:23:32 -08:00
test_proto Update boulder-tools dependencies (#6129) 2022-05-20 14:24:01 -07:00
client.go grpc: Implement a static multiple IP address gRPC resolver (#6270) 2022-08-05 10:20:57 -07:00
client_test.go grpc: Implement a static multiple IP address gRPC resolver (#6270) 2022-08-05 10:20:57 -07:00
errors.go Fixup staticcheck and stylecheck, and violations thereof (#5897) 2022-01-20 16:22:30 -08:00
errors_test.go Tests: use reflect.IsNil() to avoid boxed nil issues (#6305) 2022-08-19 14:47:34 -07:00
generate.go Unify protobuf generation (#5458) 2021-06-07 08:49:15 -07:00
interceptors.go Enable additional linters (#6106) 2022-05-11 13:58:58 -07:00
interceptors_test.go Start testing on go1.19 (#6227) 2022-08-10 15:30:43 -07:00
pb-marshalling.go Remove dead code (#5893) 2022-01-19 12:23:06 -08:00
pb-marshalling_test.go Make core.Registration.CreatedAt a *time.Time (#5422) 2021-05-21 13:44:56 -06:00
protogen.sh Unify protobuf generation (#5458) 2021-06-07 08:49:15 -07:00
resolver.go grpc: Implement a static multiple IP address gRPC resolver (#6270) 2022-08-05 10:20:57 -07:00
resolver_test.go grpc: Implement a static multiple IP address gRPC resolver (#6270) 2022-08-05 10:20:57 -07:00
server.go Fixup staticcheck and stylecheck, and violations thereof (#5897) 2022-01-20 16:22:30 -08:00