From e235cd2a22e3997147fbfcfcd108fe84dd3b2194 Mon Sep 17 00:00:00 2001 From: Alok Date: Thu, 8 Aug 2024 20:58:40 +0530 Subject: [PATCH] fix: no txns in block --- testing/pkg/tests/preconf/preconf.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/testing/pkg/tests/preconf/preconf.go b/testing/pkg/tests/preconf/preconf.go index 4c08df993..c15d72d96 100644 --- a/testing/pkg/tests/preconf/preconf.go +++ b/testing/pkg/tests/preconf/preconf.go @@ -4,6 +4,7 @@ import ( "context" crand "crypto/rand" "encoding/hex" + "errors" "fmt" "io" "math/big" @@ -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 { @@ -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 } @@ -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()) {