github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/test/e2e/runner/wait.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/ari-anchor/sei-tendermint/libs/log"
     8  	e2e "github.com/ari-anchor/sei-tendermint/test/e2e/pkg"
     9  )
    10  
    11  // Wait waits for a number of blocks to be produced, and for all nodes to catch
    12  // up with it.
    13  func Wait(ctx context.Context, logger log.Logger, testnet *e2e.Testnet, blocks int64) error {
    14  	block, err := getLatestBlock(ctx, testnet)
    15  	if err != nil {
    16  		return err
    17  	}
    18  	return WaitUntil(ctx, logger, testnet, block.Height+blocks)
    19  }
    20  
    21  // WaitUntil waits until a given height has been reached.
    22  func WaitUntil(ctx context.Context, logger log.Logger, testnet *e2e.Testnet, height int64) error {
    23  	logger.Info(fmt.Sprintf("Waiting for all nodes to reach height %v...", height))
    24  
    25  	_, _, err := waitForHeight(ctx, testnet, height)
    26  
    27  	return err
    28  }