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