2023-04-14 06:26:46 +00:00
|
|
|
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)
|
2023-04-14 06:26:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|