Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/espresso-devnet-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Compile contracts
run: just compile-contracts

- name: Build Devnet
- name: Build Devnet without TEE
run: |
cd op-deployer
just
Expand All @@ -48,8 +48,8 @@ jobs:
docker compose build
docker compose pull l1-validator espresso-dev-node l1-data-init

- name: Run Smoke test
run: go test -timeout 30m -p 1 -count 1 -run 'TestSmoke' -v ./espresso/devnet-tests/...
- name: Run Smoke test without TEE
run: go test -timeout 30m -p 1 -count 1 -run 'TestSmokeWithoutTEE' -v ./espresso/devnet-tests/...

- name: Run Challenge Game test
run: go test -timeout 30m -p 1 -count 1 -run 'TestChallengeGame' -v ./espresso/devnet-tests/...
Expand All @@ -66,6 +66,14 @@ jobs:
- name: Run Change Batch Inbox Owner test
run: go test -timeout 30m -p 1 -count 1 -run 'TestChangeBatchInboxOwner' -v ./espresso/devnet-tests/...

- name: Build Devnet with TEE
run: |
cd espresso
COMPOSE_PROFILES=tee docker compose build

- name: Run Smoke test with TEE
run: go test -timeout 30m -p 1 -count 1 -run 'TestSmokeWithTEE' -v ./espresso/devnet-tests/...

- name: Save Nix cache
uses: nix-community/cache-nix-action/save@v6
if: always() && steps.cache-nix-restore.outputs.hit-primary-key != 'true'
Expand Down
2 changes: 1 addition & 1 deletion espresso/devnet-tests/batcher_restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestBatcherRestart(t *testing.T) {
defer cancel()

d := NewDevnet(ctx, t)
require.NoError(t, d.Up())
require.NoError(t, d.Up(NON_TEE))
defer func() {
require.NoError(t, d.Down())
}()
Expand Down
2 changes: 1 addition & 1 deletion espresso/devnet-tests/challenge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestChallengeGame(t *testing.T) {
defer cancel()

d := NewDevnet(ctx, t)
require.NoError(t, d.Up())
require.NoError(t, d.Up(NON_TEE))
defer func() {
require.NoError(t, d.Down())
}()
Expand Down
44 changes: 41 additions & 3 deletions espresso/devnet-tests/devnet_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ func (d *Devnet) isRunning() bool {
return len(out) > 0
}

func (d *Devnet) Up() (err error) {
// The setting for `COMPOES_PROFILES` when running the Docker Compose.
type ComposeProfile string

const (
TEE ComposeProfile = "tee"
NON_TEE ComposeProfile = "default"
)

func (d *Devnet) Up(profile ComposeProfile) (err error) {
if d.isRunning() {
if err := d.Down(); err != nil {
return err
Expand All @@ -125,10 +133,10 @@ func (d *Devnet) Up() (err error) {
d.ctx,
"docker", "compose", "up", "-d",
)
cmd.Env = append(os.Environ(), "COMPOSE_PROFILES="+string(profile))
cmd.Env = append(
os.Environ(),
fmt.Sprintf("OP_BATCHER_PRIVATE_KEY=%s", hex.EncodeToString(crypto.FromECDSA(d.secrets.Batcher))),
"COMPOSE_PROFILES=default",
)
buf := new(bytes.Buffer)
cmd.Stderr = buf
Expand Down Expand Up @@ -448,7 +456,37 @@ func (d *Devnet) Down() error {
d.ctx,
"docker", "compose", "down", "-v", "--remove-orphans", "--timeout", "10",
)
return cmd.Run()
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to shut down docker: %w", err)
}

outBatcher, _ := exec.Command("docker", "ps", "-q", "--filter", "ancestor=op-batcher-tee:espresso").Output()
batcherContainers := strings.Fields(string(outBatcher))
if len(batcherContainers) > 0 {
cmd = exec.Command("docker", append([]string{"stop"}, batcherContainers...)...)
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to stop the batcher container: %w", err)
}
cmd = exec.Command("docker", append([]string{"rm"}, batcherContainers...)...)
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to remove the batcher container: %w", err)
}
}

outEnclave, _ := exec.Command("docker", "ps", "-aq", "--filter", "name=batcher-enclaver-").Output()
enclaveContainers := strings.Fields(string(outEnclave))
if len(enclaveContainers) > 0 {
cmd = exec.Command("docker", append([]string{"stop"}, enclaveContainers...)...)
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to stop the enclave container: %w", err)
}
cmd = exec.Command("docker", append([]string{"rm"}, enclaveContainers...)...)
if err := cmd.Run(); err != nil {
return fmt.Errorf("failed to remove the enclave container: %w", err)
}
}

return nil
}

type TaggedWriter struct {
Expand Down
4 changes: 2 additions & 2 deletions espresso/devnet-tests/key_rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestRotateBatcherKey(t *testing.T) {
// We're going to change batcher key to Bob's, verify that it won't be a no-op
require.NotEqual(t, d.secrets.Batcher, d.secrets.Bob)

require.NoError(t, d.Up())
require.NoError(t, d.Up(NON_TEE))
defer func() {
require.NoError(t, d.Down())
}()
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestChangeBatchInboxOwner(t *testing.T) {

d := NewDevnet(ctx, t)

require.NoError(t, d.Up())
require.NoError(t, d.Up(NON_TEE))
defer func() {
require.NoError(t, d.Down())
}()
Expand Down
18 changes: 16 additions & 2 deletions espresso/devnet-tests/smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,26 @@ import (
"github.com/stretchr/testify/require"
)

func TestSmoke(t *testing.T) {
func TestSmokeWithoutTEE(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
defer cancel()

d := NewDevnet(ctx, t)
require.NoError(t, d.Up())
require.NoError(t, d.Up(NON_TEE))
defer func() {
require.NoError(t, d.Down())
}()

// Send a transaction just to check that everything has started up ok.
require.NoError(t, d.RunSimpleL2Burn())
}

func TestSmokeWithTEE(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
defer cancel()

d := NewDevnet(ctx, t)
require.NoError(t, d.Up(TEE))
defer func() {
require.NoError(t, d.Down())
}()
Expand Down
2 changes: 1 addition & 1 deletion espresso/devnet-tests/withdraw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func TestWithdrawal(t *testing.T) {
defer cancel()

d := NewDevnet(ctx, t)
require.NoError(t, d.Up())
require.NoError(t, d.Up(NON_TEE))
defer func() {
require.NoError(t, d.Down())
}()
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ fast-tests:
devnet-tests: build-devnet
U_ID={{uid}} GID={{gid}} go test -timeout 30m -p 1 -count 1 -v ./espresso/devnet-tests/...

devnet-smoke-test: build-devnet
U_ID={{uid}} GID={{gid}} go test -timeout 30m -p 1 -count 1 -run 'TestSmoke' -v ./espresso/devnet-tests/...
devnet-smoke-test-without-tee: build-devnet
U_ID={{uid}} GID={{gid}} go test -timeout 30m -p 1 -count 1 -run 'TestSmokeWithoutTEE' -v ./espresso/devnet-tests/...

devnet-withdrawal-test: build-devnet
U_ID={{uid}} GID={{gid}} go test -timeout 30m -p 1 -count 1 -v -run TestWithdraw ./espresso/devnet-tests/...
Expand Down
Loading