Skip to content

Commit

Permalink
chore: Better abstract secondary storage - more test clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask committed Oct 20, 2024
1 parent 2bb21b6 commit 0c3a48c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
1 change: 0 additions & 1 deletion e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,5 @@ func requireOPClientSetGet(t *testing.T, ts e2e.TestSuite, blob []byte, precompu
preimage, err := daClient.GetInput(ts.Ctx, commit)
require.NoError(t, err)
require.Equal(t, blob, preimage)
requireDispersalRetrievalEigenDA(t, ts.Metrics.HTTPServerRequestsTotal, commitments.OptimismKeccak)

}
1 change: 1 addition & 0 deletions e2e/optimism_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"

"github.com/stretchr/testify/require"
)

Expand Down
5 changes: 5 additions & 0 deletions e2e/safety_checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import (
"github.com/stretchr/testify/require"
)

func isNilPtrDerefPanic(err string) bool {
return strings.Contains(err, "panic") && strings.Contains(err, "SIGSEGV") &&
strings.Contains(err, "nil pointer dereference")
}

// TestOpClientKeccak256MalformedInputs tests the NewDAClient from altda by setting and getting against []byte("")
// preimage. It sets the precompute option to false on the NewDAClient.
func TestOpClientKeccak256MalformedInputs(t *testing.T) {
Expand Down
25 changes: 18 additions & 7 deletions e2e/server_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package e2e_test

import (
"strings"
"testing"
"time"

"github.com/Layr-Labs/eigenda-proxy/client"
"github.com/Layr-Labs/eigenda-proxy/commitments"
"github.com/Layr-Labs/eigenda-proxy/store"
"github.com/stretchr/testify/require"

"github.com/Layr-Labs/eigenda-proxy/e2e"
)
Expand All @@ -15,11 +16,6 @@ func useMemory() bool {
return !runTestnetIntegrationTests
}

func isNilPtrDerefPanic(err string) bool {
return strings.Contains(err, "panic") && strings.Contains(err, "SIGSEGV") &&
strings.Contains(err, "nil pointer dereference")
}

func TestOptimismClientWithKeccak256Commitment(t *testing.T) {
if !runIntegrationTests && !runTestnetIntegrationTests {
t.Skip("Skipping test as INTEGRATION or TESTNET env var not set")
Expand Down Expand Up @@ -145,12 +141,27 @@ func TestProxyReadFallback(t *testing.T) {
testCfg := e2e.TestConfig(useMemory())
testCfg.UseS3Fallback = true
// ensure that blob memstore eviction times result in near immediate activation
testCfg.Expiration = time.Nanosecond * 1
testCfg.Expiration = time.Millisecond * 1

tsConfig := e2e.TestSuiteConfig(testCfg)
ts, kill := e2e.CreateTestSuite(tsConfig)
defer kill()

cfg := &client.Config{
URL: ts.Address(),
}
daClient := client.New(cfg)
expectedBlob := e2e.Rand[[]byte](1_000_000)
t.Log("Setting input data on proxy server...")
blobInfo, err := daClient.SetData(ts.Ctx, expectedBlob)
require.NoError(t, err)

time.Sleep(1 * time.Second)
t.Log("Getting input data from proxy server...")
actualBlob, err := daClient.GetData(ts.Ctx, blobInfo)
require.NoError(t, err)
require.Equal(t, expectedBlob, actualBlob)

requireSimpleClientSetGet(t, ts, e2e.Rand[[]byte](1_000_000))
requireWriteReadSecondary(t, ts.Metrics.SecondaryRequestsTotal, store.S3BackendType)
requireDispersalRetrievalEigenDA(t, ts.Metrics.HTTPServerRequestsTotal, commitments.SimpleCommitmentMode)
Expand Down
2 changes: 1 addition & 1 deletion metrics/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (cm *CountMap) Get(labels ...string) (uint64, error) {

val, exists := cm.m.Load(key.Hex())
if !exists {
return 0, fmt.Errorf("value doesn't exist")
return 0, fmt.Errorf("value doesn't exist for key %s", key.String())
}
uint64Val, ok := val.(uint64)
if !ok {
Expand Down

0 comments on commit 0c3a48c

Please sign in to comment.