@@ -64,6 +64,20 @@ public async Task NewPayloadV2_should_decline_post_cancun()
64
64
Assert . That ( result . ErrorCode , Is . EqualTo ( ErrorCodes . UnsupportedFork ) ) ;
65
65
}
66
66
67
+ [ TestCaseSource ( nameof ( CancunFieldsTestSource ) ) ]
68
+ public async Task < int > NewPayloadV2_should_decline_pre_cancun_with_cancun_fields ( ulong ? blobGasUsed , ulong ? excessBlobGas , Keccak ? parentBlockBeaconRoot )
69
+ {
70
+ MergeTestBlockchain chain = await CreateBlockchain ( releaseSpec : Shanghai . Instance ) ;
71
+ IEngineRpcModule rpcModule = CreateEngineModule ( chain ) ;
72
+ ExecutionPayload executionPayload = CreateBlockRequest (
73
+ CreateParentBlockRequestOnHead ( chain . BlockTree ) , TestItem . AddressD , withdrawals : Array . Empty < Withdrawal > ( ) ,
74
+ blobGasUsed : blobGasUsed , excessBlobGas : excessBlobGas , parentBeaconBlockRoot : parentBlockBeaconRoot ) ;
75
+
76
+ ResultWrapper < PayloadStatusV1 > result = await rpcModule . engine_newPayloadV2 ( executionPayload ) ;
77
+
78
+ return result . ErrorCode ;
79
+ }
80
+
67
81
[ Test ]
68
82
public async Task NewPayloadV3_should_decline_pre_cancun_payloads ( )
69
83
{
@@ -408,6 +422,48 @@ public static IEnumerable<TestCaseData> BlobVersionedHashesDoNotMatchTestSource
408
422
}
409
423
}
410
424
425
+ public static IEnumerable < TestCaseData > CancunFieldsTestSource
426
+ {
427
+ get
428
+ {
429
+ yield return new TestCaseData ( null , null , null )
430
+ {
431
+ ExpectedResult = ErrorCodes . None ,
432
+ TestName = "No Cancun fields" ,
433
+ } ;
434
+ yield return new TestCaseData ( 0ul , null , null )
435
+ {
436
+ ExpectedResult = ErrorCodes . InvalidParams ,
437
+ TestName = $ "{ nameof ( ExecutionPayloadV3 . BlobGasUsed ) } is set",
438
+ } ;
439
+ yield return new TestCaseData ( null , 0ul , null )
440
+ {
441
+ ExpectedResult = ErrorCodes . InvalidParams ,
442
+ TestName = $ "{ nameof ( ExecutionPayloadV3 . ExcessBlobGas ) } is set",
443
+ } ;
444
+ yield return new TestCaseData ( null , null , Keccak . Zero )
445
+ {
446
+ ExpectedResult = ErrorCodes . InvalidParams ,
447
+ TestName = $ "{ nameof ( ExecutionPayloadV3 . ParentBeaconBlockRoot ) } is set",
448
+ } ;
449
+ yield return new TestCaseData ( 1ul , 1ul , null )
450
+ {
451
+ ExpectedResult = ErrorCodes . InvalidParams ,
452
+ TestName = $ "Multiple fields #1",
453
+ } ;
454
+ yield return new TestCaseData ( 1ul , 1ul , Keccak . Zero )
455
+ {
456
+ ExpectedResult = ErrorCodes . InvalidParams ,
457
+ TestName = $ "Multiple fields #2",
458
+ } ;
459
+ yield return new TestCaseData ( 1ul , null , Keccak . Zero )
460
+ {
461
+ ExpectedResult = ErrorCodes . InvalidParams ,
462
+ TestName = $ "Multiple fields #3",
463
+ } ;
464
+ }
465
+ }
466
+
411
467
private async Task < ExecutionPayload > SendNewBlockV3 ( IEngineRpcModule rpc , MergeTestBlockchain chain , IList < Withdrawal > ? withdrawals )
412
468
{
413
469
ExecutionPayloadV3 executionPayload = CreateBlockRequestV3 (
0 commit comments