Skip to content

Commit

Permalink
refactor TestExecuteTxs
Browse files Browse the repository at this point in the history
  • Loading branch information
tzdybal committed Feb 21, 2025
1 parent c954062 commit d24bbf4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions test/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test
import (
"bytes"
"context"
"fmt"
"time"

"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -92,16 +93,14 @@ func (s *ExecutorSuite) TestExecuteTxs() {
},
}

for _, c := range cases {
for i, c := range cases {
s.Run(c.name, func() {
initialHeight := uint64(1)

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

genesisTime, genesisStateRoot, _ := s.initChain(ctx, initialHeight)
genesisTime, genesisStateRoot, _ := s.initChain(ctx, uint64(i+1))

Check failure on line 101 in test/suite.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

G115: integer overflow conversion int -> uint64 (gosec)

stateRoot, maxBytes, err := s.Exec.ExecuteTxs(ctx, c.txs, initialHeight, genesisTime.Add(time.Second), genesisStateRoot)
stateRoot, maxBytes, err := s.Exec.ExecuteTxs(ctx, c.txs, uint64(1), genesisTime.Add(time.Second), genesisStateRoot)
s.Require().NoError(err)
s.Require().NotEmpty(stateRoot)
s.Require().NotEqual(c.stateRootChanged, bytes.Equal(genesisStateRoot, stateRoot))
Expand Down Expand Up @@ -154,7 +153,7 @@ func (s *ExecutorSuite) TestMultipleBlocks() {

func (s *ExecutorSuite) initChain(ctx context.Context, initialHeight uint64) (time.Time, types.Hash, uint64) {
genesisTime := time.Now().UTC()
chainID := "test-chain"
chainID := fmt.Sprintf("test-chain-%d", initialHeight)

stateRoot, maxBytes, err := s.Exec.InitChain(ctx, genesisTime, initialHeight, chainID)
s.Require().NoError(err)
Expand Down

0 comments on commit d24bbf4

Please sign in to comment.