Skip to content

Commit 30dd77e

Browse files
committed
eth/catalyst, miner: fix tests by adding context.Background()
1 parent 6286b20 commit 30dd77e

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

eth/catalyst/api_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func TestEth2PrepareAndGetPayload(t *testing.T) {
190190
SafeBlockHash: common.Hash{},
191191
FinalizedBlockHash: common.Hash{},
192192
}
193-
_, err := api.ForkchoiceUpdatedV1(fcState, &blockParams)
193+
_, err := api.ForkchoiceUpdatedV1(context.Background(), fcState, &blockParams)
194194
if err != nil {
195195
t.Fatalf("error preparing payload, err=%v", err)
196196
}
@@ -270,7 +270,7 @@ func TestInvalidPayloadTimestamp(t *testing.T) {
270270
SafeBlockHash: common.Hash{},
271271
FinalizedBlockHash: common.Hash{},
272272
}
273-
_, err := api.ForkchoiceUpdatedV1(fcState, &params)
273+
_, err := api.ForkchoiceUpdatedV1(context.Background(), fcState, &params)
274274
if test.shouldErr && err == nil {
275275
t.Fatalf("expected error preparing payload with invalid timestamp, err=%v", err)
276276
} else if !test.shouldErr && err != nil {
@@ -329,7 +329,7 @@ func TestEth2NewBlock(t *testing.T) {
329329
SafeBlockHash: block.Hash(),
330330
FinalizedBlockHash: block.Hash(),
331331
}
332-
if _, err := api.ForkchoiceUpdatedV1(fcState, nil); err != nil {
332+
if _, err := api.ForkchoiceUpdatedV1(context.Background(), fcState, nil); err != nil {
333333
t.Fatalf("Failed to insert block: %v", err)
334334
}
335335
if have, want := ethservice.BlockChain().CurrentBlock().Number.Uint64(), block.NumberU64(); have != want {
@@ -369,7 +369,7 @@ func TestEth2NewBlock(t *testing.T) {
369369
SafeBlockHash: block.Hash(),
370370
FinalizedBlockHash: block.Hash(),
371371
}
372-
if _, err := api.ForkchoiceUpdatedV1(fcState, nil); err != nil {
372+
if _, err := api.ForkchoiceUpdatedV1(context.Background(), fcState, nil); err != nil {
373373
t.Fatalf("Failed to insert block: %v", err)
374374
}
375375
if ethservice.BlockChain().CurrentBlock().Number.Uint64() != block.NumberU64() {
@@ -515,7 +515,7 @@ func setupBlocks(t *testing.T, ethservice *eth.Ethereum, n int, parent *types.He
515515
SafeBlockHash: payload.ParentHash,
516516
FinalizedBlockHash: payload.ParentHash,
517517
}
518-
if _, err := api.ForkchoiceUpdatedV1(fcState, nil); err != nil {
518+
if _, err := api.ForkchoiceUpdatedV1(context.Background(), fcState, nil); err != nil {
519519
t.Fatalf("Failed to insert block: %v", err)
520520
}
521521
if ethservice.BlockChain().CurrentBlock().Number.Uint64() != payload.Number {
@@ -629,7 +629,7 @@ func TestNewPayloadOnInvalidChain(t *testing.T) {
629629
err error
630630
)
631631
for i := 0; ; i++ {
632-
if resp, err = api.ForkchoiceUpdatedV1(fcState, &params); err != nil {
632+
if resp, err = api.ForkchoiceUpdatedV1(context.Background(), fcState, &params); err != nil {
633633
t.Fatalf("error preparing payload, err=%v", err)
634634
}
635635
if resp.PayloadStatus.Status != engine.VALID {
@@ -660,7 +660,7 @@ func TestNewPayloadOnInvalidChain(t *testing.T) {
660660
SafeBlockHash: payload.ExecutionPayload.ParentHash,
661661
FinalizedBlockHash: payload.ExecutionPayload.ParentHash,
662662
}
663-
if _, err := api.ForkchoiceUpdatedV1(fcState, nil); err != nil {
663+
if _, err := api.ForkchoiceUpdatedV1(context.Background(), fcState, nil); err != nil {
664664
t.Fatalf("Failed to insert block: %v", err)
665665
}
666666
if ethservice.BlockChain().CurrentBlock().Number.Uint64() != payload.ExecutionPayload.Number {
@@ -679,7 +679,7 @@ func assembleEnvelope(api *ConsensusAPI, parentHash common.Hash, params *engine.
679679
Withdrawals: params.Withdrawals,
680680
BeaconRoot: params.BeaconRoot,
681681
}
682-
payload, err := api.eth.Miner().BuildPayload(args, false)
682+
payload, err := api.eth.Miner().BuildPayload(context.Background(), args, false)
683683
if err != nil {
684684
return nil, err
685685
}
@@ -867,7 +867,7 @@ func TestTrickRemoteBlockCache(t *testing.T) {
867867
t.Error("invalid status: VALID on an invalid chain")
868868
}
869869
// Now reorg to the head of the invalid chain
870-
resp, err := apiB.ForkchoiceUpdatedV1(engine.ForkchoiceStateV1{HeadBlockHash: payload.BlockHash, SafeBlockHash: payload.BlockHash, FinalizedBlockHash: payload.ParentHash}, nil)
870+
resp, err := apiB.ForkchoiceUpdatedV1(context.Background(), engine.ForkchoiceStateV1{HeadBlockHash: payload.BlockHash, SafeBlockHash: payload.BlockHash, FinalizedBlockHash: payload.ParentHash}, nil)
871871
if err != nil {
872872
t.Fatal(err)
873873
}
@@ -970,7 +970,7 @@ func TestSimultaneousNewBlock(t *testing.T) {
970970
for ii := 0; ii < 10; ii++ {
971971
go func() {
972972
defer wg.Done()
973-
if _, err := api.ForkchoiceUpdatedV1(fcState, nil); err != nil {
973+
if _, err := api.ForkchoiceUpdatedV1(context.Background(), fcState, nil); err != nil {
974974
errMu.Lock()
975975
testErr = fmt.Errorf("failed to insert block: %w", err)
976976
errMu.Unlock()
@@ -1011,7 +1011,7 @@ func TestWithdrawals(t *testing.T) {
10111011
fcState := engine.ForkchoiceStateV1{
10121012
HeadBlockHash: parent.Hash(),
10131013
}
1014-
resp, err := api.ForkchoiceUpdatedV2(fcState, &blockParams)
1014+
resp, err := api.ForkchoiceUpdatedV2(context.Background(), fcState, &blockParams)
10151015
if err != nil {
10161016
t.Fatalf("error preparing payload, err=%v", err)
10171017
}
@@ -1063,7 +1063,7 @@ func TestWithdrawals(t *testing.T) {
10631063
},
10641064
}
10651065
fcState.HeadBlockHash = execData.ExecutionPayload.BlockHash
1066-
_, err = api.ForkchoiceUpdatedV2(fcState, &blockParams)
1066+
_, err = api.ForkchoiceUpdatedV2(context.Background(), fcState, &blockParams)
10671067
if err != nil {
10681068
t.Fatalf("error preparing payload, err=%v", err)
10691069
}
@@ -1090,7 +1090,7 @@ func TestWithdrawals(t *testing.T) {
10901090

10911091
// 11: set block as head.
10921092
fcState.HeadBlockHash = execData.ExecutionPayload.BlockHash
1093-
_, err = api.ForkchoiceUpdatedV2(fcState, nil)
1093+
_, err = api.ForkchoiceUpdatedV2(context.Background(), fcState, nil)
10941094
if err != nil {
10951095
t.Fatalf("error preparing payload, err=%v", err)
10961096
}
@@ -1196,10 +1196,10 @@ func TestNilWithdrawals(t *testing.T) {
11961196
)
11971197
if !shanghai {
11981198
payloadVersion = engine.PayloadV1
1199-
_, err = api.ForkchoiceUpdatedV1(fcState, &test.blockParams)
1199+
_, err = api.ForkchoiceUpdatedV1(context.Background(), fcState, &test.blockParams)
12001200
} else {
12011201
payloadVersion = engine.PayloadV2
1202-
_, err = api.ForkchoiceUpdatedV2(fcState, &test.blockParams)
1202+
_, err = api.ForkchoiceUpdatedV2(context.Background(), fcState, &test.blockParams)
12031203
}
12041204
if test.wantErr {
12051205
if err == nil {
@@ -1574,7 +1574,7 @@ func TestParentBeaconBlockRoot(t *testing.T) {
15741574
fcState := engine.ForkchoiceStateV1{
15751575
HeadBlockHash: parent.Hash(),
15761576
}
1577-
resp, err := api.ForkchoiceUpdatedV3(fcState, &blockParams)
1577+
resp, err := api.ForkchoiceUpdatedV3(context.Background(), fcState, &blockParams)
15781578
if err != nil {
15791579
t.Fatalf("error preparing payload, err=%v", err.(*engine.EngineAPIError).ErrorData())
15801580
}
@@ -1605,7 +1605,7 @@ func TestParentBeaconBlockRoot(t *testing.T) {
16051605
}
16061606

16071607
fcState.HeadBlockHash = execData.ExecutionPayload.BlockHash
1608-
resp, err = api.ForkchoiceUpdatedV3(fcState, nil)
1608+
resp, err = api.ForkchoiceUpdatedV3(context.Background(), fcState, nil)
16091609
if err != nil {
16101610
t.Fatalf("error preparing payload, err=%v", err.(*engine.EngineAPIError).ErrorData())
16111611
}
@@ -1661,7 +1661,7 @@ func TestWitnessCreationAndConsumption(t *testing.T) {
16611661
SafeBlockHash: common.Hash{},
16621662
FinalizedBlockHash: common.Hash{},
16631663
}
1664-
_, err := api.ForkchoiceUpdatedWithWitnessV3(fcState, &blockParams)
1664+
_, err := api.ForkchoiceUpdatedWithWitnessV3(context.Background(), fcState, &blockParams)
16651665
if err != nil {
16661666
t.Fatalf("error preparing payload, err=%v", err)
16671667
}

miner/payload_building_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package miner
1818

1919
import (
20+
"context"
2021
"math/big"
2122
"reflect"
2223
"testing"
@@ -156,7 +157,7 @@ func TestBuildPayload(t *testing.T) {
156157
Random: common.Hash{},
157158
FeeRecipient: recipient,
158159
}
159-
payload, err := w.buildPayload(args, false)
160+
payload, err := w.buildPayload(context.Background(), args, false)
160161
if err != nil {
161162
t.Fatalf("Failed to build payload %v", err)
162163
}

0 commit comments

Comments
 (0)