From d1a79dc19c515f76f7238d95a54722547dd514d2 Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "rpc: use correct stringer-method for serializing BlockNumberOrHash (#28358)" This reverts commit b7be93f9e3cf553a9e01b188a43e2381a8019819. --- rpc/types.go | 3 ++- rpc/types_test.go | 21 --------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/rpc/types.go b/rpc/types.go index f88c37c59d..34a1451dea 100644 --- a/rpc/types.go +++ b/rpc/types.go @@ -21,6 +21,7 @@ import ( "encoding/json" "fmt" "math" + "strconv" "strings" "github.com/ethereum/go-ethereum/common" @@ -220,7 +221,7 @@ func (bnh *BlockNumberOrHash) Number() (BlockNumber, bool) { func (bnh *BlockNumberOrHash) String() string { if bnh.BlockNumber != nil { - return bnh.BlockNumber.String() + return strconv.Itoa(int(*bnh.BlockNumber)) } if bnh.BlockHash != nil { return bnh.BlockHash.String() diff --git a/rpc/types_test.go b/rpc/types_test.go index 617f441d91..f110dee7c6 100644 --- a/rpc/types_test.go +++ b/rpc/types_test.go @@ -153,24 +153,3 @@ func TestBlockNumberOrHash_WithNumber_MarshalAndUnmarshal(t *testing.T) { }) } } - -func TestBlockNumberOrHash_StringAndUnmarshal(t *testing.T) { - tests := []BlockNumberOrHash{ - BlockNumberOrHashWithNumber(math.MaxInt64), - BlockNumberOrHashWithNumber(PendingBlockNumber), - BlockNumberOrHashWithNumber(LatestBlockNumber), - BlockNumberOrHashWithNumber(EarliestBlockNumber), - BlockNumberOrHashWithNumber(32), - BlockNumberOrHashWithHash(common.Hash{0xaa}, false), - } - for _, want := range tests { - marshalled, _ := json.Marshal(want.String()) - var have BlockNumberOrHash - if err := json.Unmarshal(marshalled, &have); err != nil { - t.Fatalf("cannot unmarshal (%v): %v", string(marshalled), err) - } - if !reflect.DeepEqual(want, have) { - t.Fatalf("wrong result: have %v, want %v", have, want) - } - } -}