fix and simplify history test historyPruneErr check

This commit is contained in:
Jared Wasinger 2025-03-13 12:31:14 +01:00
parent b0eaf5f6b0
commit 72a6e23dfa

View file

@ -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 {