Skip to content

Commit

Permalink
feat: OP Stack integration test - parallel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask committed Jun 10, 2024
1 parent 334d552 commit 5620c87
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 89 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
run: |
make test
- name: Run Optimism Test
run: |
make optimism-test
gosec:
runs-on: ubuntu-latest
env:
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ run-server:
clean:
rm bin/eigenda-proxy

test: optimism-test
go test -v ./...
test:
go test -v ./... -parallel 4

optimism-test:
OPTIMISM=true go test -timeout 50m -v ./e2e/... -deploy-config ../.devnet/devnetL1.json

holesky-test:
TESTNET=true go test -timeout 50m -v ./e2e
TESTNET=true go test -timeout 50m -v ./e2e -parallel

.PHONY: lint
lint:
@if ! test -f &> /dev/null; \
Expand All @@ -59,7 +59,7 @@ srs:
cd operator-setup && ./srs_setup.sh; \
fi

op-devnet-allocs: submodules
op-devnet-allocs:
@echo "Generating devnet allocs..."
@./scripts/op-devnet-allocs.sh

Expand Down
2 changes: 2 additions & 0 deletions common/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func TestParseByteAmount(t *testing.T) {
t.Parallel()

testCases := []struct {
input string
expected uint64
Expand Down
100 changes: 18 additions & 82 deletions e2e/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,92 +15,26 @@ import (
"github.com/stretchr/testify/require"
)

func TestHoleskyWithPlasmaClient(t *testing.T) {
if !runTestnetIntegrationTests || runOptimismIntegrationTests {
t.Skip("Skipping testnet integration test")
}

ts, kill := e2e.CreateTestSuite(t, false)
defer kill()

daClient := op_plasma.NewDAClient(ts.Address(), false, false)
t.Log("Waiting for client to establish connection with plasma server...")
// wait for server to come online after starting
time.Sleep(5 * time.Second)

// 1 - write arbitrary data to EigenDA

var testPreimage = []byte("inter-subjective and not objective!")

t.Log("Setting input data on proxy server...")
commit, err := daClient.SetInput(ts.Ctx, testPreimage)
require.NoError(t, err)

// 2 - fetch data from EigenDA for generated commitment key
t.Log("Getting input data from proxy server...")
preimage, err := daClient.GetInput(ts.Ctx, commit)
require.NoError(t, err)
require.Equal(t, testPreimage, preimage)
}

func TestHoleskyWithProxyClient(t *testing.T) {
if !runTestnetIntegrationTests || runOptimismIntegrationTests {
t.Skip("Skipping testnet integration test")
func useMemory() bool {
if runOptimismIntegrationTests {
return true
}

ts, kill := e2e.CreateTestSuite(t, false)
defer kill()

cfg := &client.Config{
URL: ts.Address(),
if runTestnetIntegrationTests {
return false
}
daClient := client.New(cfg)
t.Log("Waiting for client to establish connection with plasma server...")
// wait for server to come online after starting
wait.For(ts.Ctx, time.Second*1, func() (bool, error) {
err := daClient.Health()
if err != nil {
return false, nil
}

return true, nil
})

// 1 - write arbitrary data to EigenDA

var testPreimage = []byte("inter-subjective and not objective!")

t.Log("Setting input data on proxy server...")
blobInfo, err := daClient.SetData(ts.Ctx, testPreimage)
require.NoError(t, err)

// 2 - fetch data from EigenDA for generated commitment key
t.Log("Getting input data from proxy server...")
preimage, err := daClient.GetData(ts.Ctx, blobInfo, common.BinaryDomain)
require.NoError(t, err)
require.Equal(t, testPreimage, preimage)

// 3 - fetch iFFT representation of preimage
iFFTPreimage, err := daClient.GetData(ts.Ctx, blobInfo, common.PolyDomain)
require.NoError(t, err)
require.NotEqual(t, preimage, iFFTPreimage)

// 4 - Assert domain transformations

ifftCodec := codecs.NewIFFTCodec(codecs.DefaultBlobCodec{})

decodedBlob, err := ifftCodec.DecodeBlob(iFFTPreimage)
require.NoError(t, err)

require.Equal(t, decodedBlob, preimage)
return true
}

func TestMemStoreWithPlasmaClient(t *testing.T) {
if runTestnetIntegrationTests || runOptimismIntegrationTests {
t.Skip("Skipping non-testnet integration test")
func TestPlasmaClient(t *testing.T) {
t.Parallel()

if runOptimismIntegrationTests {
t.Skip("Skipping testnet integration test")
}

ts, kill := e2e.CreateTestSuite(t, true)
ts, kill := e2e.CreateTestSuite(t, useMemory())
defer kill()

daClient := op_plasma.NewDAClient(ts.Address(), false, false)
Expand All @@ -123,12 +57,14 @@ func TestMemStoreWithPlasmaClient(t *testing.T) {
require.Equal(t, testPreimage, preimage)
}

func TestMemStoreWithProxyClient(t *testing.T) {
if runTestnetIntegrationTests || runOptimismIntegrationTests {
t.Skip("Skipping non-testnet integration test")
func TestProxyClient(t *testing.T) {
t.Parallel()

if runOptimismIntegrationTests {
t.Skip("Skipping testnet integration test")
}

ts, kill := e2e.CreateTestSuite(t, true)
ts, kill := e2e.CreateTestSuite(t, useMemory())
defer kill()

cfg := &client.Config{
Expand Down
6 changes: 4 additions & 2 deletions e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const (
transport = "http"
SvcName = "eigenda_proxy"
host = "127.0.0.1"
port = 4200
HoleskyDA = "disperser-holesky.eigenda.xyz:443"
)

Expand Down Expand Up @@ -84,7 +83,7 @@ func CreateTestSuite(t *testing.T, useMemory bool) (TestSuite, func()) {
log,
)
require.NoError(t, err)
server := server.NewServer(host, port, store, log, metrics.NoopMetrics)
server := server.NewServer(host, 0, store, log, metrics.NoopMetrics)

t.Log("Starting proxy server...")
err = server.Start()
Expand All @@ -104,5 +103,8 @@ func CreateTestSuite(t *testing.T, useMemory bool) (TestSuite, func()) {
}

func (ts *TestSuite) Address() string {
// read port from listener
port := ts.Server.Port()

return fmt.Sprintf("%s://%s:%d", transport, host, port)
}
7 changes: 7 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,10 @@ func ReadDomainFilter(r *http.Request) (common.DomainType, error) {
func (svr *Server) Store() store.Store {
return svr.store
}

func (svr *Server) Port() int {
// read from listener
_, portStr, _ := net.SplitHostPort(svr.listener.Addr().String())
port, _ := strconv.Atoi(portStr)
return port
}
2 changes: 2 additions & 0 deletions store/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func TestGetSet(t *testing.T) {
}

func TestExpiration(t *testing.T) {
t.Parallel()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand Down
1 change: 1 addition & 0 deletions verify/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestVerification(t *testing.T) {
t.Parallel()

var data = []byte("inter-subjective and not objective!")

Expand Down

0 comments on commit 5620c87

Please sign in to comment.