From faec0f8280c67d058ac8ffa2a82d33a13bfa41a3 Mon Sep 17 00:00:00 2001 From: Ryan Staudt Date: Mon, 13 Jul 2020 15:02:00 -0500 Subject: [PATCH] rpcserver: Update error case handling in tests. This updates the rpcserver handler tests to properly call Errorf in the case that the test specifies wantErr, but err is nil. --- rpcserverhandlers_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rpcserverhandlers_test.go b/rpcserverhandlers_test.go index de9b2142..abba8891 100644 --- a/rpcserverhandlers_test.go +++ b/rpcserverhandlers_test.go @@ -3370,7 +3370,11 @@ func testRPCServerHandler(t *testing.T, tests []rpcTest) { if test.wantErr { var rpcErr *dcrjson.RPCError if !errors.As(err, &rpcErr) || rpcErr.Code != test.errCode { - t.Errorf("%s\nwant: %+v\n got: %+v\n", test.name, test.errCode, rpcErr.Code) + if rpcErr != nil { + t.Errorf("%s\nwant: %+v\n got: %+v\n", test.name, test.errCode, rpcErr.Code) + } else { + t.Errorf("%s\nwant: %+v\n got: nil\n", test.name, test.errCode) + } } return }