all: fix warning of DeepEqual on error #23624 (#960)

This commit is contained in:
Daniel Liu 2025-04-24 18:31:47 +08:00 committed by GitHub
parent fae15a51b5
commit a997425b03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 5 deletions

View file

@ -22,7 +22,6 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"os" "os"
"reflect"
"testing" "testing"
"github.com/XinFinOrg/XDPoSChain/common" "github.com/XinFinOrg/XDPoSChain/common"
@ -580,7 +579,7 @@ func testPrecompiledFailure(addr string, test precompiledFailureTest, t *testing
gas := p.RequiredGas(in) gas := p.RequiredGas(in)
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
_, _, err := RunPrecompiledContract(nil, p, in, gas) _, _, 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) t.Errorf("Expected error [%v], got [%v]", test.expectedError, err)
} }
// Verify that the precompile did not touch the input buffer // Verify that the precompile did not touch the input buffer

View file

@ -18,6 +18,7 @@ package p2p
import ( import (
"crypto/ecdsa" "crypto/ecdsa"
"errors"
"math/rand" "math/rand"
"net" "net"
"reflect" "reflect"
@ -563,7 +564,7 @@ func TestServerSetupConn(t *testing.T) {
} }
p1, _ := net.Pipe() p1, _ := net.Pipe()
srv.SetupConn(p1, test.flags, test.dialDest) 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) t.Errorf("test %d: close error mismatch: got %q, want %q", i, test.tt.closeErr, test.wantCloseErr)
} }
if test.tt.calls != test.wantCalls { if test.tt.calls != test.wantCalls {

View file

@ -18,13 +18,13 @@ package rpc
import ( import (
"context" "context"
"errors"
"io" "io"
"net" "net"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"net/http/httputil" "net/http/httputil"
"net/url" "net/url"
"reflect"
"strings" "strings"
"sync/atomic" "sync/atomic"
"testing" "testing"
@ -69,7 +69,7 @@ func TestWebsocketOriginCheck(t *testing.T) {
t.Fatal("no error for wrong origin") t.Fatal("no error for wrong origin")
} }
wantErr := wsHandshakeError{websocket.ErrBadHandshake, "403 Forbidden"} 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) t.Fatalf("wrong error for wrong origin: %q", err)
} }