From 2c1636a339a9166d50ebda126e043c61808c834f Mon Sep 17 00:00:00 2001 From: anupsv Date: Sun, 1 Sep 2024 22:27:37 -0700 Subject: [PATCH 01/31] initial set of edge cases --- e2e/server_test.go | 135 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 112 insertions(+), 23 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 5c213ce0..5abec06a 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -1,20 +1,25 @@ package e2e_test import ( - "strings" - "testing" - "time" - "github.com/Layr-Labs/eigenda-proxy/client" "github.com/Layr-Labs/eigenda-proxy/e2e" op_plasma "github.com/ethereum-optimism/optimism/op-plasma" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "strings" + "testing" + "time" ) func useMemory() bool { return !runTestnetIntegrationTests } +func isPanic(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") @@ -29,15 +34,44 @@ func TestOptimismClientWithKeccak256Commitment(t *testing.T) { defer kill() daClient := op_plasma.NewDAClient(ts.Address(), false, true) - - testPreimage := []byte(e2e.RandString(100)) - - commit, err := daClient.SetInput(ts.Ctx, testPreimage) - require.NoError(t, err) - - preimage, err := daClient.GetInput(ts.Ctx, commit) - require.NoError(t, err) - require.Equal(t, testPreimage, preimage) + daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) + + // nil commitment. Should return an error but currently is not + t.Run("nil commitment case", func(t *testing.T) { + var commit op_plasma.CommitmentData + _, err := daClient.GetInput(ts.Ctx, commit) + require.Error(t, err) + assert.True(t, !isPanic(err.Error())) + }) + + t.Run("input bad data to SetInput & GetInput", func(t *testing.T) { + testPreimage := []byte("") // Empty preimage + _, err := daClientPcFalse.SetInput(ts.Ctx, testPreimage) + require.Error(t, err) + + // should fail with proper error message as is now, and cannot contain panics or nils + assert.True(t, strings.Contains(err.Error(), "invalid input") && !isPanic(err.Error())) + + // The below test panics silently. + input := op_plasma.NewGenericCommitment([]byte("")) + _, err = daClientPcFalse.GetInput(ts.Ctx, input) + require.Error(t, err) + + // Should not fail on EOF. Should fail before and return with proper error message + assert.False(t, strings.Contains(err.Error(), ": EOF") && !isPanic(err.Error())) + }) + + // nil commitment. Should return an error but currently not + t.Run("normal case", func(t *testing.T) { + testPreimage := []byte(e2e.RandString(100)) + + commit, err := daClient.SetInput(ts.Ctx, testPreimage) + require.NoError(t, err) + + preimage, err := daClient.GetInput(ts.Ctx, commit) + require.NoError(t, err) + require.Equal(t, testPreimage, preimage) + }) } /* @@ -84,16 +118,71 @@ func TestProxyClient(t *testing.T) { } daClient := client.New(cfg) - testPreimage := []byte(e2e.RandString(100)) - - t.Log("Setting input data on proxy server...") - blobInfo, err := daClient.SetData(ts.Ctx, testPreimage) - require.NoError(t, err) - - t.Log("Getting input data from proxy server...") - preimage, err := daClient.GetData(ts.Ctx, blobInfo) - require.NoError(t, err) - require.Equal(t, testPreimage, preimage) + t.Run("normal case case", func(t *testing.T) { + testPreimage := []byte(e2e.RandString(100)) + + t.Log("Setting input data on proxy server...") + blobInfo, err := daClient.SetData(ts.Ctx, testPreimage) + require.NoError(t, err) + + t.Log("Getting input data from proxy server...") + preimage, err := daClient.GetData(ts.Ctx, blobInfo) + require.NoError(t, err) + require.Equal(t, testPreimage, preimage) + }) + + t.Run("single byte preimage set data case", func(t *testing.T) { + testPreimage := []byte{1} // Empty preimage + t.Log("Setting input data on proxy server...") + _, err := daClient.SetData(ts.Ctx, testPreimage) + require.NoError(t, err) + assert.True(t, !isPanic(err.Error())) + }) + + t.Run("unicode preimage set data case", func(t *testing.T) { + testPreimage := []byte("§§©ˆªªˆ˙√ç®∂§∞¶§ƒ¥√¨¥√¨¥ƒƒ©˙˜ø˜˜˜∫˙∫¥∫√†®®√稈¨˙ï") // Empty preimage + t.Log("Setting input data on proxy server...") + _, err := daClient.SetData(ts.Ctx, testPreimage) + require.NoError(t, err) + assert.True(t, !isPanic(err.Error())) + + testPreimage = []byte("§") // Empty preimage + t.Log("Setting input data on proxy server...") + _, err = daClient.SetData(ts.Ctx, testPreimage) + require.NoError(t, err) + assert.True(t, !isPanic(err.Error())) + + }) + + t.Run("empty preimage set data case", func(t *testing.T) { + testPreimage := []byte("") // Empty preimage + t.Log("Setting input data on proxy server...") + _, err := daClient.SetData(ts.Ctx, testPreimage) + require.NoError(t, err) + assert.True(t, !isPanic(err.Error())) + }) + + t.Run("get data edge cases", func(t *testing.T) { + testCert := []byte("") + _, err := daClient.GetData(ts.Ctx, testCert) + require.Error(t, err) + assert.True(t, strings.Contains(err.Error(), + "received error response, code=400, msg = commitment is empty") && !isPanic(err.Error())) + + testCert = []byte{1} + _, err = daClient.GetData(ts.Ctx, testCert) + require.Error(t, err) + assert.True(t, strings.Contains(err.Error(), + "received error response, code=500, msg = failed to decode DA cert to RLP format: EOF") && + !isPanic(err.Error())) + + testCert = []byte(e2e.RandString(10000)) + _, err = daClient.GetData(ts.Ctx, testCert) + require.Error(t, err) + assert.True(t, strings.Contains(err.Error(), + "failed to decode DA cert to RLP format: rlp: expected input list for verify.Certificate") && + !isPanic(err.Error())) + }) } func TestProxyServerWithLargeBlob(t *testing.T) { From ddc223fc3ee0d76896487565a8155c2067df43c9 Mon Sep 17 00:00:00 2001 From: anupsv Date: Mon, 16 Sep 2024 15:54:04 -0700 Subject: [PATCH 02/31] commenting out test checking for nil --- e2e/server_test.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 5abec06a..b45dd3da 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -2,13 +2,14 @@ package e2e_test import ( "github.com/Layr-Labs/eigenda-proxy/client" + "strings" + "testing" + "time" + "github.com/Layr-Labs/eigenda-proxy/e2e" op_plasma "github.com/ethereum-optimism/optimism/op-plasma" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "strings" - "testing" - "time" ) func useMemory() bool { @@ -36,13 +37,13 @@ func TestOptimismClientWithKeccak256Commitment(t *testing.T) { daClient := op_plasma.NewDAClient(ts.Address(), false, true) daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) - // nil commitment. Should return an error but currently is not - t.Run("nil commitment case", func(t *testing.T) { - var commit op_plasma.CommitmentData - _, err := daClient.GetInput(ts.Ctx, commit) - require.Error(t, err) - assert.True(t, !isPanic(err.Error())) - }) + // nil commitment. Should return an error but currently is not. This needs to be fixed by OP + //t.Run("nil commitment case", func(t *testing.T) { + // var commit op_plasma.CommitmentData + // _, err := daClient.GetInput(ts.Ctx, commit) + // require.Error(t, err) + // assert.True(t, !isPanic(err.Error())) + //}) t.Run("input bad data to SetInput & GetInput", func(t *testing.T) { testPreimage := []byte("") // Empty preimage @@ -57,8 +58,8 @@ func TestOptimismClientWithKeccak256Commitment(t *testing.T) { _, err = daClientPcFalse.GetInput(ts.Ctx, input) require.Error(t, err) - // Should not fail on EOF. Should fail before and return with proper error message - assert.False(t, strings.Contains(err.Error(), ": EOF") && !isPanic(err.Error())) + // Should not fail on slice bounds out of range. This needs to be fixed by OP. + //assert.False(t, strings.Contains(err.Error(), ": EOF") && !isPanic(err.Error())) }) // nil commitment. Should return an error but currently not From a8c83b378026e4d2ac954f79fa1dc74ad69c7c87 Mon Sep 17 00:00:00 2001 From: anupsv Date: Mon, 16 Sep 2024 16:03:52 -0700 Subject: [PATCH 03/31] fixing for ci lint --- e2e/server_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 788970fe..7c9f3233 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -39,12 +39,12 @@ func TestOptimismClientWithKeccak256Commitment(t *testing.T) { daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) // nil commitment. Should return an error but currently is not. This needs to be fixed by OP - //t.Run("nil commitment case", func(t *testing.T) { + // t.Run("nil commitment case", func(t *testing.T) { // var commit op_plasma.CommitmentData // _, err := daClient.GetInput(ts.Ctx, commit) // require.Error(t, err) // assert.True(t, !isPanic(err.Error())) - //}) + // }) t.Run("input bad data to SetInput & GetInput", func(t *testing.T) { testPreimage := []byte("") // Empty preimage @@ -60,7 +60,7 @@ func TestOptimismClientWithKeccak256Commitment(t *testing.T) { require.Error(t, err) // Should not fail on slice bounds out of range. This needs to be fixed by OP. - //assert.False(t, strings.Contains(err.Error(), ": EOF") && !isPanic(err.Error())) + // assert.False(t, strings.Contains(err.Error(), ": EOF") && !isPanic(err.Error())) }) // nil commitment. Should return an error but currently not From 040620f730f366c6d1e8ad6143b7dc519a3d4fb1 Mon Sep 17 00:00:00 2001 From: anupsv Date: Mon, 16 Sep 2024 16:19:47 -0700 Subject: [PATCH 04/31] ci fix --- e2e/server_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 7c9f3233..a1f639d0 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -1,11 +1,12 @@ package e2e_test import ( - "github.com/Layr-Labs/eigenda-proxy/client" "strings" "testing" "time" + "github.com/Layr-Labs/eigenda-proxy/client" + "github.com/Layr-Labs/eigenda-proxy/e2e" "github.com/Layr-Labs/eigenda-proxy/store" op_plasma "github.com/ethereum-optimism/optimism/op-plasma" From 1be6eb1273fe2ba94f2a111b150861aab00111e0 Mon Sep 17 00:00:00 2001 From: anupsv Date: Mon, 16 Sep 2024 18:51:30 -0700 Subject: [PATCH 05/31] removing unwanted assert --- e2e/server_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index a1f639d0..1c087108 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -139,7 +139,6 @@ func TestProxyClient(t *testing.T) { t.Log("Setting input data on proxy server...") _, err := daClient.SetData(ts.Ctx, testPreimage) require.NoError(t, err) - assert.True(t, !isPanic(err.Error())) }) t.Run("unicode preimage set data case", func(t *testing.T) { From 933aa34b99947abb746f621ab08ae8f4e6cc565a Mon Sep 17 00:00:00 2001 From: anupsv Date: Mon, 16 Sep 2024 19:06:12 -0700 Subject: [PATCH 06/31] more fixes to tests --- e2e/server_test.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 1c087108..f55022bb 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -107,9 +107,9 @@ func TestOptimismClientWithGenericCommitment(t *testing.T) { } func TestProxyClient(t *testing.T) { - if !runIntegrationTests && !runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - } + //if !runIntegrationTests && !runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} t.Parallel() @@ -146,13 +146,11 @@ func TestProxyClient(t *testing.T) { t.Log("Setting input data on proxy server...") _, err := daClient.SetData(ts.Ctx, testPreimage) require.NoError(t, err) - assert.True(t, !isPanic(err.Error())) testPreimage = []byte("§") // Empty preimage t.Log("Setting input data on proxy server...") _, err = daClient.SetData(ts.Ctx, testPreimage) require.NoError(t, err) - assert.True(t, !isPanic(err.Error())) }) @@ -161,7 +159,6 @@ func TestProxyClient(t *testing.T) { t.Log("Setting input data on proxy server...") _, err := daClient.SetData(ts.Ctx, testPreimage) require.NoError(t, err) - assert.True(t, !isPanic(err.Error())) }) t.Run("get data edge cases", func(t *testing.T) { @@ -169,14 +166,13 @@ func TestProxyClient(t *testing.T) { _, err := daClient.GetData(ts.Ctx, testCert) require.Error(t, err) assert.True(t, strings.Contains(err.Error(), - "received error response, code=400, msg = commitment is empty") && !isPanic(err.Error())) + "commitment is too short") && !isPanic(err.Error())) testCert = []byte{1} _, err = daClient.GetData(ts.Ctx, testCert) require.Error(t, err) assert.True(t, strings.Contains(err.Error(), - "received error response, code=500, msg = failed to decode DA cert to RLP format: EOF") && - !isPanic(err.Error())) + "commitment is too short") && !isPanic(err.Error())) testCert = []byte(e2e.RandString(10000)) _, err = daClient.GetData(ts.Ctx, testCert) From 9209ce1440590ebf14d0d3062a9fc6a5779a0702 Mon Sep 17 00:00:00 2001 From: anupsv Date: Mon, 16 Sep 2024 19:09:39 -0700 Subject: [PATCH 07/31] removing commented code --- e2e/server_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index f55022bb..24cb71c3 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -107,9 +107,9 @@ func TestOptimismClientWithGenericCommitment(t *testing.T) { } func TestProxyClient(t *testing.T) { - //if !runIntegrationTests && !runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } t.Parallel() From 10cfd7f806561ca6db6c81b5c339e30497fa8089 Mon Sep 17 00:00:00 2001 From: anupsv Date: Tue, 17 Sep 2024 10:04:36 -0700 Subject: [PATCH 08/31] separating tests for integration only --- e2e/server_test.go | 84 +++++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 24cb71c3..647f4a19 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -23,11 +23,19 @@ func isPanic(err string) bool { 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") +func TestOptimismClientWithKeccak256CommitmentIntegration(t *testing.T) { + if !runIntegrationTests || runTestnetIntegrationTests { + t.Skip("Skipping test as TESTNET env set or INTEGRATION var not set") } + // nil commitment. Should return an error but currently is not. This needs to be fixed by OP + // t.Run("nil commitment case", func(t *testing.T) { + // var commit op_plasma.CommitmentData + // _, err := daClient.GetInput(ts.Ctx, commit) + // require.Error(t, err) + // assert.True(t, !isPanic(err.Error())) + // }) + t.Parallel() testCfg := e2e.TestConfig(useMemory()) @@ -36,17 +44,8 @@ func TestOptimismClientWithKeccak256Commitment(t *testing.T) { ts, kill := e2e.CreateTestSuite(t, testCfg) defer kill() - daClient := op_plasma.NewDAClient(ts.Address(), false, true) daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) - // nil commitment. Should return an error but currently is not. This needs to be fixed by OP - // t.Run("nil commitment case", func(t *testing.T) { - // var commit op_plasma.CommitmentData - // _, err := daClient.GetInput(ts.Ctx, commit) - // require.Error(t, err) - // assert.True(t, !isPanic(err.Error())) - // }) - t.Run("input bad data to SetInput & GetInput", func(t *testing.T) { testPreimage := []byte("") // Empty preimage _, err := daClientPcFalse.SetInput(ts.Ctx, testPreimage) @@ -64,7 +63,23 @@ func TestOptimismClientWithKeccak256Commitment(t *testing.T) { // assert.False(t, strings.Contains(err.Error(), ": EOF") && !isPanic(err.Error())) }) - // nil commitment. Should return an error but currently not +} + +func TestOptimismClientWithKeccak256Commitment(t *testing.T) { + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } + + t.Parallel() + + testCfg := e2e.TestConfig(useMemory()) + testCfg.UseKeccak256ModeS3 = true + + ts, kill := e2e.CreateTestSuite(t, testCfg) + defer kill() + + daClient := op_plasma.NewDAClient(ts.Address(), false, true) + t.Run("normal case", func(t *testing.T) { testPreimage := []byte(e2e.RandString(100)) @@ -106,7 +121,7 @@ func TestOptimismClientWithGenericCommitment(t *testing.T) { require.Equal(t, testPreimage, preimage) } -func TestProxyClient(t *testing.T) { +func TestProxyClientIntegrationOnly(t *testing.T) { if !runIntegrationTests && !runTestnetIntegrationTests { t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") } @@ -121,19 +136,6 @@ func TestProxyClient(t *testing.T) { } daClient := client.New(cfg) - t.Run("normal case case", func(t *testing.T) { - testPreimage := []byte(e2e.RandString(100)) - - t.Log("Setting input data on proxy server...") - blobInfo, err := daClient.SetData(ts.Ctx, testPreimage) - require.NoError(t, err) - - t.Log("Getting input data from proxy server...") - preimage, err := daClient.GetData(ts.Ctx, blobInfo) - require.NoError(t, err) - require.Equal(t, testPreimage, preimage) - }) - t.Run("single byte preimage set data case", func(t *testing.T) { testPreimage := []byte{1} // Empty preimage t.Log("Setting input data on proxy server...") @@ -181,6 +183,34 @@ func TestProxyClient(t *testing.T) { "failed to decode DA cert to RLP format: rlp: expected input list for verify.Certificate") && !isPanic(err.Error())) }) + +} + +func TestProxyClient(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, e2e.TestConfig(useMemory())) + defer kill() + + cfg := &client.Config{ + URL: ts.Address(), + } + daClient := client.New(cfg) + + testPreimage := []byte(e2e.RandString(100)) + + t.Log("Setting input data on proxy server...") + blobInfo, err := daClient.SetData(ts.Ctx, testPreimage) + require.NoError(t, err) + + t.Log("Getting input data from proxy server...") + preimage, err := daClient.GetData(ts.Ctx, blobInfo) + require.NoError(t, err) + require.Equal(t, testPreimage, preimage) } func TestProxyServerWithLargeBlob(t *testing.T) { From 8e5e6f7a0251594baa277bf0fa211de6daf35bf0 Mon Sep 17 00:00:00 2001 From: anupsv Date: Wed, 18 Sep 2024 12:24:08 -0700 Subject: [PATCH 09/31] changing test name and adding OP issue link --- e2e/server_test.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 647f4a19..65186344 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -23,27 +23,27 @@ func isPanic(err string) bool { strings.Contains(err, "nil pointer dereference") } -func TestOptimismClientWithKeccak256CommitmentIntegration(t *testing.T) { +func TestOpClientKeccak256MalformedInputs(t *testing.T) { if !runIntegrationTests || runTestnetIntegrationTests { t.Skip("Skipping test as TESTNET env set or INTEGRATION var not set") } - // nil commitment. Should return an error but currently is not. This needs to be fixed by OP - // t.Run("nil commitment case", func(t *testing.T) { - // var commit op_plasma.CommitmentData - // _, err := daClient.GetInput(ts.Ctx, commit) - // require.Error(t, err) - // assert.True(t, !isPanic(err.Error())) - // }) - t.Parallel() - testCfg := e2e.TestConfig(useMemory()) testCfg.UseKeccak256ModeS3 = true - ts, kill := e2e.CreateTestSuite(t, testCfg) defer kill() + // nil commitment. Should return an error but currently is not. This needs to be fixed by OP + // Ref: https://github.com/ethereum-optimism/optimism/issues/11987 + //daClient := op_plasma.NewDAClient(ts.Address(), false, true) + //t.Run("nil commitment case", func(t *testing.T) { + // var commit op_plasma.CommitmentData + // _, err := daClient.GetInput(ts.Ctx, commit) + // require.Error(t, err) + // assert.True(t, !isPanic(err.Error())) + //}) + daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) t.Run("input bad data to SetInput & GetInput", func(t *testing.T) { From c7209a07f4f5ac3b25fc55ff7132c70d7b30ddd3 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 11:01:25 -0700 Subject: [PATCH 10/31] Update e2e/server_test.go Co-authored-by: Samuel Laferriere --- e2e/server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 65186344..7dfb7efc 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -18,7 +18,7 @@ func useMemory() bool { return !runTestnetIntegrationTests } -func isPanic(err string) bool { +func isNilPtrDerefPanic(err string) bool { return strings.Contains(err, "panic") && strings.Contains(err, "SIGSEGV") && strings.Contains(err, "nil pointer dereference") } From 951092b2b4a36e0ce185f65bbb77821215f4557a Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 11:14:21 -0700 Subject: [PATCH 11/31] changed test name and fn name --- e2e/server_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 7dfb7efc..5b51ebac 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -52,7 +52,7 @@ func TestOpClientKeccak256MalformedInputs(t *testing.T) { require.Error(t, err) // should fail with proper error message as is now, and cannot contain panics or nils - assert.True(t, strings.Contains(err.Error(), "invalid input") && !isPanic(err.Error())) + assert.True(t, strings.Contains(err.Error(), "invalid input") && !isNilPtrDerefPanic(err.Error())) // The below test panics silently. input := op_plasma.NewGenericCommitment([]byte("")) @@ -121,7 +121,7 @@ func TestOptimismClientWithGenericCommitment(t *testing.T) { require.Equal(t, testPreimage, preimage) } -func TestProxyClientIntegrationOnly(t *testing.T) { +func TestProxyClientServerIntegration(t *testing.T) { if !runIntegrationTests && !runTestnetIntegrationTests { t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") } @@ -168,20 +168,20 @@ func TestProxyClientIntegrationOnly(t *testing.T) { _, err := daClient.GetData(ts.Ctx, testCert) require.Error(t, err) assert.True(t, strings.Contains(err.Error(), - "commitment is too short") && !isPanic(err.Error())) + "commitment is too short") && !isNilPtrDerefPanic(err.Error())) testCert = []byte{1} _, err = daClient.GetData(ts.Ctx, testCert) require.Error(t, err) assert.True(t, strings.Contains(err.Error(), - "commitment is too short") && !isPanic(err.Error())) + "commitment is too short") && !isNilPtrDerefPanic(err.Error())) testCert = []byte(e2e.RandString(10000)) _, err = daClient.GetData(ts.Ctx, testCert) require.Error(t, err) assert.True(t, strings.Contains(err.Error(), "failed to decode DA cert to RLP format: rlp: expected input list for verify.Certificate") && - !isPanic(err.Error())) + !isNilPtrDerefPanic(err.Error())) }) } From 6689c7a797cc7d44d2b93b059910458b1452c168 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 11:26:58 -0700 Subject: [PATCH 12/31] test config changes --- e2e/server_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 85a59bf8..d52c2a3e 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -31,7 +31,8 @@ func TestOpClientKeccak256MalformedInputs(t *testing.T) { t.Parallel() testCfg := e2e.TestConfig(useMemory()) testCfg.UseKeccak256ModeS3 = true - ts, kill := e2e.CreateTestSuite(t, testCfg) + tsConfig := e2e.TestSuiteConfig(t, testCfg) + ts, kill := e2e.CreateTestSuite(t, tsConfig) defer kill() // nil commitment. Should return an error but currently is not. This needs to be fixed by OP @@ -154,7 +155,8 @@ func TestProxyClientServerIntegration(t *testing.T) { t.Parallel() - ts, kill := e2e.CreateTestSuite(t, e2e.TestConfig(useMemory())) + tsConfig := e2e.TestSuiteConfig(t, e2e.TestConfig(useMemory())) + ts, kill := e2e.CreateTestSuite(t, tsConfig) defer kill() cfg := &client.Config{ From fcac380845f0f1fd0509b2806af22ed693a76585 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 11:48:22 -0700 Subject: [PATCH 13/31] making the linter happy --- e2e/server_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index d52c2a3e..12f64f17 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -37,13 +37,13 @@ func TestOpClientKeccak256MalformedInputs(t *testing.T) { // nil commitment. Should return an error but currently is not. This needs to be fixed by OP // Ref: https://github.com/ethereum-optimism/optimism/issues/11987 - //daClient := op_plasma.NewDAClient(ts.Address(), false, true) - //t.Run("nil commitment case", func(t *testing.T) { + // daClient := op_plasma.NewDAClient(ts.Address(), false, true) + // t.Run("nil commitment case", func(t *testing.T) { // var commit op_plasma.CommitmentData // _, err := daClient.GetInput(ts.Ctx, commit) // require.Error(t, err) // assert.True(t, !isPanic(err.Error())) - //}) + // }) daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) From 3e25323e0e5ba5a7f542144e0fde4a280046f159 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 12:17:36 -0700 Subject: [PATCH 14/31] adding comments --- e2e/server_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index 12f64f17..a2431231 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -23,6 +23,8 @@ func isNilPtrDerefPanic(err string) bool { strings.Contains(err, "nil pointer dereference") } +// TestOpClientKeccak256MalformedInputs tests the NewDAClient from op_plasma by setting and getting against []byte("") +// preimage. It sets the precompute option to false on the NewDAClient. func TestOpClientKeccak256MalformedInputs(t *testing.T) { if !runIntegrationTests || runTestnetIntegrationTests { t.Skip("Skipping test as TESTNET env set or INTEGRATION var not set") @@ -61,6 +63,7 @@ func TestOpClientKeccak256MalformedInputs(t *testing.T) { require.Error(t, err) // Should not fail on slice bounds out of range. This needs to be fixed by OP. + // Refer to issue: https://github.com/ethereum-optimism/optimism/issues/11987 // assert.False(t, strings.Contains(err.Error(), ": EOF") && !isPanic(err.Error())) }) @@ -148,6 +151,9 @@ func TestOptimismClientWithGenericCommitment(t *testing.T) { require.Equal(t, testPreimage, preimage) } +// TestProxyClientServerIntegration tests the proxy client and server integration by setting the data as a single byte, +// many unicode characters, single unicode character and an empty preimage. It then tries to get the data from the +// proxy server with empty byte, single byte and random string. func TestProxyClientServerIntegration(t *testing.T) { if !runIntegrationTests && !runTestnetIntegrationTests { t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") @@ -165,19 +171,19 @@ func TestProxyClientServerIntegration(t *testing.T) { daClient := client.New(cfg) t.Run("single byte preimage set data case", func(t *testing.T) { - testPreimage := []byte{1} // Empty preimage + testPreimage := []byte{1} // single byte preimage t.Log("Setting input data on proxy server...") _, err := daClient.SetData(ts.Ctx, testPreimage) require.NoError(t, err) }) t.Run("unicode preimage set data case", func(t *testing.T) { - testPreimage := []byte("§§©ˆªªˆ˙√ç®∂§∞¶§ƒ¥√¨¥√¨¥ƒƒ©˙˜ø˜˜˜∫˙∫¥∫√†®®√稈¨˙ï") // Empty preimage + testPreimage := []byte("§§©ˆªªˆ˙√ç®∂§∞¶§ƒ¥√¨¥√¨¥ƒƒ©˙˜ø˜˜˜∫˙∫¥∫√†®®√稈¨˙ï") // many unicode characters t.Log("Setting input data on proxy server...") _, err := daClient.SetData(ts.Ctx, testPreimage) require.NoError(t, err) - testPreimage = []byte("§") // Empty preimage + testPreimage = []byte("§") // single unicode character t.Log("Setting input data on proxy server...") _, err = daClient.SetData(ts.Ctx, testPreimage) require.NoError(t, err) From e331cbdbe6c51b8a2cf78d18477b026fa27558a2 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 21:28:13 -0700 Subject: [PATCH 15/31] adding fuzzer cases --- .github/workflows/fuzz-tests.yml | 30 +++++++++ Makefile | 6 ++ e2e/server_fuzz_test.go | 66 ++++++++++++++++++ e2e/setup.go | 112 +++++++++++++++++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 .github/workflows/fuzz-tests.yml create mode 100644 e2e/server_fuzz_test.go diff --git a/.github/workflows/fuzz-tests.yml b/.github/workflows/fuzz-tests.yml new file mode 100644 index 00000000..5f86d27a --- /dev/null +++ b/.github/workflows/fuzz-tests.yml @@ -0,0 +1,30 @@ +name: unit-tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + go-test: + outputs: + COVERAGE: ${{ steps.unit.outputs.coverage }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.21 + + - name: Install project dependencies + run: | + go mod download + + - name: Run E2E Fuzz Tests + run: | + make e2e-fuzz-test diff --git a/Makefile b/Makefile index ca54a859..1ddb4008 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ LDFLAGSSTRING +=-X main.Version=$(GIT_TAG) LDFLAGS := -ldflags "$(LDFLAGSSTRING)" E2ETEST = INTEGRATION=true go test -timeout 1m -v ./e2e -parallel 4 -deploy-config ../.devnet/devnetL1.json +E2EFUZZTEST = INTEGRATION=true go test -fuzz ./e2e -deploy-config ../.devnet/devnetL1.json -v -fuzztime=30m HOLESKYTEST = TESTNET=true go test -timeout 50m -v ./e2e -parallel 4 -deploy-config ../.devnet/devnetL1.json .PHONY: eigenda-proxy @@ -56,6 +57,11 @@ e2e-test: stop-minio stop-redis run-minio run-redis make stop-minio && \ make stop-redis +e2e-fuzz-test: stop-minio stop-redis run-minio run-redis + $(E2ETEST) && \ + make stop-minio && \ + make stop-redis + holesky-test: stop-minio stop-redis run-minio run-redis $(HOLESKYTEST) && \ make stop-minio && \ diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go new file mode 100644 index 00000000..27e03aed --- /dev/null +++ b/e2e/server_fuzz_test.go @@ -0,0 +1,66 @@ +package e2e_test + +import ( + "github.com/Layr-Labs/eigenda-proxy/client" + "github.com/Layr-Labs/eigenda-proxy/e2e" + op_plasma "github.com/ethereum-optimism/optimism/op-plasma" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "testing" +) + +func FuzzProxyClientServerIntegration(f *testing.F) { + //if !runIntegrationTests && !runTestnetIntegrationTests { + // f.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} + + testCfg := e2e.TestConfig(useMemory()) + testCfg.UseKeccak256ModeS3 = true + tsConfig := e2e.TestSuiteConfigF(f, testCfg) + ts, kill := e2e.CreateTestSuiteF(f, tsConfig) + defer kill() + + cfg := &client.Config{ + URL: ts.Address(), + } + daClient := client.New(cfg) + + // Add each printable Unicode character as a seed including ascii + //for r := rune(0); r <= unicode.MaxRune; r++ { + // if unicode.IsPrint(r) { + // f.Add(fmt.Sprintf("seed: %s", string(r)), []byte(string(r))) // Add each printable Unicode character as a seed + // } + //} + + f.Fuzz(func(t *testing.T, seed string, data []byte) { + _, err := daClient.SetData(ts.Ctx, data) + require.NoError(t, err) + }) +} + +func FuzzOpClientKeccak256MalformedInputs(f *testing.F) { + if !runIntegrationTests || runTestnetIntegrationTests { + f.Skip("Skipping test as INTEGRATION var not set") + } + + testCfg := e2e.TestConfig(useMemory()) + testCfg.UseKeccak256ModeS3 = true + tsConfig := e2e.TestSuiteConfigF(f, testCfg) + ts, kill := e2e.CreateTestSuiteF(f, tsConfig) + defer kill() + + daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) + + // Fuzz the SetInput function with random data + // seed and data are expected. `seed` value is seed: {i} and data is the one with the random string + f.Fuzz(func(t *testing.T, seed string, data []byte) { + + _, err := daClientPcFalse.SetInput(ts.Ctx, data) + // should fail with proper error message as is now, and cannot contain panics or nils + if err != nil { + assert.True(t, !isNilPtrDerefPanic(err.Error())) + } + + }) + +} diff --git a/e2e/setup.go b/e2e/setup.go index b91cdd67..de7f9b6a 100644 --- a/e2e/setup.go +++ b/e2e/setup.go @@ -6,6 +6,7 @@ import ( "os" "testing" "time" + "unicode" "github.com/Layr-Labs/eigenda-proxy/metrics" "github.com/Layr-Labs/eigenda-proxy/server" @@ -156,6 +157,77 @@ func TestSuiteConfig(t *testing.T, testCfg *Cfg) server.CLIConfig { return cfg } +func TestSuiteConfigF(t *testing.F, testCfg *Cfg) server.CLIConfig { + // load signer key from environment + pk := os.Getenv(privateKey) + if pk == "" && !testCfg.UseMemory { + t.Fatal("SIGNER_PRIVATE_KEY environment variable not set") + } + + // load node url from environment + ethRPC := os.Getenv(ethRPC) + if ethRPC == "" && !testCfg.UseMemory { + t.Fatal("ETHEREUM_RPC environment variable is not set") + } + + var pollInterval time.Duration + if testCfg.UseMemory { + pollInterval = time.Second * 1 + } else { + pollInterval = time.Minute * 1 + } + + eigendaCfg := server.Config{ + ClientConfig: clients.EigenDAClientConfig{ + RPC: holeskyDA, + StatusQueryTimeout: time.Minute * 45, + StatusQueryRetryInterval: pollInterval, + DisableTLS: false, + SignerPrivateKeyHex: pk, + }, + EthRPC: ethRPC, + SvcManagerAddr: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b", // incompatible with non holeskly networks + CacheDir: "../resources/SRSTables", + G1Path: "../resources/g1.point", + MaxBlobLength: "16mib", + G2PowerOfTauPath: "../resources/g2.point.powerOf2", + PutBlobEncodingVersion: 0x00, + MemstoreEnabled: testCfg.UseMemory, + MemstoreBlobExpiration: testCfg.Expiration, + EthConfirmationDepth: 0, + } + + if testCfg.UseMemory { + eigendaCfg.ClientConfig.SignerPrivateKeyHex = "0000000000000000000100000000000000000000000000000000000000000000" + } + + var cfg server.CLIConfig + switch { + case testCfg.UseKeccak256ModeS3: + cfg = createS3Config(eigendaCfg) + + case testCfg.UseS3Caching: + eigendaCfg.CacheTargets = []string{"S3"} + cfg = createS3Config(eigendaCfg) + + case testCfg.UseS3Fallback: + eigendaCfg.FallbackTargets = []string{"S3"} + cfg = createS3Config(eigendaCfg) + + case testCfg.UseRedisCaching: + eigendaCfg.CacheTargets = []string{"redis"} + cfg = createRedisConfig(eigendaCfg) + + default: + cfg = server.CLIConfig{ + EigenDAConfig: eigendaCfg, + MetricsCfg: opmetrics.CLIConfig{}, + } + } + + return cfg +} + type TestSuite struct { Ctx context.Context Log log.Logger @@ -195,6 +267,46 @@ func CreateTestSuite(t *testing.T, testSuiteCfg server.CLIConfig) (TestSuite, fu }, kill } +func CreateTestSuiteF(t *testing.F, testSuiteCfg server.CLIConfig) (TestSuite, func()) { + + for r := rune(0); r <= unicode.MaxRune; r++ { + if unicode.IsPrint(r) { + t.Add(fmt.Sprintf("seed: %s", string(r)), []byte(string(r))) // Add each printable Unicode character as a seed + } + } + + log := oplog.NewLogger(os.Stdout, oplog.CLIConfig{ + Level: log.LevelDebug, + Format: oplog.FormatLogFmt, + Color: true, + }).New("role", svcName) + + ctx := context.Background() + store, err := server.LoadStoreRouter( + ctx, + testSuiteCfg, + log, + ) + require.NoError(t, err) + server := server.NewServer(host, 0, store, log, metrics.NoopMetrics) + + t.Log("Starting proxy server...") + err = server.Start() + require.NoError(t, err) + + kill := func() { + if err := server.Stop(); err != nil { + panic(err) + } + } + + return TestSuite{ + Ctx: ctx, + Log: log, + Server: server, + }, kill +} + func (ts *TestSuite) Address() string { // read port from listener port := ts.Server.Port() From 2fcad31117a8fb880a357e6082578fca72c61363 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 21:29:14 -0700 Subject: [PATCH 16/31] renaming test --- .github/workflows/fuzz-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fuzz-tests.yml b/.github/workflows/fuzz-tests.yml index 5f86d27a..8608e3c9 100644 --- a/.github/workflows/fuzz-tests.yml +++ b/.github/workflows/fuzz-tests.yml @@ -1,4 +1,4 @@ -name: unit-tests +name: fuzz-tests on: push: From 2e74eff82f853cd2ae317d2c51e2ed09923475fc Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 21:31:17 -0700 Subject: [PATCH 17/31] fixing makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1ddb4008..0d208b62 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ e2e-test: stop-minio stop-redis run-minio run-redis make stop-redis e2e-fuzz-test: stop-minio stop-redis run-minio run-redis - $(E2ETEST) && \ + $(E2EFUZZTEST) && \ make stop-minio && \ make stop-redis From 65ec8311c5a970a77a525f6d1c3f2d2457846eac Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 21:32:57 -0700 Subject: [PATCH 18/31] order of command --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0d208b62..69526723 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ LDFLAGSSTRING +=-X main.Version=$(GIT_TAG) LDFLAGS := -ldflags "$(LDFLAGSSTRING)" E2ETEST = INTEGRATION=true go test -timeout 1m -v ./e2e -parallel 4 -deploy-config ../.devnet/devnetL1.json -E2EFUZZTEST = INTEGRATION=true go test -fuzz ./e2e -deploy-config ../.devnet/devnetL1.json -v -fuzztime=30m +E2EFUZZTEST = INTEGRATION=true go test ./e2e -fuzz -deploy-config ../.devnet/devnetL1.json -v -fuzztime=30m HOLESKYTEST = TESTNET=true go test -timeout 50m -v ./e2e -parallel 4 -deploy-config ../.devnet/devnetL1.json .PHONY: eigenda-proxy From 9975ee9ecdc9cea0d25590911e4e02814897c9b5 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Sep 2024 21:37:53 -0700 Subject: [PATCH 19/31] specifying to fuzz --- Makefile | 2 +- e2e/main_test.go | 2 ++ e2e/server_fuzz_test.go | 10 +++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 69526723..73a58c58 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ LDFLAGSSTRING +=-X main.Version=$(GIT_TAG) LDFLAGS := -ldflags "$(LDFLAGSSTRING)" E2ETEST = INTEGRATION=true go test -timeout 1m -v ./e2e -parallel 4 -deploy-config ../.devnet/devnetL1.json -E2EFUZZTEST = INTEGRATION=true go test ./e2e -fuzz -deploy-config ../.devnet/devnetL1.json -v -fuzztime=30m +E2EFUZZTEST = FUZZ=true go test ./e2e -fuzz -deploy-config ../.devnet/devnetL1.json -v -fuzztime=30m HOLESKYTEST = TESTNET=true go test -timeout 50m -v ./e2e -parallel 4 -deploy-config ../.devnet/devnetL1.json .PHONY: eigenda-proxy diff --git a/e2e/main_test.go b/e2e/main_test.go index 36b64e88..92fdd672 100644 --- a/e2e/main_test.go +++ b/e2e/main_test.go @@ -8,11 +8,13 @@ import ( var ( runTestnetIntegrationTests bool runIntegrationTests bool + runFuzzTests bool ) func ParseEnv() { runIntegrationTests = os.Getenv("INTEGRATION") == "true" || os.Getenv("INTEGRATION") == "1" runTestnetIntegrationTests = os.Getenv("TESTNET") == "true" || os.Getenv("TESTNET") == "1" + runFuzzTests = os.Getenv("FUZZ") == "true" || os.Getenv("FUZZ") == "1" } func TestMain(m *testing.M) { diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index 27e03aed..f5f32eef 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -10,9 +10,9 @@ import ( ) func FuzzProxyClientServerIntegration(f *testing.F) { - //if !runIntegrationTests && !runTestnetIntegrationTests { - // f.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runFuzzTests { + f.Skip("Skipping test as FUZZ env var not set") + } testCfg := e2e.TestConfig(useMemory()) testCfg.UseKeccak256ModeS3 = true @@ -39,8 +39,8 @@ func FuzzProxyClientServerIntegration(f *testing.F) { } func FuzzOpClientKeccak256MalformedInputs(f *testing.F) { - if !runIntegrationTests || runTestnetIntegrationTests { - f.Skip("Skipping test as INTEGRATION var not set") + if !runFuzzTests { + f.Skip("Skipping test as FUZZ env var not set") } testCfg := e2e.TestConfig(useMemory()) From 7dec6cb9d2a62933ef73f41c1364ea74078f22b0 Mon Sep 17 00:00:00 2001 From: anupsv Date: Fri, 20 Sep 2024 14:46:10 -0700 Subject: [PATCH 20/31] fixing tests --- e2e/server_fuzz_test.go | 28 ++++++--- e2e/setup.go | 132 ++++------------------------------------ 2 files changed, 31 insertions(+), 129 deletions(-) diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index f5f32eef..417e9299 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -1,14 +1,24 @@ package e2e_test import ( + "fmt" "github.com/Layr-Labs/eigenda-proxy/client" "github.com/Layr-Labs/eigenda-proxy/e2e" op_plasma "github.com/ethereum-optimism/optimism/op-plasma" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" + "unicode" ) +func addUnicodeTestCases(f *testing.F) { + for r := rune(0); r <= unicode.MaxRune; r++ { + if unicode.IsPrint(r) { + f.Add(fmt.Sprintf("seed: %s", string(r)), []byte(string(r))) // Add each printable Unicode character as a seed + } + } +} + func FuzzProxyClientServerIntegration(f *testing.F) { if !runFuzzTests { f.Skip("Skipping test as FUZZ env var not set") @@ -16,22 +26,18 @@ func FuzzProxyClientServerIntegration(f *testing.F) { testCfg := e2e.TestConfig(useMemory()) testCfg.UseKeccak256ModeS3 = true - tsConfig := e2e.TestSuiteConfigF(f, testCfg) - ts, kill := e2e.CreateTestSuiteF(f, tsConfig) + tsConfig := e2e.TestSuiteConfig(f, testCfg) + ts, kill := e2e.CreateTestSuite(f, tsConfig) defer kill() + addUnicodeTestCases(f) + cfg := &client.Config{ URL: ts.Address(), } daClient := client.New(cfg) // Add each printable Unicode character as a seed including ascii - //for r := rune(0); r <= unicode.MaxRune; r++ { - // if unicode.IsPrint(r) { - // f.Add(fmt.Sprintf("seed: %s", string(r)), []byte(string(r))) // Add each printable Unicode character as a seed - // } - //} - f.Fuzz(func(t *testing.T, seed string, data []byte) { _, err := daClient.SetData(ts.Ctx, data) require.NoError(t, err) @@ -39,15 +45,17 @@ func FuzzProxyClientServerIntegration(f *testing.F) { } func FuzzOpClientKeccak256MalformedInputs(f *testing.F) { + if !runFuzzTests { f.Skip("Skipping test as FUZZ env var not set") } testCfg := e2e.TestConfig(useMemory()) testCfg.UseKeccak256ModeS3 = true - tsConfig := e2e.TestSuiteConfigF(f, testCfg) - ts, kill := e2e.CreateTestSuiteF(f, tsConfig) + tsConfig := e2e.TestSuiteConfig(f, testCfg) + ts, kill := e2e.CreateTestSuite(f, tsConfig) defer kill() + addUnicodeTestCases(f) daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) diff --git a/e2e/setup.go b/e2e/setup.go index de7f9b6a..a0d42be7 100644 --- a/e2e/setup.go +++ b/e2e/setup.go @@ -3,22 +3,18 @@ package e2e import ( "context" "fmt" - "os" - "testing" - "time" - "unicode" - "github.com/Layr-Labs/eigenda-proxy/metrics" "github.com/Layr-Labs/eigenda-proxy/server" "github.com/Layr-Labs/eigenda-proxy/store" "github.com/Layr-Labs/eigenda/api/clients" + oplog "github.com/ethereum-optimism/optimism/op-service/log" + opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics" "github.com/ethereum/go-ethereum/log" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" "golang.org/x/exp/rand" - - oplog "github.com/ethereum-optimism/optimism/op-service/log" - opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics" + "os" + "time" "github.com/stretchr/testify/require" ) @@ -86,78 +82,16 @@ func createS3Config(eigendaCfg server.Config) server.CLIConfig { } } -func TestSuiteConfig(t *testing.T, testCfg *Cfg) server.CLIConfig { - // load signer key from environment - pk := os.Getenv(privateKey) - if pk == "" && !testCfg.UseMemory { - t.Fatal("SIGNER_PRIVATE_KEY environment variable not set") - } - - // load node url from environment - ethRPC := os.Getenv(ethRPC) - if ethRPC == "" && !testCfg.UseMemory { - t.Fatal("ETHEREUM_RPC environment variable is not set") - } - - var pollInterval time.Duration - if testCfg.UseMemory { - pollInterval = time.Second * 1 - } else { - pollInterval = time.Minute * 1 - } - - eigendaCfg := server.Config{ - ClientConfig: clients.EigenDAClientConfig{ - RPC: holeskyDA, - StatusQueryTimeout: time.Minute * 45, - StatusQueryRetryInterval: pollInterval, - DisableTLS: false, - SignerPrivateKeyHex: pk, - }, - EthRPC: ethRPC, - SvcManagerAddr: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b", // incompatible with non holeskly networks - CacheDir: "../resources/SRSTables", - G1Path: "../resources/g1.point", - MaxBlobLength: "16mib", - G2PowerOfTauPath: "../resources/g2.point.powerOf2", - PutBlobEncodingVersion: 0x00, - MemstoreEnabled: testCfg.UseMemory, - MemstoreBlobExpiration: testCfg.Expiration, - EthConfirmationDepth: 0, - } - - if testCfg.UseMemory { - eigendaCfg.ClientConfig.SignerPrivateKeyHex = "0000000000000000000100000000000000000000000000000000000000000000" - } - - var cfg server.CLIConfig - switch { - case testCfg.UseKeccak256ModeS3: - cfg = createS3Config(eigendaCfg) - - case testCfg.UseS3Caching: - eigendaCfg.CacheTargets = []string{"S3"} - cfg = createS3Config(eigendaCfg) - - case testCfg.UseS3Fallback: - eigendaCfg.FallbackTargets = []string{"S3"} - cfg = createS3Config(eigendaCfg) - - case testCfg.UseRedisCaching: - eigendaCfg.CacheTargets = []string{"redis"} - cfg = createRedisConfig(eigendaCfg) - - default: - cfg = server.CLIConfig{ - EigenDAConfig: eigendaCfg, - MetricsCfg: opmetrics.CLIConfig{}, - } - } - - return cfg +type TB interface { + Helper() + Log(args ...interface{}) + Error(args ...interface{}) + Fatal(args ...interface{}) + Errorf(format string, args ...interface{}) + FailNow() } -func TestSuiteConfigF(t *testing.F, testCfg *Cfg) server.CLIConfig { +func TestSuiteConfig(t TB, testCfg *Cfg) server.CLIConfig { // load signer key from environment pk := os.Getenv(privateKey) if pk == "" && !testCfg.UseMemory { @@ -234,47 +168,7 @@ type TestSuite struct { Server *server.Server } -func CreateTestSuite(t *testing.T, testSuiteCfg server.CLIConfig) (TestSuite, func()) { - log := oplog.NewLogger(os.Stdout, oplog.CLIConfig{ - Level: log.LevelDebug, - Format: oplog.FormatLogFmt, - Color: true, - }).New("role", svcName) - - ctx := context.Background() - store, err := server.LoadStoreRouter( - ctx, - testSuiteCfg, - log, - ) - require.NoError(t, err) - server := server.NewServer(host, 0, store, log, metrics.NoopMetrics) - - t.Log("Starting proxy server...") - err = server.Start() - require.NoError(t, err) - - kill := func() { - if err := server.Stop(); err != nil { - panic(err) - } - } - - return TestSuite{ - Ctx: ctx, - Log: log, - Server: server, - }, kill -} - -func CreateTestSuiteF(t *testing.F, testSuiteCfg server.CLIConfig) (TestSuite, func()) { - - for r := rune(0); r <= unicode.MaxRune; r++ { - if unicode.IsPrint(r) { - t.Add(fmt.Sprintf("seed: %s", string(r)), []byte(string(r))) // Add each printable Unicode character as a seed - } - } - +func CreateTestSuite(t TB, testSuiteCfg server.CLIConfig) (TestSuite, func()) { log := oplog.NewLogger(os.Stdout, oplog.CLIConfig{ Level: log.LevelDebug, Format: oplog.FormatLogFmt, From 0752a6b581bedf14e1db29bdb57e5349313a0754 Mon Sep 17 00:00:00 2001 From: anupsv Date: Fri, 20 Sep 2024 14:59:31 -0700 Subject: [PATCH 21/31] lint fix --- e2e/server_fuzz_test.go | 9 +++++---- e2e/setup.go | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index 417e9299..50d36e5f 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -2,13 +2,14 @@ package e2e_test import ( "fmt" + "testing" + "unicode" + "github.com/Layr-Labs/eigenda-proxy/client" "github.com/Layr-Labs/eigenda-proxy/e2e" op_plasma "github.com/ethereum-optimism/optimism/op-plasma" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "testing" - "unicode" ) func addUnicodeTestCases(f *testing.F) { @@ -38,7 +39,7 @@ func FuzzProxyClientServerIntegration(f *testing.F) { daClient := client.New(cfg) // Add each printable Unicode character as a seed including ascii - f.Fuzz(func(t *testing.T, seed string, data []byte) { + f.Fuzz(func(t *testing.T, _ string, data []byte) { _, err := daClient.SetData(ts.Ctx, data) require.NoError(t, err) }) @@ -61,7 +62,7 @@ func FuzzOpClientKeccak256MalformedInputs(f *testing.F) { // Fuzz the SetInput function with random data // seed and data are expected. `seed` value is seed: {i} and data is the one with the random string - f.Fuzz(func(t *testing.T, seed string, data []byte) { + f.Fuzz(func(t *testing.T, _ string, data []byte) { _, err := daClientPcFalse.SetInput(ts.Ctx, data) // should fail with proper error message as is now, and cannot contain panics or nils diff --git a/e2e/setup.go b/e2e/setup.go index a0d42be7..efb9375c 100644 --- a/e2e/setup.go +++ b/e2e/setup.go @@ -3,6 +3,9 @@ package e2e import ( "context" "fmt" + "os" + "time" + "github.com/Layr-Labs/eigenda-proxy/metrics" "github.com/Layr-Labs/eigenda-proxy/server" "github.com/Layr-Labs/eigenda-proxy/store" @@ -13,8 +16,6 @@ import ( "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" "golang.org/x/exp/rand" - "os" - "time" "github.com/stretchr/testify/require" ) From a114a71cafa6f60c01648366fce6f73f11e1b8d8 Mon Sep 17 00:00:00 2001 From: anupsv Date: Fri, 20 Sep 2024 15:09:01 -0700 Subject: [PATCH 22/31] combining tests --- e2e/server_fuzz_test.go | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index 50d36e5f..ef9b339c 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -20,7 +20,9 @@ func addUnicodeTestCases(f *testing.F) { } } -func FuzzProxyClientServerIntegration(f *testing.F) { +// FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs will fuzz the proxy client server integration +// and op client keccak256 with malformed inputs +func FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs(f *testing.F) { if !runFuzzTests { f.Skip("Skipping test as FUZZ env var not set") } @@ -31,37 +33,21 @@ func FuzzProxyClientServerIntegration(f *testing.F) { ts, kill := e2e.CreateTestSuite(f, tsConfig) defer kill() + // Add each printable Unicode character as a seed addUnicodeTestCases(f) cfg := &client.Config{ URL: ts.Address(), } daClient := client.New(cfg) + daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) - // Add each printable Unicode character as a seed including ascii f.Fuzz(func(t *testing.T, _ string, data []byte) { _, err := daClient.SetData(ts.Ctx, data) require.NoError(t, err) }) -} - -func FuzzOpClientKeccak256MalformedInputs(f *testing.F) { - if !runFuzzTests { - f.Skip("Skipping test as FUZZ env var not set") - } - - testCfg := e2e.TestConfig(useMemory()) - testCfg.UseKeccak256ModeS3 = true - tsConfig := e2e.TestSuiteConfig(f, testCfg) - ts, kill := e2e.CreateTestSuite(f, tsConfig) - defer kill() - addUnicodeTestCases(f) - - daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) - - // Fuzz the SetInput function with random data - // seed and data are expected. `seed` value is seed: {i} and data is the one with the random string + // seed and data are expected. `seed` value is seed: {rune} and data is the one with the random byte/s f.Fuzz(func(t *testing.T, _ string, data []byte) { _, err := daClientPcFalse.SetInput(ts.Ctx, data) @@ -71,5 +57,4 @@ func FuzzOpClientKeccak256MalformedInputs(f *testing.F) { } }) - } From c2e78e4ebc0da1761444580081b082225e206286 Mon Sep 17 00:00:00 2001 From: anupsv Date: Tue, 24 Sep 2024 12:47:17 -0700 Subject: [PATCH 23/31] small changes --- e2e/server_fuzz_test.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index ef9b339c..d6e93d2c 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" ) -func addUnicodeTestCases(f *testing.F) { +func addAllUnicodeTestCases(f *testing.F) { for r := rune(0); r <= unicode.MaxRune; r++ { if unicode.IsPrint(r) { f.Add(fmt.Sprintf("seed: %s", string(r)), []byte(string(r))) // Add each printable Unicode character as a seed @@ -34,7 +34,7 @@ func FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs(f *test defer kill() // Add each printable Unicode character as a seed - addUnicodeTestCases(f) + addAllUnicodeTestCases(f) cfg := &client.Config{ URL: ts.Address(), @@ -42,19 +42,16 @@ func FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs(f *test daClient := client.New(cfg) daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) + // seed and data are expected. `seed` value is seed: {rune} and data is the one with the random byte(s) f.Fuzz(func(t *testing.T, _ string, data []byte) { + _, err := daClient.SetData(ts.Ctx, data) require.NoError(t, err) - }) - // seed and data are expected. `seed` value is seed: {rune} and data is the one with the random byte/s - f.Fuzz(func(t *testing.T, _ string, data []byte) { - - _, err := daClientPcFalse.SetInput(ts.Ctx, data) + _, err = daClientPcFalse.SetInput(ts.Ctx, data) // should fail with proper error message as is now, and cannot contain panics or nils if err != nil { assert.True(t, !isNilPtrDerefPanic(err.Error())) } - }) } From 801a84e6530f4988856711525fa1a5acac1534f2 Mon Sep 17 00:00:00 2001 From: anupsv Date: Tue, 24 Sep 2024 15:11:36 -0700 Subject: [PATCH 24/31] more comments --- e2e/server_fuzz_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index d6e93d2c..f867c10d 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -21,13 +21,13 @@ func addAllUnicodeTestCases(f *testing.F) { } // FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs will fuzz the proxy client server integration -// and op client keccak256 with malformed inputs +// and op client keccak256 with malformed inputs. This is never meant to be fuzzed with EigenDA. func FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs(f *testing.F) { if !runFuzzTests { f.Skip("Skipping test as FUZZ env var not set") } - testCfg := e2e.TestConfig(useMemory()) + testCfg := e2e.TestConfig(true) testCfg.UseKeccak256ModeS3 = true tsConfig := e2e.TestSuiteConfig(f, testCfg) ts, kill := e2e.CreateTestSuite(f, tsConfig) From 4016241f5e119b4474917a36cd3e24591b8ce0d4 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Dec 2024 12:17:13 +0530 Subject: [PATCH 25/31] fixing tests after rebase --- e2e/server_fuzz_test.go | 72 +++++++++++------------ e2e/server_test.go | 127 ++++++++++++---------------------------- e2e/setup.go | 4 -- 3 files changed, 71 insertions(+), 132 deletions(-) diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index f867c10d..84a82ed0 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -4,12 +4,6 @@ import ( "fmt" "testing" "unicode" - - "github.com/Layr-Labs/eigenda-proxy/client" - "github.com/Layr-Labs/eigenda-proxy/e2e" - op_plasma "github.com/ethereum-optimism/optimism/op-plasma" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func addAllUnicodeTestCases(f *testing.F) { @@ -22,36 +16,36 @@ func addAllUnicodeTestCases(f *testing.F) { // FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs will fuzz the proxy client server integration // and op client keccak256 with malformed inputs. This is never meant to be fuzzed with EigenDA. -func FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs(f *testing.F) { - if !runFuzzTests { - f.Skip("Skipping test as FUZZ env var not set") - } - - testCfg := e2e.TestConfig(true) - testCfg.UseKeccak256ModeS3 = true - tsConfig := e2e.TestSuiteConfig(f, testCfg) - ts, kill := e2e.CreateTestSuite(f, tsConfig) - defer kill() - - // Add each printable Unicode character as a seed - addAllUnicodeTestCases(f) - - cfg := &client.Config{ - URL: ts.Address(), - } - daClient := client.New(cfg) - daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) - - // seed and data are expected. `seed` value is seed: {rune} and data is the one with the random byte(s) - f.Fuzz(func(t *testing.T, _ string, data []byte) { - - _, err := daClient.SetData(ts.Ctx, data) - require.NoError(t, err) - - _, err = daClientPcFalse.SetInput(ts.Ctx, data) - // should fail with proper error message as is now, and cannot contain panics or nils - if err != nil { - assert.True(t, !isNilPtrDerefPanic(err.Error())) - } - }) -} +//func FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs(f *testing.F) { +// if !runFuzzTests { +// f.Skip("Skipping test as FUZZ env var not set") +// } +// +// testCfg := e2e.TestConfig(true) +// testCfg.UseKeccak256ModeS3 = true +// tsConfig := e2e.TestSuiteConfig(testCfg) +// ts, kill := e2e.CreateTestSuite(tsConfig) +// defer kill() +// +// // Add each printable Unicode character as a seed +// addAllUnicodeTestCases(f) +// +// cfg := &client.Config{ +// URL: ts.Address(), +// } +// daClient := client.New(cfg) +// daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) +// +// // seed and data are expected. `seed` value is seed: {rune} and data is the one with the random byte(s) +// f.Fuzz(func(t *testing.T, _ string, data []byte) { +// +// _, err := daClient.SetData(ts.Ctx, data) +// require.NoError(t, err) +// +// _, err = daClientPcFalse.SetInput(ts.Ctx, data) +// // should fail with proper error message as is now, and cannot contain panics or nils +// if err != nil { +// assert.True(t, !isNilPtrDerefPanic(err.Error())) +// } +// }) +//} diff --git a/e2e/server_test.go b/e2e/server_test.go index 0d4b4f30..3a15b4f9 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -1,70 +1,21 @@ package e2e_test import ( - "testing" - "time" "github.com/Layr-Labs/eigenda-proxy/client" "github.com/Layr-Labs/eigenda-proxy/commitments" "github.com/Layr-Labs/eigenda-proxy/common" - "github.com/stretchr/testify/require" "github.com/Layr-Labs/eigenda-proxy/e2e" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "strings" + "testing" + "time" ) 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") -} - -// TestOpClientKeccak256MalformedInputs tests the NewDAClient from op_plasma by setting and getting against []byte("") -// preimage. It sets the precompute option to false on the NewDAClient. -func TestOpClientKeccak256MalformedInputs(t *testing.T) { - if !runIntegrationTests || runTestnetIntegrationTests { - t.Skip("Skipping test as TESTNET env set or INTEGRATION var not set") - } - - t.Parallel() - testCfg := e2e.TestConfig(useMemory()) - testCfg.UseKeccak256ModeS3 = true - tsConfig := e2e.TestSuiteConfig(t, testCfg) - ts, kill := e2e.CreateTestSuite(t, tsConfig) - defer kill() - - // nil commitment. Should return an error but currently is not. This needs to be fixed by OP - // Ref: https://github.com/ethereum-optimism/optimism/issues/11987 - // daClient := op_plasma.NewDAClient(ts.Address(), false, true) - // t.Run("nil commitment case", func(t *testing.T) { - // var commit op_plasma.CommitmentData - // _, err := daClient.GetInput(ts.Ctx, commit) - // require.Error(t, err) - // assert.True(t, !isPanic(err.Error())) - // }) - - daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) - - t.Run("input bad data to SetInput & GetInput", func(t *testing.T) { - testPreimage := []byte("") // Empty preimage - _, err := daClientPcFalse.SetInput(ts.Ctx, testPreimage) - require.Error(t, err) - - // should fail with proper error message as is now, and cannot contain panics or nils - assert.True(t, strings.Contains(err.Error(), "invalid input") && !isNilPtrDerefPanic(err.Error())) - - // The below test panics silently. - input := op_plasma.NewGenericCommitment([]byte("")) - _, err = daClientPcFalse.GetInput(ts.Ctx, input) - require.Error(t, err) - - // Should not fail on slice bounds out of range. This needs to be fixed by OP. - // Refer to issue: https://github.com/ethereum-optimism/optimism/issues/11987 - // assert.False(t, strings.Contains(err.Error(), ": EOF") && !isPanic(err.Error())) - }) - -} - func TestOptimismClientWithKeccak256Commitment(t *testing.T) { if !runIntegrationTests && !runTestnetIntegrationTests { t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") @@ -88,9 +39,9 @@ with a concurrent S3 backend configured */ func TestOptimismClientWithGenericCommitment(t *testing.T) { - if !runIntegrationTests && !runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - } + //if !runIntegrationTests && !runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} t.Parallel() @@ -106,14 +57,14 @@ func TestOptimismClientWithGenericCommitment(t *testing.T) { // many unicode characters, single unicode character and an empty preimage. It then tries to get the data from the // proxy server with empty byte, single byte and random string. func TestProxyClientServerIntegration(t *testing.T) { - if !runIntegrationTests && !runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - } + //if !runIntegrationTests && !runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} t.Parallel() - tsConfig := e2e.TestSuiteConfig(t, e2e.TestConfig(useMemory())) - ts, kill := e2e.CreateTestSuite(t, tsConfig) + tsConfig := e2e.TestSuiteConfig(e2e.TestConfig(useMemory())) + ts, kill := e2e.CreateTestSuite(tsConfig) defer kill() cfg := &client.Config{ @@ -153,33 +104,31 @@ func TestProxyClientServerIntegration(t *testing.T) { _, err := daClient.GetData(ts.Ctx, testCert) require.Error(t, err) assert.True(t, strings.Contains(err.Error(), - "commitment is too short") && !isNilPtrDerefPanic(err.Error())) + "404") && !isNilPtrDerefPanic(err.Error())) testCert = []byte{1} _, err = daClient.GetData(ts.Ctx, testCert) require.Error(t, err) assert.True(t, strings.Contains(err.Error(), - "commitment is too short") && !isNilPtrDerefPanic(err.Error())) + "400") && !isNilPtrDerefPanic(err.Error())) - testCert = []byte(e2e.RandString(10000)) + testCert = []byte(e2e.RandBytes(10000)) _, err = daClient.GetData(ts.Ctx, testCert) require.Error(t, err) - assert.True(t, strings.Contains(err.Error(), - "failed to decode DA cert to RLP format: rlp: expected input list for verify.Certificate") && - !isNilPtrDerefPanic(err.Error())) + assert.True(t, strings.Contains(err.Error(), "400") && !isNilPtrDerefPanic(err.Error())) }) } func TestProxyClient(t *testing.T) { - if !runIntegrationTests && !runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - } + //if !runIntegrationTests && !runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} t.Parallel() - tsConfig := e2e.TestSuiteConfig(t, e2e.TestConfig(useMemory())) - ts, kill := e2e.CreateTestSuite(t, tsConfig) + tsConfig := e2e.TestSuiteConfig(e2e.TestConfig(useMemory())) + ts, kill := e2e.CreateTestSuite(tsConfig) defer kill() cfg := &client.Config{ @@ -187,7 +136,7 @@ func TestProxyClient(t *testing.T) { } daClient := client.New(cfg) - testPreimage := []byte(e2e.RandString(100)) + testPreimage := []byte(e2e.RandBytes(100)) t.Log("Setting input data on proxy server...") blobInfo, err := daClient.SetData(ts.Ctx, testPreimage) @@ -200,9 +149,9 @@ func TestProxyClient(t *testing.T) { } func TestProxyClientWriteRead(t *testing.T) { - if !runIntegrationTests && !runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - } + //if !runIntegrationTests && !runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} t.Parallel() @@ -215,9 +164,9 @@ func TestProxyClientWriteRead(t *testing.T) { } func TestProxyWithMaximumSizedBlob(t *testing.T) { - if !runIntegrationTests && !runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - } + //if !runIntegrationTests && !runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} t.Parallel() @@ -233,9 +182,9 @@ func TestProxyWithMaximumSizedBlob(t *testing.T) { Ensure that proxy is able to write/read from a cache backend when enabled */ func TestProxyCaching(t *testing.T) { - if !runIntegrationTests && !runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - } + //if !runIntegrationTests && !runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} t.Parallel() @@ -252,9 +201,9 @@ func TestProxyCaching(t *testing.T) { } func TestProxyCachingWithRedis(t *testing.T) { - if !runIntegrationTests && !runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - } + //if !runIntegrationTests && !runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + //} t.Parallel() @@ -278,9 +227,9 @@ func TestProxyCachingWithRedis(t *testing.T) { func TestProxyReadFallback(t *testing.T) { // test can't be ran against holesky since read failure case can't be manually triggered - if !runIntegrationTests || runTestnetIntegrationTests { - t.Skip("Skipping test as INTEGRATION env var not set") - } + //if !runIntegrationTests || runTestnetIntegrationTests { + // t.Skip("Skipping test as INTEGRATION env var not set") + //} t.Parallel() diff --git a/e2e/setup.go b/e2e/setup.go index 19007bd1..f09fe9af 100644 --- a/e2e/setup.go +++ b/e2e/setup.go @@ -23,8 +23,6 @@ import ( "github.com/minio/minio-go/v7/pkg/credentials" "golang.org/x/exp/rand" - "github.com/stretchr/testify/require" - oplog "github.com/ethereum-optimism/optimism/op-service/log" opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics" @@ -160,7 +158,6 @@ func createS3Config(eigendaCfg server.Config) server.CLIConfig { } } - func TestSuiteConfig(testCfg *Cfg) server.CLIConfig { // load signer key from environment @@ -261,7 +258,6 @@ type TestSuite struct { Metrics *metrics.EmulatedMetricer } - func CreateTestSuite(testSuiteCfg server.CLIConfig) (TestSuite, func()) { log := oplog.NewLogger(os.Stdout, oplog.CLIConfig{ Level: log.LevelDebug, From 5e72950ae64e9d608c7c66d88dd7676eb05358c5 Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Dec 2024 12:23:00 +0530 Subject: [PATCH 26/31] fixing makefile for fuzz tests --- Makefile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index bd0d06bd..c6f1e089 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ LDFLAGSSTRING +=-X main.Date=$(BUILD_TIME) LDFLAGSSTRING +=-X main.Version=$(GIT_TAG) LDFLAGS := -ldflags "$(LDFLAGSSTRING)" -E2EFUZZTEST = FUZZ=true go test ./e2e -fuzz -deploy-config ../.devnet/devnetL1.json -v -fuzztime=30m +E2EFUZZTEST = FUZZ=true go test ./e2e -fuzz -v -fuzztime=30m .PHONY: eigenda-proxy eigenda-proxy: @@ -37,10 +37,8 @@ test: e2e-test: INTEGRATION=true go test -timeout 1m ./e2e -parallel 4 -e2e-fuzz-test: stop-minio stop-redis run-minio run-redis - $(E2EFUZZTEST) && \ - make stop-minio && \ - make stop-redis +e2e-fuzz-test: + $(E2EFUZZTEST) holesky-test: TESTNET=true go test -timeout 50m ./e2e -parallel 4 From acf83a4d6dfa49cf4ffe7809943f7d8ef40a43ee Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Dec 2024 13:51:40 +0530 Subject: [PATCH 27/31] lint and fix fuzz test fix --- e2e/main_test.go | 2 +- e2e/server_fuzz_test.go | 72 +++++++++++++++++++---------------------- e2e/server_test.go | 53 ++++++++++++++++-------------- e2e/setup.go | 1 - 4 files changed, 63 insertions(+), 65 deletions(-) diff --git a/e2e/main_test.go b/e2e/main_test.go index 842e8b53..afe8350d 100644 --- a/e2e/main_test.go +++ b/e2e/main_test.go @@ -24,7 +24,7 @@ import ( var ( runTestnetIntegrationTests bool // holesky tests runIntegrationTests bool // memstore tests - runFuzzTests bool + runFuzzTests bool ) // ParseEnv ... reads testing cfg fields. Go test flags don't work for this library due to the dependency on Optimism's E2E framework diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index 84a82ed0..b7b36f98 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -1,51 +1,45 @@ package e2e_test import ( - "fmt" + "github.com/stretchr/testify/assert" + + "github.com/Layr-Labs/eigenda-proxy/client" + "github.com/Layr-Labs/eigenda-proxy/e2e" "testing" "unicode" ) -func addAllUnicodeTestCases(f *testing.F) { +// FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs will fuzz the proxy client server integration +// and op client keccak256 with malformed inputs. This is never meant to be fuzzed with EigenDA. +func FuzzProxyClientServerIntegration(f *testing.F) { + if !runFuzzTests { + f.Skip("Skipping test as FUZZ env var not set") + } + + tsConfig := e2e.TestSuiteConfig(e2e.TestConfig(useMemory())) + ts, kill := e2e.CreateTestSuite(tsConfig) + for r := rune(0); r <= unicode.MaxRune; r++ { if unicode.IsPrint(r) { - f.Add(fmt.Sprintf("seed: %s", string(r)), []byte(string(r))) // Add each printable Unicode character as a seed + f.Add([]byte(string(r))) // Add each printable Unicode character as a seed } } -} -// FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs will fuzz the proxy client server integration -// and op client keccak256 with malformed inputs. This is never meant to be fuzzed with EigenDA. -//func FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs(f *testing.F) { -// if !runFuzzTests { -// f.Skip("Skipping test as FUZZ env var not set") -// } -// -// testCfg := e2e.TestConfig(true) -// testCfg.UseKeccak256ModeS3 = true -// tsConfig := e2e.TestSuiteConfig(testCfg) -// ts, kill := e2e.CreateTestSuite(tsConfig) -// defer kill() -// -// // Add each printable Unicode character as a seed -// addAllUnicodeTestCases(f) -// -// cfg := &client.Config{ -// URL: ts.Address(), -// } -// daClient := client.New(cfg) -// daClientPcFalse := op_plasma.NewDAClient(ts.Address(), false, false) -// -// // seed and data are expected. `seed` value is seed: {rune} and data is the one with the random byte(s) -// f.Fuzz(func(t *testing.T, _ string, data []byte) { -// -// _, err := daClient.SetData(ts.Ctx, data) -// require.NoError(t, err) -// -// _, err = daClientPcFalse.SetInput(ts.Ctx, data) -// // should fail with proper error message as is now, and cannot contain panics or nils -// if err != nil { -// assert.True(t, !isNilPtrDerefPanic(err.Error())) -// } -// }) -//} + cfg := &client.Config{ + URL: ts.Address(), + } + + daClient := client.New(cfg) + + // seed and data are expected. `seed` value is seed: {rune} and data is the one with the random byte(s) + f.Fuzz(func(t *testing.T, data []byte) { + _, err := daClient.SetData(ts.Ctx, data) + assert.NoError(t, err) + if err != nil { + t.Errorf("Failed to set data: %v", err) + } + }) + + f.Cleanup(kill) + +} diff --git a/e2e/server_test.go b/e2e/server_test.go index 3a15b4f9..bb12daed 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -1,15 +1,16 @@ 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/common" "github.com/Layr-Labs/eigenda-proxy/e2e" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "strings" - "testing" - "time" ) func useMemory() bool { @@ -39,9 +40,9 @@ with a concurrent S3 backend configured */ func TestOptimismClientWithGenericCommitment(t *testing.T) { - //if !runIntegrationTests && !runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } t.Parallel() @@ -57,15 +58,15 @@ func TestOptimismClientWithGenericCommitment(t *testing.T) { // many unicode characters, single unicode character and an empty preimage. It then tries to get the data from the // proxy server with empty byte, single byte and random string. func TestProxyClientServerIntegration(t *testing.T) { - //if !runIntegrationTests && !runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } t.Parallel() tsConfig := e2e.TestSuiteConfig(e2e.TestConfig(useMemory())) ts, kill := e2e.CreateTestSuite(tsConfig) - defer kill() + t.Cleanup(kill) cfg := &client.Config{ URL: ts.Address(), @@ -73,6 +74,7 @@ func TestProxyClientServerIntegration(t *testing.T) { daClient := client.New(cfg) t.Run("single byte preimage set data case", func(t *testing.T) { + t.Parallel() testPreimage := []byte{1} // single byte preimage t.Log("Setting input data on proxy server...") _, err := daClient.SetData(ts.Ctx, testPreimage) @@ -80,6 +82,7 @@ func TestProxyClientServerIntegration(t *testing.T) { }) t.Run("unicode preimage set data case", func(t *testing.T) { + t.Parallel() testPreimage := []byte("§§©ˆªªˆ˙√ç®∂§∞¶§ƒ¥√¨¥√¨¥ƒƒ©˙˜ø˜˜˜∫˙∫¥∫√†®®√稈¨˙ï") // many unicode characters t.Log("Setting input data on proxy server...") _, err := daClient.SetData(ts.Ctx, testPreimage) @@ -93,6 +96,7 @@ func TestProxyClientServerIntegration(t *testing.T) { }) t.Run("empty preimage set data case", func(t *testing.T) { + t.Parallel() testPreimage := []byte("") // Empty preimage t.Log("Setting input data on proxy server...") _, err := daClient.SetData(ts.Ctx, testPreimage) @@ -100,6 +104,7 @@ func TestProxyClientServerIntegration(t *testing.T) { }) t.Run("get data edge cases", func(t *testing.T) { + t.Parallel() testCert := []byte("") _, err := daClient.GetData(ts.Ctx, testCert) require.Error(t, err) @@ -112,7 +117,7 @@ func TestProxyClientServerIntegration(t *testing.T) { assert.True(t, strings.Contains(err.Error(), "400") && !isNilPtrDerefPanic(err.Error())) - testCert = []byte(e2e.RandBytes(10000)) + testCert = e2e.RandBytes(10000) _, err = daClient.GetData(ts.Ctx, testCert) require.Error(t, err) assert.True(t, strings.Contains(err.Error(), "400") && !isNilPtrDerefPanic(err.Error())) @@ -121,9 +126,9 @@ func TestProxyClientServerIntegration(t *testing.T) { } func TestProxyClient(t *testing.T) { - //if !runIntegrationTests && !runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } t.Parallel() @@ -136,7 +141,7 @@ func TestProxyClient(t *testing.T) { } daClient := client.New(cfg) - testPreimage := []byte(e2e.RandBytes(100)) + testPreimage := e2e.RandBytes(100) t.Log("Setting input data on proxy server...") blobInfo, err := daClient.SetData(ts.Ctx, testPreimage) @@ -149,9 +154,9 @@ func TestProxyClient(t *testing.T) { } func TestProxyClientWriteRead(t *testing.T) { - //if !runIntegrationTests && !runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } t.Parallel() @@ -164,9 +169,9 @@ func TestProxyClientWriteRead(t *testing.T) { } func TestProxyWithMaximumSizedBlob(t *testing.T) { - //if !runIntegrationTests && !runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } t.Parallel() @@ -182,7 +187,7 @@ func TestProxyWithMaximumSizedBlob(t *testing.T) { Ensure that proxy is able to write/read from a cache backend when enabled */ func TestProxyCaching(t *testing.T) { - //if !runIntegrationTests && !runTestnetIntegrationTests { + // if !runIntegrationTests && !runTestnetIntegrationTests { // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") //} @@ -201,7 +206,7 @@ func TestProxyCaching(t *testing.T) { } func TestProxyCachingWithRedis(t *testing.T) { - //if !runIntegrationTests && !runTestnetIntegrationTests { + // if !runIntegrationTests && !runTestnetIntegrationTests { // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") //} @@ -227,7 +232,7 @@ func TestProxyCachingWithRedis(t *testing.T) { func TestProxyReadFallback(t *testing.T) { // test can't be ran against holesky since read failure case can't be manually triggered - //if !runIntegrationTests || runTestnetIntegrationTests { + // if !runIntegrationTests || runTestnetIntegrationTests { // t.Skip("Skipping test as INTEGRATION env var not set") //} diff --git a/e2e/setup.go b/e2e/setup.go index f09fe9af..7ddd5041 100644 --- a/e2e/setup.go +++ b/e2e/setup.go @@ -159,7 +159,6 @@ func createS3Config(eigendaCfg server.Config) server.CLIConfig { } func TestSuiteConfig(testCfg *Cfg) server.CLIConfig { - // load signer key from environment pk := os.Getenv(privateKey) if pk == "" && !testCfg.UseMemory { From 088b90730041562a55b879cea09ac5d7acb5b44d Mon Sep 17 00:00:00 2001 From: anupsv Date: Thu, 19 Dec 2024 13:58:30 +0530 Subject: [PATCH 28/31] more linter bs --- e2e/server_fuzz_test.go | 5 +++-- e2e/server_test.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index b7b36f98..6eee2128 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -3,10 +3,11 @@ package e2e_test import ( "github.com/stretchr/testify/assert" - "github.com/Layr-Labs/eigenda-proxy/client" - "github.com/Layr-Labs/eigenda-proxy/e2e" "testing" "unicode" + + "github.com/Layr-Labs/eigenda-proxy/client" + "github.com/Layr-Labs/eigenda-proxy/e2e" ) // FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs will fuzz the proxy client server integration diff --git a/e2e/server_test.go b/e2e/server_test.go index bb12daed..dfb155a3 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -58,12 +58,12 @@ func TestOptimismClientWithGenericCommitment(t *testing.T) { // many unicode characters, single unicode character and an empty preimage. It then tries to get the data from the // proxy server with empty byte, single byte and random string. func TestProxyClientServerIntegration(t *testing.T) { + t.Parallel() + if !runIntegrationTests && !runTestnetIntegrationTests { t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") } - t.Parallel() - tsConfig := e2e.TestSuiteConfig(e2e.TestConfig(useMemory())) ts, kill := e2e.CreateTestSuite(tsConfig) t.Cleanup(kill) From d98cfc90f8fbda28bd67090fa0063f522f5b0e4f Mon Sep 17 00:00:00 2001 From: anupsv Date: Fri, 20 Dec 2024 00:07:32 +0530 Subject: [PATCH 29/31] removing fuzz flags since context of failure isn't maintained --- Makefile | 2 +- e2e/main_test.go | 2 -- e2e/server_fuzz_test.go | 3 --- e2e/server_test.go | 6 +++--- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index c6f1e089..d50874f7 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ LDFLAGSSTRING +=-X main.Date=$(BUILD_TIME) LDFLAGSSTRING +=-X main.Version=$(GIT_TAG) LDFLAGS := -ldflags "$(LDFLAGSSTRING)" -E2EFUZZTEST = FUZZ=true go test ./e2e -fuzz -v -fuzztime=30m +E2EFUZZTEST = go test ./e2e -fuzz -v -fuzztime=30m .PHONY: eigenda-proxy eigenda-proxy: diff --git a/e2e/main_test.go b/e2e/main_test.go index afe8350d..78896658 100644 --- a/e2e/main_test.go +++ b/e2e/main_test.go @@ -24,13 +24,11 @@ import ( var ( runTestnetIntegrationTests bool // holesky tests runIntegrationTests bool // memstore tests - runFuzzTests bool ) // ParseEnv ... reads testing cfg fields. Go test flags don't work for this library due to the dependency on Optimism's E2E framework // which initializes test flags per init function which is called before an init in this package. func ParseEnv() { - runFuzzTests = os.Getenv("FUZZ") == "true" || os.Getenv("FUZZ") == "1" if runIntegrationTests && runTestnetIntegrationTests { panic("only one of INTEGRATION=true or TESTNET=true env var can be set") } diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index 6eee2128..d572e123 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -13,9 +13,6 @@ import ( // FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs will fuzz the proxy client server integration // and op client keccak256 with malformed inputs. This is never meant to be fuzzed with EigenDA. func FuzzProxyClientServerIntegration(f *testing.F) { - if !runFuzzTests { - f.Skip("Skipping test as FUZZ env var not set") - } tsConfig := e2e.TestSuiteConfig(e2e.TestConfig(useMemory())) ts, kill := e2e.CreateTestSuite(tsConfig) diff --git a/e2e/server_test.go b/e2e/server_test.go index dfb155a3..e6c10d0f 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -187,9 +187,9 @@ func TestProxyWithMaximumSizedBlob(t *testing.T) { Ensure that proxy is able to write/read from a cache backend when enabled */ func TestProxyCaching(t *testing.T) { - // if !runIntegrationTests && !runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } t.Parallel() From 226ecac2268e8a949a3e3c4f2281d8d5e77d79c4 Mon Sep 17 00:00:00 2001 From: anupsv Date: Fri, 20 Dec 2024 01:57:41 +0530 Subject: [PATCH 30/31] uncommenting the if conditions --- e2e/server_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/server_test.go b/e2e/server_test.go index e6c10d0f..10ccf135 100644 --- a/e2e/server_test.go +++ b/e2e/server_test.go @@ -206,9 +206,9 @@ func TestProxyCaching(t *testing.T) { } func TestProxyCachingWithRedis(t *testing.T) { - // if !runIntegrationTests && !runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") - //} + if !runIntegrationTests && !runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION or TESTNET env var not set") + } t.Parallel() @@ -232,9 +232,9 @@ func TestProxyCachingWithRedis(t *testing.T) { func TestProxyReadFallback(t *testing.T) { // test can't be ran against holesky since read failure case can't be manually triggered - // if !runIntegrationTests || runTestnetIntegrationTests { - // t.Skip("Skipping test as INTEGRATION env var not set") - //} + if !runIntegrationTests || runTestnetIntegrationTests { + t.Skip("Skipping test as INTEGRATION env var not set") + } t.Parallel() From d90e9a0d9c5af9a5cbc920f6575e82156f49f1d4 Mon Sep 17 00:00:00 2001 From: anupsv Date: Fri, 20 Dec 2024 02:18:46 +0530 Subject: [PATCH 31/31] adding back fuzz test boolean --- Makefile | 2 +- e2e/main_test.go | 2 ++ e2e/server_fuzz_test.go | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d50874f7..33f5d364 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ LDFLAGSSTRING +=-X main.Date=$(BUILD_TIME) LDFLAGSSTRING +=-X main.Version=$(GIT_TAG) LDFLAGS := -ldflags "$(LDFLAGSSTRING)" -E2EFUZZTEST = go test ./e2e -fuzz -v -fuzztime=30m +E2EFUZZTEST = FUZZ=true go test ./e2e -fuzz -v -fuzztime=15m .PHONY: eigenda-proxy eigenda-proxy: diff --git a/e2e/main_test.go b/e2e/main_test.go index 78896658..c0b397e8 100644 --- a/e2e/main_test.go +++ b/e2e/main_test.go @@ -24,11 +24,13 @@ import ( var ( runTestnetIntegrationTests bool // holesky tests runIntegrationTests bool // memstore tests + runFuzzTests bool // fuzz tests ) // ParseEnv ... reads testing cfg fields. Go test flags don't work for this library due to the dependency on Optimism's E2E framework // which initializes test flags per init function which is called before an init in this package. func ParseEnv() { + runFuzzTests = os.Getenv("FUZZ") == "true" || os.Getenv("FUZZ") == "1" if runIntegrationTests && runTestnetIntegrationTests { panic("only one of INTEGRATION=true or TESTNET=true env var can be set") } diff --git a/e2e/server_fuzz_test.go b/e2e/server_fuzz_test.go index d572e123..6eee2128 100644 --- a/e2e/server_fuzz_test.go +++ b/e2e/server_fuzz_test.go @@ -13,6 +13,9 @@ import ( // FuzzProxyClientServerIntegrationAndOpClientKeccak256MalformedInputs will fuzz the proxy client server integration // and op client keccak256 with malformed inputs. This is never meant to be fuzzed with EigenDA. func FuzzProxyClientServerIntegration(f *testing.F) { + if !runFuzzTests { + f.Skip("Skipping test as FUZZ env var not set") + } tsConfig := e2e.TestSuiteConfig(e2e.TestConfig(useMemory())) ts, kill := e2e.CreateTestSuite(tsConfig)