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"
"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

View file

@ -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 {

View file

@ -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)
}