github.com/celestiaorg/celestia-node@v0.15.0-beta.1/nodebuilder/tests/swamp/swamp_tx.go (about)

     1  package swamp
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"github.com/cosmos/cosmos-sdk/client/flags"
     8  
     9  	"github.com/celestiaorg/celestia-app/test/util/testnode"
    10  )
    11  
    12  // FillBlocks produces the given amount of contiguous blocks with customizable size.
    13  // The returned channel reports when the process is finished.
    14  func FillBlocks(ctx context.Context, cctx testnode.Context, accounts []string, bsize, blocks int) chan error {
    15  	errCh := make(chan error)
    16  	go func() {
    17  		// TODO: FillBlock must respect the context
    18  		// fill blocks is not working correctly without sleep rn.
    19  		time.Sleep(time.Millisecond * 50)
    20  		var err error
    21  		for i := 0; i < blocks; i++ {
    22  			_, err = cctx.FillBlock(bsize, accounts, flags.BroadcastBlock)
    23  			if err != nil {
    24  				break
    25  			}
    26  		}
    27  
    28  		select {
    29  		case errCh <- err:
    30  		case <-ctx.Done():
    31  		}
    32  	}()
    33  	return errCh
    34  }