@ -208,7 +208,6 @@ func TestEth2PrepareAndGetPayload(t *testing.T) {
t . Fatalf ( "error preparing payload, err=%v" , err )
t . Fatalf ( "error preparing payload, err=%v" , err )
}
}
// give the payload some time to be built
// give the payload some time to be built
time . Sleep ( 100 * time . Millisecond )
payloadID := ( & miner . BuildPayloadArgs {
payloadID := ( & miner . BuildPayloadArgs {
Parent : fcState . HeadBlockHash ,
Parent : fcState . HeadBlockHash ,
Timestamp : blockParams . Timestamp ,
Timestamp : blockParams . Timestamp ,
@ -217,12 +216,12 @@ func TestEth2PrepareAndGetPayload(t *testing.T) {
BeaconRoot : blockParams . BeaconRoot ,
BeaconRoot : blockParams . BeaconRoot ,
Version : engine . PayloadV1 ,
Version : engine . PayloadV1 ,
} ) . Id ( )
} ) . Id ( )
execData , err := api . GetPayloadV1 ( payloadID )
execData , err := api . getPayload ( payloadID , true )
if err != nil {
if err != nil {
t . Fatalf ( "error getting payload, err=%v" , err )
t . Fatalf ( "error getting payload, err=%v" , err )
}
}
if len ( execData . Transactions ) != blocks [ 9 ] . Transactions ( ) . Len ( ) {
if len ( execData . ExecutionPayload . Transactions ) != blocks [ 9 ] . Transactions ( ) . Len ( ) {
t . Fatalf ( "invalid number of transactions %d != 1" , len ( execData . Transactions ) )
t . Fatalf ( "invalid number of transactions %d != 1" , len ( execData . ExecutionPayload . Transactions ) )
}
}
// Test invalid payloadID
// Test invalid payloadID
var invPayload engine . PayloadID
var invPayload engine . PayloadID
@ -453,7 +452,6 @@ func startEthService(t *testing.T, genesis *core.Genesis, blocks []*types.Block)
}
}
mcfg := miner . DefaultConfig
mcfg := miner . DefaultConfig
mcfg . PendingFeeRecipient = testAddr
ethcfg := & ethconfig . Config { Genesis : genesis , SyncMode : downloader . FullSync , TrieTimeout : time . Minute , TrieDirtyCache : 256 , TrieCleanCache : 256 , Miner : mcfg }
ethcfg := & ethconfig . Config { Genesis : genesis , SyncMode : downloader . FullSync , TrieTimeout : time . Minute , TrieDirtyCache : 256 , TrieCleanCache : 256 , Miner : mcfg }
ethservice , err := eth . New ( n , ethcfg )
ethservice , err := eth . New ( n , ethcfg )
if err != nil {
if err != nil {
@ -628,7 +626,7 @@ func TestNewPayloadOnInvalidChain(t *testing.T) {
SafeBlockHash : common . Hash { } ,
SafeBlockHash : common . Hash { } ,
FinalizedBlockHash : common . Hash { } ,
FinalizedBlockHash : common . Hash { } ,
}
}
payload * engine . ExecutableData
payload * engine . ExecutionPayloadEnvelope
resp engine . ForkChoiceResponse
resp engine . ForkChoiceResponse
err error
err error
)
)
@ -640,11 +638,10 @@ func TestNewPayloadOnInvalidChain(t *testing.T) {
t . Fatalf ( "error preparing payload, invalid status: %v" , resp . PayloadStatus . Status )
t . Fatalf ( "error preparing payload, invalid status: %v" , resp . PayloadStatus . Status )
}
}
// give the payload some time to be built
// give the payload some time to be built
time . Sleep ( 50 * time . Millisecond )
if payload , err = api . getPayload ( * resp . PayloadID , true ) ; err != nil {
if payload , err = api . GetPayloadV1 ( * resp . PayloadID ) ; err != nil {
t . Fatalf ( "can't get payload: %v" , err )
t . Fatalf ( "can't get payload: %v" , err )
}
}
if len ( payload . Transactions ) > 0 {
if len ( payload . ExecutionPayload . Transactions ) > 0 {
break
break
}
}
// No luck this time we need to update the params and try again.
// No luck this time we need to update the params and try again.
@ -653,7 +650,7 @@ func TestNewPayloadOnInvalidChain(t *testing.T) {
t . Fatalf ( "payload should not be empty" )
t . Fatalf ( "payload should not be empty" )
}
}
}
}
execResp , err := api . NewPayloadV1 ( * payload )
execResp , err := api . NewPayloadV1 ( * payload . ExecutionPayload )
if err != nil {
if err != nil {
t . Fatalf ( "can't execute payload: %v" , err )
t . Fatalf ( "can't execute payload: %v" , err )
}
}
@ -661,14 +658,14 @@ func TestNewPayloadOnInvalidChain(t *testing.T) {
t . Fatalf ( "invalid status: %v" , execResp . Status )
t . Fatalf ( "invalid status: %v" , execResp . Status )
}
}
fcState = engine . ForkchoiceStateV1 {
fcState = engine . ForkchoiceStateV1 {
HeadBlockHash : payload . BlockHash ,
HeadBlockHash : payload . ExecutionPayload . BlockHash ,
SafeBlockHash : payload . ParentHash ,
SafeBlockHash : payload . ExecutionPayload . ParentHash ,
FinalizedBlockHash : payload . ParentHash ,
FinalizedBlockHash : payload . ExecutionPayload . ParentHash ,
}
}
if _ , err := api . ForkchoiceUpdatedV1 ( fcState , nil ) ; err != nil {
if _ , err := api . ForkchoiceUpdatedV1 ( fcState , nil ) ; err != nil {
t . Fatalf ( "Failed to insert block: %v" , err )
t . Fatalf ( "Failed to insert block: %v" , err )
}
}
if ethservice . BlockChain ( ) . CurrentBlock ( ) . Number . Uint64 ( ) != payload . Number {
if ethservice . BlockChain ( ) . CurrentBlock ( ) . Number . Uint64 ( ) != payload . ExecutionPayload . Number {
t . Fatalf ( "Chain head should be updated" )
t . Fatalf ( "Chain head should be updated" )
}
}
parent = ethservice . BlockChain ( ) . CurrentBlock ( )
parent = ethservice . BlockChain ( ) . CurrentBlock ( )
@ -1736,9 +1733,6 @@ func TestWitnessCreationAndConsumption(t *testing.T) {
if err != nil {
if err != nil {
t . Fatalf ( "error preparing payload, err=%v" , err )
t . Fatalf ( "error preparing payload, err=%v" , err )
}
}
// Give the payload some time to be built
time . Sleep ( 100 * time . Millisecond )
payloadID := ( & miner . BuildPayloadArgs {
payloadID := ( & miner . BuildPayloadArgs {
Parent : fcState . HeadBlockHash ,
Parent : fcState . HeadBlockHash ,
Timestamp : blockParams . Timestamp ,
Timestamp : blockParams . Timestamp ,
@ -1748,7 +1742,7 @@ func TestWitnessCreationAndConsumption(t *testing.T) {
BeaconRoot : blockParams . BeaconRoot ,
BeaconRoot : blockParams . BeaconRoot ,
Version : engine . PayloadV3 ,
Version : engine . PayloadV3 ,
} ) . Id ( )
} ) . Id ( )
envelope , err := api . GetPayloadV3 ( payloadID )
envelope , err := api . getPayload ( payloadID , true )
if err != nil {
if err != nil {
t . Fatalf ( "error getting payload, err=%v" , err )
t . Fatalf ( "error getting payload, err=%v" , err )
}
}