From 72a6e23dfa82bee72f6ee8d8a5ccf3e99062b3d0 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Thu, 13 Mar 2025 12:31:14 +0100 Subject: [PATCH] fix and simplify history test historyPruneErr check --- cmd/workload/historytest.go | 48 +++++++------------------------------ 1 file changed, 8 insertions(+), 40 deletions(-) diff --git a/cmd/workload/historytest.go b/cmd/workload/historytest.go index fc72a7c3a4..330763e191 100644 --- a/cmd/workload/historytest.go +++ b/cmd/workload/historytest.go @@ -108,11 +108,7 @@ func (s *historyTestSuite) testGetBlockByHash(t *utesting.T) { for i, num := range s.tests.BlockNumbers { bhash := s.tests.BlockHashes[i] b, err := s.cfg.client.getBlockByHash(ctx, bhash, false) - if err != nil { - err = validateHistoryPruneErr(err, num, s.cfg) - if err != nil { - continue - } + if err = validateHistoryPruneErr(err, num, s.cfg); err != nil { t.Fatalf("block %d (hash %v): error %v", num, bhash, err) } if b == nil { @@ -131,11 +127,7 @@ func (s *historyTestSuite) testGetBlockByNumber(t *utesting.T) { for i, num := range s.tests.BlockNumbers { bhash := s.tests.BlockHashes[i] b, err := s.cfg.client.getBlockByNumber(ctx, num, false) - if err != nil { - err = validateHistoryPruneErr(err, num, s.cfg) - if err != nil { - continue - } + if err = validateHistoryPruneErr(err, num, s.cfg); err != nil { t.Fatalf("block %d (hash %v): error %v", num, bhash, err) } if b == nil { @@ -154,11 +146,7 @@ func (s *historyTestSuite) testGetBlockTransactionCountByHash(t *utesting.T) { for i, num := range s.tests.BlockNumbers { bhash := s.tests.BlockHashes[i] count, err := s.cfg.client.getBlockTransactionCountByHash(ctx, bhash) - if err != nil { - err = validateHistoryPruneErr(err, num, s.cfg) - if err != nil { - continue - } + if err = validateHistoryPruneErr(err, num, s.cfg); err != nil { t.Fatalf("block %d (hash %v): error %v", num, bhash, err) } expectedCount := uint64(s.tests.TxCounts[i]) @@ -174,11 +162,7 @@ func (s *historyTestSuite) testGetBlockTransactionCountByNumber(t *utesting.T) { for i, num := range s.tests.BlockNumbers { bhash := s.tests.BlockHashes[i] count, err := s.cfg.client.getBlockTransactionCountByNumber(ctx, num) - if err != nil { - err = validateHistoryPruneErr(err, num, s.cfg) - if err != nil { - continue - } + if err = validateHistoryPruneErr(err, num, s.cfg); err != nil { t.Fatalf("block %d (hash %v): error %v", num, bhash, err) } expectedCount := uint64(s.tests.TxCounts[i]) @@ -194,11 +178,7 @@ func (s *historyTestSuite) testGetBlockReceiptsByHash(t *utesting.T) { for i, num := range s.tests.BlockNumbers { bhash := s.tests.BlockHashes[i] receipts, err := s.cfg.client.getBlockReceipts(ctx, bhash) - if err != nil { - err = validateHistoryPruneErr(err, num, s.cfg) - if err != nil { - continue - } + if err = validateHistoryPruneErr(err, num, s.cfg); err != nil { t.Fatalf("block %d (hash %v): error %v", num, bhash, err) } hash := calcReceiptsHash(receipts) @@ -215,11 +195,7 @@ func (s *historyTestSuite) testGetBlockReceiptsByNumber(t *utesting.T) { for i, num := range s.tests.BlockNumbers { bhash := s.tests.BlockHashes[i] receipts, err := s.cfg.client.getBlockReceipts(ctx, hexutil.Uint64(num)) - if err != nil { - err = validateHistoryPruneErr(err, num, s.cfg) - if err != nil { - continue - } + if err = validateHistoryPruneErr(err, num, s.cfg); err != nil { t.Fatalf("block %d (hash %v): error %v", num, bhash, err) } hash := calcReceiptsHash(receipts) @@ -242,11 +218,7 @@ func (s *historyTestSuite) testGetTransactionByBlockHashAndIndex(t *utesting.T) } tx, err := s.cfg.client.getTransactionByBlockHashAndIndex(ctx, bhash, uint64(txIndex)) - if err != nil { - err = validateHistoryPruneErr(err, num, s.cfg) - if err != nil { - continue - } + if err = validateHistoryPruneErr(err, num, s.cfg); err != nil { t.Fatalf("block %d (hash %v): error %v", num, bhash, err) } if tx == nil { @@ -271,11 +243,7 @@ func (s *historyTestSuite) testGetTransactionByBlockNumberAndIndex(t *utesting.T } tx, err := s.cfg.client.getTransactionByBlockNumberAndIndex(ctx, num, uint64(txIndex)) - if err != nil { - err = validateHistoryPruneErr(err, num, s.cfg) - if err != nil { - continue - } + if err = validateHistoryPruneErr(err, num, s.cfg); err != nil { t.Fatalf("block %d (hash %v): error %v", num, bhash, err) } if tx == nil {