Skip to content

Commit

Permalink
feat: Fault Testing Support - fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ethenotethan committed Jul 31, 2024
1 parent fdbb1a1 commit 15488b4
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ clean:
test:
go test -v ./... -parallel 4

e2e-test: stop-minio run-minio
e2e-test: run-minio
$(E2ETEST) && \
make stop-minio

holesky-test: stop-minio run-minio
holesky-test: run-minio
$(HOLESKYTEST) && \
make stop-minio

Expand Down
39 changes: 0 additions & 39 deletions common/common.go

This file was deleted.

12 changes: 12 additions & 0 deletions e2e/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ func TestProxyClient(t *testing.T) {
}

func TestProxyServerFaultMode(t *testing.T) {
if !runIntegrationTests {
t.Skip("Skipping test as INTEGRATION or TESTNET env var not set")
}

if runTestnetIntegrationTests {
t.Skip("Skipping test since fault mode is only supported for memstore implementations")
}

fc := &store.FaultConfig{
Actors: map[string]store.Behavior{
"sequencer": {
Expand Down Expand Up @@ -197,6 +205,10 @@ func TestProxyClientWithOversizedBlob(t *testing.T) {
}

func TestProxyClient_MultiSameContentBlobs_SameBatch(t *testing.T) {
if !runIntegrationTests && !runTestnetIntegrationTests {
t.Skip("Skipping test as INTEGRATION or TESTNET env var not set")
}

t.Parallel()

ts, kill := e2e.CreateTestSuite(t, useMemory(), false, nil)
Expand Down
5 changes: 5 additions & 0 deletions e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ func CreateTestSuite(t *testing.T, useMemory bool, useS3 bool, fc *store.FaultCo
ctx,
log,
)

if fc != nil {
store.GetMemStore().SetFaultConfig(fc)
}

require.NoError(t, err)
server := server.NewServer(host, 0, store, log, metrics.NoopMetrics)

Expand Down
2 changes: 1 addition & 1 deletion fault.example.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"all": {
"mode": "interval_byzantine",
"interval": 2
"interval": 1
}
}
3 changes: 1 addition & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"github.com/Layr-Labs/eigenda-proxy/commitments"
"github.com/Layr-Labs/eigenda-proxy/common"
"github.com/Layr-Labs/eigenda-proxy/metrics"
"github.com/Layr-Labs/eigenda-proxy/store"
"github.com/ethereum-optimism/optimism/op-service/rpc"
Expand All @@ -37,7 +36,7 @@ const (

type Store interface {
// Get retrieves the given key if it's present in the key-value data store.
Get(ctx context.Context, key []byte, domain common.DomainType) ([]byte, error)
Get(ctx context.Context, key []byte) ([]byte, error)
// Put inserts the given value into the key-value data store.
Put(ctx context.Context, value []byte) (key []byte, err error)
// Stats returns the current usage metrics of the key-value data store.
Expand Down
8 changes: 7 additions & 1 deletion store/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func NewMemStore(ctx context.Context, verifier *verify.Verifier, l log.Logger, m
return store, nil
}

func (e *MemStore) SetFaultConfig(fc *FaultConfig) {
e.Lock()
defer e.Unlock()
e.faultCfg = fc
}

func (e *MemStore) EventLoop(ctx context.Context) {
timer := time.NewTicker(DefaultPruneInterval)

Expand Down Expand Up @@ -131,7 +137,7 @@ func (e *MemStore) Get(ctx context.Context, commit []byte) ([]byte, error) {

switch behavior.Mode {
case Honest:
return encodedBlob, nil
return decodedBlob, nil
case Byzantine:
return e.corruptBlob(decodedBlob), nil

Expand Down

0 comments on commit 15488b4

Please sign in to comment.