mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
fix test
This commit is contained in:
parent
6134461aae
commit
ea2cd2dc5d
1 changed files with 0 additions and 18 deletions
|
|
@ -654,11 +654,8 @@ We expect
|
||||||
└── P1''
|
└── P1''
|
||||||
*/
|
*/
|
||||||
func TestNewPayloadOnInvalidChain(t *testing.T) {
|
func TestNewPayloadOnInvalidChain(t *testing.T) {
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
genesis, preMergeBlocks := generateMergeChain(10, false)
|
genesis, preMergeBlocks := generateMergeChain(10, false)
|
||||||
n, ethservice := startEthService(t, genesis, preMergeBlocks)
|
n, ethservice := startEthService(t, genesis, preMergeBlocks)
|
||||||
|
|
||||||
defer n.Close()
|
defer n.Close()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -668,7 +665,6 @@ func TestNewPayloadOnInvalidChain(t *testing.T) {
|
||||||
// This EVM code generates a log when the contract is created.
|
// This EVM code generates a log when the contract is created.
|
||||||
logCode = common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00")
|
logCode = common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00")
|
||||||
)
|
)
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
statedb, _ := ethservice.BlockChain().StateAt(parent.Root)
|
statedb, _ := ethservice.BlockChain().StateAt(parent.Root)
|
||||||
tx := types.MustSignNewTx(testKey, signer, &types.LegacyTx{
|
tx := types.MustSignNewTx(testKey, signer, &types.LegacyTx{
|
||||||
|
|
@ -694,59 +690,45 @@ func TestNewPayloadOnInvalidChain(t *testing.T) {
|
||||||
resp engine.ForkChoiceResponse
|
resp engine.ForkChoiceResponse
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
if resp, err = api.ForkchoiceUpdatedV1(fcState, ¶ms); err != nil {
|
if resp, err = api.ForkchoiceUpdatedV1(fcState, ¶ms); err != nil {
|
||||||
t.Fatalf("error preparing payload, err=%v", err)
|
t.Fatalf("error preparing payload, err=%v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.PayloadStatus.Status != engine.VALID {
|
if resp.PayloadStatus.Status != engine.VALID {
|
||||||
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)
|
time.Sleep(50 * time.Millisecond)
|
||||||
|
|
||||||
if payload, err = api.GetPayloadV1(*resp.PayloadID); 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.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.
|
||||||
params.Timestamp = params.Timestamp + 1
|
params.Timestamp = params.Timestamp + 1
|
||||||
|
|
||||||
if i > 10 {
|
if i > 10 {
|
||||||
t.Fatalf("payload should not be empty")
|
t.Fatalf("payload should not be empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
execResp, err := api.NewPayloadV1(*payload)
|
execResp, err := api.NewPayloadV1(*payload)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't execute payload: %v", err)
|
t.Fatalf("can't execute payload: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if execResp.Status != engine.VALID {
|
if execResp.Status != engine.VALID {
|
||||||
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.BlockHash,
|
||||||
SafeBlockHash: payload.ParentHash,
|
SafeBlockHash: payload.ParentHash,
|
||||||
FinalizedBlockHash: payload.ParentHash,
|
FinalizedBlockHash: payload.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.Number {
|
||||||
t.Fatalf("Chain head should be updated")
|
t.Fatalf("Chain head should be updated")
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = ethservice.BlockChain().CurrentBlock()
|
parent = ethservice.BlockChain().CurrentBlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue