forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
48 lines (43 loc) · 1016 Bytes
/
main_test.go
File metadata and controls
48 lines (43 loc) · 1016 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"context"
"io"
"sync"
"testing"
"time"
"github.com/ethereum-optimism/optimism/op-devstack/sysgo"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/require"
)
func TestRun(t *testing.T) {
var wg sync.WaitGroup
defer wg.Wait()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
errCh := make(chan error)
wg.Add(1)
go func() {
defer wg.Done()
defer close(errCh)
if err := run(ctx, []string{"op-up", "--dir", t.TempDir()}, io.Discard, io.Discard); err != nil {
errCh <- err
}
}()
client, err := ethclient.DialContext(ctx, "http://localhost:8545")
require.NoError(t, err)
ticker := time.NewTicker(time.Millisecond * 250)
for {
select {
case e := <-errCh:
require.NoError(t, e)
case <-ticker.C:
chainID, err := client.ChainID(ctx)
if err != nil {
t.Logf("error while querying chain ID, will retry: %s", err)
continue
}
require.Equal(t, sysgo.DefaultL2AID.ToBig(), chainID)
return
}
}
}