Skip to content

Commit

Permalink
eth/catalyst: fix (?) flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Oct 4, 2022
1 parent 6ddc0ba commit df3ddc0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions eth/catalyst/api_test.go
Expand Up @@ -113,12 +113,20 @@ func TestEth2AssembleBlockWithAnotherBlocksTxs(t *testing.T) {
blockParams := beacon.PayloadAttributesV1{
Timestamp: blocks[8].Time() + 5,
}
execData, err := assembleBlock(api, blocks[8].Hash(), &blockParams)
if err != nil {
t.Fatalf("error producing block, err=%v", err)
}
if len(execData.Transactions) != blocks[9].Transactions().Len() {
t.Fatalf("invalid number of transactions %d != 1", len(execData.Transactions))
// This test is a bit time-sensitive, the miner needs to pick up on the
// txs in the pool. Therefore, we retry once if it fails on the first attempt.
var testErr error
for retries := 2; retries > 0; retries-- {
if execData, err := assembleBlock(api, blocks[8].Hash(), &blockParams); err != nil {
t.Fatalf("error producing block, err=%v", err)
} else if have, want := len(execData.Transactions), blocks[9].Transactions().Len(); have != want {
testErr = fmt.Errorf("invalid number of transactions, have %d want %d", have, want)
} else {
testErr = nil
}
}
if testErr != nil {
t.Fatal(testErr)
}
}

Expand Down

0 comments on commit df3ddc0

Please sign in to comment.