Skip to content

Commit

Permalink
fix: no txns in block
Browse files Browse the repository at this point in the history
  • Loading branch information
Alok committed Aug 13, 2024
1 parent 9f9961e commit e235cd2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions testing/pkg/tests/preconf/preconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
crand "crypto/rand"
"encoding/hex"
"errors"
"fmt"
"io"
"math/big"
Expand Down Expand Up @@ -61,6 +62,8 @@ var (
blkWinnerKey = func(bNo uint64) string {
return fmt.Sprintf("blkw/%d", bNo)
}

errNoTxnsInBlock = fmt.Errorf("no transactions in block")
)

type BidEntry struct {
Expand Down Expand Up @@ -257,6 +260,10 @@ DONE:
for _, b := range bidders {
entry, err := getRandomBid(cluster, store)
if err != nil {
if errors.Is(err, errNoTxnsInBlock) {
logger.Info("No transactions in block")
continue
}
egCancel()
return err
}
Expand Down Expand Up @@ -431,6 +438,10 @@ func getRandomBid(
store.Insert(blkKey(blkNum), blk)
}

if len(blk.(*types.Block).Transactions()) == 0 {
return nil, errNoTxnsInBlock
}

idx := rand.Intn(len(blk.(*types.Block).Transactions()))
bundleLen := rand.Intn(5) + 1
if idx+bundleLen > len(blk.(*types.Block).Transactions()) {
Expand Down

0 comments on commit e235cd2

Please sign in to comment.