ipld-eth-server/integration/util_test.go

29 lines
492 B
Go
Raw Permalink Normal View History

package integration_test
import (
"context"
"errors"
"time"
"github.com/ethereum/go-ethereum/ethclient"
)
func waitForBlock(ctx context.Context, client *ethclient.Client, target int64) error {
timeout := 10 * time.Second
for {
select {
case <-time.After(timeout):
return errors.New("timed out")
default:
latest, err := client.BlockNumber(ctx)
if err != nil {
return err
}
if uint64(target) <= latest {
return nil
}
2023-05-28 11:01:14 +00:00
time.Sleep(time.Second)
}
}
}