@@ -580,6 +580,56 @@ var Tests = []test.SpecInterface{
580580 },
581581 },
582582
583+ & GetPayloadBodiesSpec {
584+ WithdrawalsBaseSpec : & WithdrawalsBaseSpec {
585+ Spec : test.Spec {
586+ Name : "GetPayloadBodies After Sync" ,
587+ About : `
588+ Make multiple withdrawals to 16 accounts each payload.
589+ Spawn a secondary client which must sync the canonical chain
590+ from the first client.
591+ Retrieve many of the payloads' bodies by number range from
592+ this secondary client.
593+ ` ,
594+ TimeoutSeconds : 240 ,
595+ SlotsToSafe : big .NewInt (32 ),
596+ SlotsToFinalized : big .NewInt (64 ),
597+ },
598+ WithdrawalsForkHeight : 17 ,
599+ WithdrawalsBlockCount : 16 ,
600+ WithdrawalsPerBlock : 16 ,
601+ WithdrawableAccountCount : 1024 ,
602+ },
603+ GetPayloadBodiesRequests : []GetPayloadBodyRequest {
604+ GetPayloadBodyRequestByRange {
605+ Start : 16 ,
606+ Count : 2 ,
607+ },
608+ GetPayloadBodyRequestByRange {
609+ Start : 31 ,
610+ Count : 3 ,
611+ },
612+ GetPayloadBodyRequestByHashIndex {
613+ BlockNumbers : []uint64 {
614+ 1 ,
615+ 16 ,
616+ 2 ,
617+ 17 ,
618+ },
619+ },
620+ GetPayloadBodyRequestByHashIndex { // Existing+Random hashes
621+ BlockNumbers : []uint64 {
622+ 32 ,
623+ 1000 ,
624+ 31 ,
625+ 1000 ,
626+ 30 ,
627+ 1000 ,
628+ },
629+ },
630+ },
631+ },
632+
583633 & GetPayloadBodiesSpec {
584634 WithdrawalsBaseSpec : & WithdrawalsBaseSpec {
585635 Spec : test.Spec {
@@ -1842,6 +1892,7 @@ type GetPayloadBodiesSpec struct {
18421892 * WithdrawalsBaseSpec
18431893 GetPayloadBodiesRequests []GetPayloadBodyRequest
18441894 GenerateSidechain bool
1895+ AfterSync bool
18451896}
18461897
18471898type GetPayloadBodyRequest interface {
@@ -1950,6 +2001,8 @@ func (ws *GetPayloadBodiesSpec) Execute(t *test.Env) {
19502001
19512002 payloadHistory := t .CLMock .ExecutedPayloadHistory
19522003
2004+ testEngine := t .TestEngine
2005+
19532006 if ws .GenerateSidechain {
19542007
19552008 // First generate an extra payload on top of the canonical chain
@@ -1997,11 +2050,44 @@ func (ws *GetPayloadBodiesSpec) Execute(t *test.Env) {
19972050 n1 .ExpectStatus (test .Valid )
19982051 n2 := t .TestEngine .TestEngineNewPayloadV2 (sidechainHead )
19992052 n2 .ExpectStatus (test .Valid )
2053+ } else if ws .AfterSync {
2054+ // Spawn a secondary client which will need to sync to the primary client
2055+ secondaryEngine , err := hive_rpc.HiveRPCEngineStarter {}.StartClient (t .T , t .TestContext , t .Genesis , t .ClientParams , t .ClientFiles , t .Engine )
2056+ if err != nil {
2057+ t .Fatalf ("FAIL (%s): Unable to spawn a secondary client: %v" , t .TestName , err )
2058+ }
2059+ secondaryEngineTest := test .NewTestEngineClient (t , secondaryEngine )
2060+ t .CLMock .AddEngineClient (secondaryEngine )
2061+
2062+ loop:
2063+ for {
2064+ select {
2065+ case <- t .TimeoutContext .Done ():
2066+ t .Fatalf ("FAIL (%s): Timeout while waiting for secondary client to sync" , t .TestName )
2067+ case <- time .After (time .Second ):
2068+ secondaryEngineTest .TestEngineNewPayloadV2 (
2069+ & t .CLMock .LatestExecutedPayload ,
2070+ )
2071+ r := secondaryEngineTest .TestEngineForkchoiceUpdatedV2 (
2072+ & t .CLMock .LatestForkchoice ,
2073+ nil ,
2074+ )
2075+ if r .Response .PayloadStatus .Status == test .Valid {
2076+ break loop
2077+ }
2078+ if r .Response .PayloadStatus .Status == test .Invalid {
2079+ t .Fatalf ("FAIL (%s): Syncing client rejected valid chain: %s" , t .TestName , r .Response )
2080+ }
2081+ }
2082+ }
2083+
2084+ // GetPayloadBodies will be sent to the secondary client
2085+ testEngine = secondaryEngineTest
20002086 }
20012087
2002- // Now send the range request, which should ignore the sidechain
2088+ // Now send the range request, which should ignore any sidechain
20032089 for _ , req := range ws .GetPayloadBodiesRequests {
2004- req .Verify (t . TestEngine , payloadHistory )
2090+ req .Verify (testEngine , payloadHistory )
20052091 }
20062092}
20072093
0 commit comments