@@ -185,6 +185,31 @@ func checkLogEvents(t *testing.T, logsCh <-chan []*types.Log, rmLogsCh <-chan co
185185 }
186186}
187187
188+ func TestInvalidPayloadTimestamp (t * testing.T ) {
189+ genesis , preMergeBlocks := generatePreMergeChain (10 )
190+ n , ethservice := startEthService (t , genesis , preMergeBlocks )
191+ ethservice .Merger ().ReachTTD ()
192+ defer n .Close ()
193+ var (
194+ api = NewConsensusAPI (ethservice , nil )
195+ parent = ethservice .BlockChain ().CurrentBlock ()
196+ )
197+ params := PayloadAttributesV1 {
198+ Timestamp : parent .Time () - 1 ,
199+ Random : crypto .Keccak256Hash ([]byte {byte (123 )}),
200+ SuggestedFeeRecipient : parent .Coinbase (),
201+ }
202+ fcState := ForkchoiceStateV1 {
203+ HeadBlockHash : parent .Hash (),
204+ SafeBlockHash : common.Hash {},
205+ FinalizedBlockHash : common.Hash {},
206+ }
207+ _ , err := api .ForkchoiceUpdatedV1 (fcState , & params )
208+ if err == nil {
209+ t .Fatalf ("expected error preparing payload with invalid timestamp, err=%v" , err )
210+ }
211+ }
212+
188213func TestEth2NewBlock (t * testing.T ) {
189214 genesis , preMergeBlocks := generatePreMergeChain (10 )
190215 n , ethservice := startEthService (t , genesis , preMergeBlocks )
@@ -414,6 +439,5 @@ func TestFullAPI(t *testing.T) {
414439 t .Fatalf ("Chain head should be updated" )
415440 }
416441 parent = ethservice .BlockChain ().CurrentBlock ()
417-
418442 }
419443}
0 commit comments