diff --git a/core/vm/contracts_test.go b/core/vm/contracts_test.go index 22fe467c3f..0db3dae37e 100644 --- a/core/vm/contracts_test.go +++ b/core/vm/contracts_test.go @@ -22,7 +22,6 @@ import ( "fmt" "math/big" "os" - "reflect" "testing" "github.com/XinFinOrg/XDPoSChain/common" @@ -580,7 +579,7 @@ func testPrecompiledFailure(addr string, test precompiledFailureTest, t *testing gas := p.RequiredGas(in) t.Run(test.name, func(t *testing.T) { _, _, err := RunPrecompiledContract(nil, p, in, gas) - if !reflect.DeepEqual(err, test.expectedError) { + if err.Error() != test.expectedError.Error() { t.Errorf("Expected error [%v], got [%v]", test.expectedError, err) } // Verify that the precompile did not touch the input buffer diff --git a/p2p/server_test.go b/p2p/server_test.go index cf6ae61943..bed9dac88d 100644 --- a/p2p/server_test.go +++ b/p2p/server_test.go @@ -18,6 +18,7 @@ package p2p import ( "crypto/ecdsa" + "errors" "math/rand" "net" "reflect" @@ -563,7 +564,7 @@ func TestServerSetupConn(t *testing.T) { } p1, _ := net.Pipe() srv.SetupConn(p1, test.flags, test.dialDest) - if !reflect.DeepEqual(test.tt.closeErr, test.wantCloseErr) { + if !errors.Is(test.tt.closeErr, test.wantCloseErr) { t.Errorf("test %d: close error mismatch: got %q, want %q", i, test.tt.closeErr, test.wantCloseErr) } if test.tt.calls != test.wantCalls { diff --git a/rpc/websocket_test.go b/rpc/websocket_test.go index df5e7ac9da..8659f798e4 100644 --- a/rpc/websocket_test.go +++ b/rpc/websocket_test.go @@ -18,13 +18,13 @@ package rpc import ( "context" + "errors" "io" "net" "net/http" "net/http/httptest" "net/http/httputil" "net/url" - "reflect" "strings" "sync/atomic" "testing" @@ -69,7 +69,7 @@ func TestWebsocketOriginCheck(t *testing.T) { t.Fatal("no error for wrong origin") } wantErr := wsHandshakeError{websocket.ErrBadHandshake, "403 Forbidden"} - if !reflect.DeepEqual(err, wantErr) { + if !errors.Is(err, wantErr) { t.Fatalf("wrong error for wrong origin: %q", err) }