Skip to content

Commit

Permalink
fix(swamp): simplify and correct FillBlocks and increase amount of pr…
Browse files Browse the repository at this point in the history
…eallocated accounts

FillBlocks was generating much more blocks than expected. Calling of testnode.FillBlock once with block amount of accounts fixes it.
Also, the amount of preallocated accounts was increased, to ensure enough blocks can be generated.
Additionally, the blocktime was increased to avoid over production of blocks.
  • Loading branch information
Wondertan committed Oct 6, 2022
1 parent d66fd8c commit 11543be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
4 changes: 2 additions & 2 deletions nodebuilder/tests/reconstruct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestFullReconstructFromBridge(t *testing.T) {
const (
blocks = 20
bsize = 16
btime = time.Millisecond * 100
btime = time.Millisecond * 300
)

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestFullReconstructFromLights(t *testing.T) {
share.DefaultSampleAmount = 20
const (
blocks = 20
btime = time.Millisecond * 100
btime = time.Millisecond * 300
bsize = 16
lnodes = 69
)
Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/tests/swamp/swamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func NewSwamp(t *testing.T, options ...Option) *Swamp {
ctx := context.Background()

// we create an arbitray number of funded accounts
accounts := make([]string, 10)
accounts := make([]string, 100)
for i := 0; i < 10; i++ {
accounts = append(accounts, tmrand.Str(9))
}
Expand Down
17 changes: 5 additions & 12 deletions nodebuilder/tests/swamp/swamp_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/tendermint/tendermint/pkg/consts"

"github.com/celestiaorg/celestia-app/testutil/testnode"

"github.com/celestiaorg/celestia-app/x/payment"
paytypes "github.com/celestiaorg/celestia-app/x/payment/types"
)
Expand All @@ -26,19 +27,11 @@ func (s *Swamp) SubmitData(ctx context.Context, data []byte) error {
return nil
}

func (s *Swamp) FillBlocks(ctx context.Context, bsize, blocks int) error {
func (s *Swamp) FillBlocks(_ context.Context, bsize, blocks int) error {
btime := s.comps.CoreCfg.Consensus.CreateEmptyBlocksInterval
timer := time.NewTimer(btime)
defer timer.Stop()
for i := 0; i < blocks; i++ {
_, err := testnode.FillBlock(s.ClientContext, bsize, s.accounts)
if err != nil {
return err
}
err = testnode.WaitForNextBlock(s.ClientContext)
if err != nil {
return err
}
}
return nil

_, err := testnode.FillBlock(s.ClientContext, bsize, s.accounts[:blocks+1])
return err
}

0 comments on commit 11543be

Please sign in to comment.