-
Notifications
You must be signed in to change notification settings - Fork 4k
Expand file tree
/
Copy pathmain_test.go
More file actions
52 lines (46 loc) · 1.23 KB
/
Copy pathmain_test.go
File metadata and controls
52 lines (46 loc) · 1.23 KB
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
49
50
51
52
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) {
// This smoke test runs in the go-tests-short CI workflow, which does not build the Rust
// op-reth binary. Use op-geth here until the workflow can provide an op-reth binary.
t.Setenv("DEVSTACK_L2EL_KIND", string(sysgo.MixedL2ELOpGeth))
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
}
}
}