From dc618fc780ad75fd07f9bdc525cba1fe2bee7d77 Mon Sep 17 00:00:00 2001 From: Wondertan Date: Thu, 6 Oct 2022 18:23:47 +0200 Subject: [PATCH] fix(swamp): simplify and correct FillBlocks and increase amount of preallocated accounts FillBlocks was generating much more blocks than expected. Calling of testnode.FillBlock once with block amount of accounts fixes it. Also, the amoung of preallocated accounts was increased, to ensure enough blocks can be generated --- nodebuilder/tests/swamp/swamp.go | 2 +- nodebuilder/tests/swamp/swamp_tx.go | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/nodebuilder/tests/swamp/swamp.go b/nodebuilder/tests/swamp/swamp.go index c81ece5815..152b6e6344 100644 --- a/nodebuilder/tests/swamp/swamp.go +++ b/nodebuilder/tests/swamp/swamp.go @@ -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)) } diff --git a/nodebuilder/tests/swamp/swamp_tx.go b/nodebuilder/tests/swamp/swamp_tx.go index 75363ea3c7..d6e78e7628 100644 --- a/nodebuilder/tests/swamp/swamp_tx.go +++ b/nodebuilder/tests/swamp/swamp_tx.go @@ -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" ) @@ -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 }