@@ -27,6 +27,7 @@ import (
27
27
payloadattribute "github.com/prysmaticlabs/prysm/v3/consensus-types/payload-attribute"
28
28
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
29
29
pb "github.com/prysmaticlabs/prysm/v3/proto/engine/v1"
30
+ "github.com/prysmaticlabs/prysm/v3/runtime/version"
30
31
"github.com/prysmaticlabs/prysm/v3/testing/assert"
31
32
"github.com/prysmaticlabs/prysm/v3/testing/require"
32
33
"github.com/prysmaticlabs/prysm/v3/testing/util"
@@ -493,7 +494,7 @@ func TestReconstructFullBellatrixBlock(t *testing.T) {
493
494
t .Run ("nil block" , func (t * testing.T ) {
494
495
service := & Service {}
495
496
496
- _ , err := service .ReconstructFullBellatrixBlock (ctx , nil )
497
+ _ , err := service .ReconstructFullBlock (ctx , nil )
497
498
require .ErrorContains (t , "nil data" , err )
498
499
})
499
500
t .Run ("only blinded block" , func (t * testing.T ) {
@@ -502,7 +503,7 @@ func TestReconstructFullBellatrixBlock(t *testing.T) {
502
503
bellatrixBlock := util .NewBeaconBlockBellatrix ()
503
504
wrapped , err := blocks .NewSignedBeaconBlock (bellatrixBlock )
504
505
require .NoError (t , err )
505
- _ , err = service .ReconstructFullBellatrixBlock (ctx , wrapped )
506
+ _ , err = service .ReconstructFullBlock (ctx , wrapped )
506
507
require .ErrorContains (t , want , err )
507
508
})
508
509
t .Run ("pre-merge execution payload" , func (t * testing.T ) {
@@ -517,7 +518,7 @@ func TestReconstructFullBellatrixBlock(t *testing.T) {
517
518
require .NoError (t , err )
518
519
wantedWrapped , err := blocks .NewSignedBeaconBlock (wanted )
519
520
require .NoError (t , err )
520
- reconstructed , err := service .ReconstructFullBellatrixBlock (ctx , wrapped )
521
+ reconstructed , err := service .ReconstructFullBlock (ctx , wrapped )
521
522
require .NoError (t , err )
522
523
require .DeepEqual (t , wantedWrapped , reconstructed )
523
524
})
@@ -590,7 +591,7 @@ func TestReconstructFullBellatrixBlock(t *testing.T) {
590
591
blindedBlock .Block .Body .ExecutionPayloadHeader = header
591
592
wrapped , err := blocks .NewSignedBeaconBlock (blindedBlock )
592
593
require .NoError (t , err )
593
- reconstructed , err := service .ReconstructFullBellatrixBlock (ctx , wrapped )
594
+ reconstructed , err := service .ReconstructFullBlock (ctx , wrapped )
594
595
require .NoError (t , err )
595
596
596
597
got , err := reconstructed .Block ().Body ().Execution ()
@@ -1149,6 +1150,7 @@ func fixtures() map[string]interface{} {
1149
1150
receiptsRoot := bytesutil .PadTo ([]byte ("receiptsRoot" ), fieldparams .RootLength )
1150
1151
logsBloom := bytesutil .PadTo ([]byte ("logs" ), fieldparams .LogsBloomLength )
1151
1152
executionBlock := & pb.ExecutionBlock {
1153
+ Version : version .Bellatrix ,
1152
1154
Header : gethtypes.Header {
1153
1155
ParentHash : common .BytesToHash (parent ),
1154
1156
UncleHash : common .BytesToHash (sha3Uncles ),
@@ -1257,7 +1259,7 @@ func Test_fullPayloadFromExecutionBlock(t *testing.T) {
1257
1259
tests := []struct {
1258
1260
name string
1259
1261
args args
1260
- want * pb. ExecutionPayload
1262
+ want func () interfaces. ExecutionData
1261
1263
err string
1262
1264
}{
1263
1265
{
@@ -1267,7 +1269,8 @@ func Test_fullPayloadFromExecutionBlock(t *testing.T) {
1267
1269
BlockHash : []byte ("foo" ),
1268
1270
},
1269
1271
block : & pb.ExecutionBlock {
1270
- Hash : common .BytesToHash ([]byte ("bar" )),
1272
+ Version : version .Bellatrix ,
1273
+ Hash : common .BytesToHash ([]byte ("bar" )),
1271
1274
},
1272
1275
},
1273
1276
err : "does not match execution block hash" ,
@@ -1279,22 +1282,30 @@ func Test_fullPayloadFromExecutionBlock(t *testing.T) {
1279
1282
BlockHash : wantedHash [:],
1280
1283
},
1281
1284
block : & pb.ExecutionBlock {
1282
- Hash : wantedHash ,
1285
+ Version : version .Bellatrix ,
1286
+ Hash : wantedHash ,
1283
1287
},
1284
1288
},
1285
- want : & pb.ExecutionPayload {
1286
- BlockHash : wantedHash [:],
1289
+ want : func () interfaces.ExecutionData {
1290
+ p , err := blocks .WrappedExecutionPayload (& pb.ExecutionPayload {
1291
+ BlockHash : wantedHash [:],
1292
+ Transactions : [][]byte {},
1293
+ })
1294
+ require .NoError (t , err )
1295
+ return p
1287
1296
},
1288
1297
},
1289
1298
}
1290
1299
for _ , tt := range tests {
1291
1300
t .Run (tt .name , func (t * testing.T ) {
1292
1301
wrapped , err := blocks .WrappedExecutionPayloadHeader (tt .args .header )
1302
+ require .NoError (t , err )
1293
1303
got , err := fullPayloadFromExecutionBlock (wrapped , tt .args .block )
1294
- if (err != nil ) && ! strings .Contains (err .Error (), tt .err ) {
1295
- t .Fatalf ("Wanted err %s got %v" , tt .err , err )
1304
+ if err != nil {
1305
+ assert .ErrorContains (t , tt .err , err )
1306
+ } else {
1307
+ assert .DeepEqual (t , tt .want (), got )
1296
1308
}
1297
- require .DeepEqual (t , tt .want , got )
1298
1309
})
1299
1310
}
1300
1311
}
0 commit comments