Skip to content
Merged
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
10 changes: 9 additions & 1 deletion playground/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func (b *ArtifactsBuilder) Build(out *output) error {
// override l2 genesis, make the timestamp start 2 seconds after the L1 genesis
input := map[string]interface{}{
"timestamp": hexutil.Uint64(opTimestamp).String(),
"allocs": allocs,
"alloc": allocs,
}
if forkTime != nil {
// We need to enable prague on the EL to enable the engine v4 calls
Expand Down Expand Up @@ -422,6 +422,14 @@ func NewOutput(dst string) (*output, error) {
return out, nil
}

func (o *output) Read(path string) (string, error) {
data, err := os.ReadFile(filepath.Join(o.dst, path))
if err != nil {
return "", err
}
return string(data), nil
}

func (o *output) AbsoluteDstPath() (string, error) {
return filepath.Abs(o.dst)
}
Expand Down
18 changes: 18 additions & 0 deletions playground/artifacts_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package playground

import (
"encoding/json"
"os"
"testing"

"github.com/ethereum/go-ethereum/core"
"github.com/stretchr/testify/require"
)

func TestEnodeGeneration(t *testing.T) {
Expand All @@ -17,6 +21,20 @@ func TestEnodeGeneration(t *testing.T) {
}
}

func TestL2PrefundedAccounts(t *testing.T) {
o := newTestOutput(t)

b := NewArtifactsBuilder()
require.NoError(t, b.Build(o))

genesisRaw, err := o.Read("l2-genesis.json")
require.NoError(t, err)

var genesis core.Genesis
require.NoError(t, json.Unmarshal([]byte(genesisRaw), &genesis))
require.Len(t, genesis.Alloc, 10)
}

func newTestOutput(t *testing.T) *output {
dir, err := os.MkdirTemp("/tmp", "test-output")
if err != nil {
Expand Down
14 changes: 13 additions & 1 deletion playground/components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"encoding/json"
"fmt"
"math/big"
"math/rand"
"net/http"
"os"
Expand All @@ -14,6 +15,7 @@ import (
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/require"
Expand All @@ -23,7 +25,17 @@ func TestRecipeOpstackSimple(t *testing.T) {
tt := newTestFramework(t)
defer tt.Close()

tt.test(&OpRecipe{}, nil)
m := tt.test(&OpRecipe{}, nil)

httpPort := m.MustGetService("op-geth").MustGetPort("http")
client, err := ethclient.Dial(fmt.Sprintf("http://localhost:%d", httpPort.HostPort))
require.NoError(t, err)

// validate that the default addresses are prefunded
knownAddress := common.HexToAddress("0xf49Fd6e51aad88F6F4ce6aB8827279cffFb92266")
balance, err := client.BalanceAt(context.Background(), knownAddress, nil)
require.NoError(t, err)
require.NotEqual(t, balance, big.NewInt(0))
}

func TestRecipeOpstackExternalBuilder(t *testing.T) {
Expand Down