@@ -22,6 +22,7 @@ import (
22
22
"fmt"
23
23
"math/big"
24
24
"math/rand"
25
+ "reflect"
25
26
"sync"
26
27
"testing"
27
28
"time"
@@ -42,7 +43,6 @@ import (
42
43
"github.com/ethereum/go-ethereum/node"
43
44
"github.com/ethereum/go-ethereum/p2p"
44
45
"github.com/ethereum/go-ethereum/params"
45
- "github.com/ethereum/go-ethereum/rlp"
46
46
"github.com/ethereum/go-ethereum/rpc"
47
47
"github.com/ethereum/go-ethereum/trie"
48
48
)
@@ -1238,10 +1238,10 @@ func TestNilWithdrawals(t *testing.T) {
1238
1238
}
1239
1239
1240
1240
func setupBodies (t * testing.T ) (* node.Node , * eth.Ethereum , []* types.Block ) {
1241
- genesis , preMergeBlocks := generateMergeChain (10 , true )
1242
- n , ethservice := startEthService (t , genesis , preMergeBlocks )
1241
+ genesis , blocks := generateMergeChain (10 , true )
1242
+ n , ethservice := startEthService (t , genesis , blocks )
1243
1243
// enable shanghai on the last block
1244
- ethservice .BlockChain ().Config ().ShanghaiTime = & preMergeBlocks [len (preMergeBlocks )- 1 ].Header ().Time
1244
+ ethservice .BlockChain ().Config ().ShanghaiTime = & blocks [len (blocks )- 1 ].Header ().Time
1245
1245
1246
1246
var (
1247
1247
parent = ethservice .BlockChain ().CurrentBlock ()
@@ -1267,12 +1267,12 @@ func setupBodies(t *testing.T) (*node.Node, *eth.Ethereum, []*types.Block) {
1267
1267
}
1268
1268
}
1269
1269
1270
- postMergeHeaders := setupBlocks (t , ethservice , 10 , parent , callback , withdrawals )
1271
- postMergeBlocks := make ([]* types.Block , len (postMergeHeaders ))
1272
- for i , header := range postMergeHeaders {
1273
- postMergeBlocks [i ] = ethservice .BlockChain ().GetBlock (header .Hash (), header .Number .Uint64 ())
1270
+ postShanghaiHeaders := setupBlocks (t , ethservice , 10 , parent , callback , withdrawals )
1271
+ postShanghaiBlocks := make ([]* types.Block , len (postShanghaiHeaders ))
1272
+ for i , header := range postShanghaiHeaders {
1273
+ postShanghaiBlocks [i ] = ethservice .BlockChain ().GetBlock (header .Hash (), header .Number .Uint64 ())
1274
1274
}
1275
- return n , ethservice , append (preMergeBlocks , postMergeBlocks ... )
1275
+ return n , ethservice , append (blocks , postShanghaiBlocks ... )
1276
1276
}
1277
1277
1278
1278
func allHashes (blocks []* types.Block ) []common.Hash {
@@ -1478,28 +1478,14 @@ func equalBody(a *types.Body, b *engine.ExecutionPayloadBodyV1) bool {
1478
1478
} else if a == nil || b == nil {
1479
1479
return false
1480
1480
}
1481
- var want []hexutil.Bytes
1482
- for _ , tx := range a .Transactions {
1483
- data , _ := tx .MarshalBinary ()
1484
- want = append (want , hexutil .Bytes (data ))
1485
- }
1486
- aBytes , errA := rlp .EncodeToBytes (want )
1487
- bBytes , errB := rlp .EncodeToBytes (b .TransactionData )
1488
- if errA != errB {
1489
- return false
1490
- }
1491
- if ! bytes .Equal (aBytes , bBytes ) {
1481
+ if len (a .Transactions ) != len (b .TransactionData ) {
1492
1482
return false
1493
1483
}
1494
- if a .Withdrawals == nil && b .Withdrawals == nil {
1495
- return true
1496
- } else if a .Withdrawals == nil || b .Withdrawals == nil {
1497
- return false
1498
- }
1499
- aBytes , errA = rlp .EncodeToBytes (a .Withdrawals )
1500
- bBytes , errB = rlp .EncodeToBytes (b .Withdrawals )
1501
- if errA != errB {
1502
- return false
1484
+ for i , tx := range a .Transactions {
1485
+ data , _ := tx .MarshalBinary ()
1486
+ if ! reflect .DeepEqual (hexutil .Bytes (data ), b .TransactionData [i ]) {
1487
+ return false
1488
+ }
1503
1489
}
1504
- return bytes . Equal ( aBytes , bBytes )
1490
+ return reflect . DeepEqual ( a . Withdrawals , b . Withdrawals )
1505
1491
}
0 commit comments