Skip to content

Commit

Permalink
add timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Mar 16, 2024
1 parent baf9e15 commit b08c404
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions common/geth/multihoming_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"math/big"
"testing"
"time"

"github.com/Layr-Labs/eigenda/common/geth"
damock "github.com/Layr-Labs/eigenda/common/mock"
Expand All @@ -18,14 +19,15 @@ var (
rpcURLs = []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"}
)

func makeTestMultihomingClient(t *testing.T, numRetries int) (*geth.MultiHomingClient, error) {
func makeTestMultihomingClient(numRetries int) (*geth.MultiHomingClient, error) {
logger := logging.NewNoopLogger()

ethClientCfg := geth.EthClientConfig{
RPCURLs: rpcURLs,
PrivateKeyString: privateKey,
NumConfirmations: 0,
NumRetries: numRetries,
NetworkTimeout: time.Second,
}

mockClient := geth.MultiHomingClient{}
Expand Down Expand Up @@ -54,7 +56,7 @@ func makeFailureCall(t *testing.T, client *geth.MultiHomingClient, numCall int)
}

func TestMultihomingClientZeroRetry(t *testing.T) {
client, _ := makeTestMultihomingClient(t, 0)
client, _ := makeTestMultihomingClient(0)

index, _ := client.GetRPCInstance()
require.Equal(t, index, 0)
Expand All @@ -77,7 +79,7 @@ func TestMultihomingClientZeroRetry(t *testing.T) {
}

func TestMultihomingClientOneRetry(t *testing.T) {
client, _ := makeTestMultihomingClient(t, 1)
client, _ := makeTestMultihomingClient(1)

index, _ := client.GetRPCInstance()
require.Equal(t, index, 0)
Expand All @@ -100,7 +102,7 @@ func TestMultihomingClientOneRetry(t *testing.T) {
}

func TestMultihomingClientTwoRetry(t *testing.T) {
client, _ := makeTestMultihomingClient(t, 2)
client, _ := makeTestMultihomingClient(2)

index, _ := client.GetRPCInstance()
require.Equal(t, index, 0)
Expand Down
6 changes: 6 additions & 0 deletions inabox/tests/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ var (
mockRollup *rollupbindings.ContractMockRollup
retrievalClient clients.RetrievalClient
numConfirmations int = 3
networkTimeout = 3 * time.Second
numRetries = 0

cancel context.CancelFunc
)
Expand Down Expand Up @@ -122,6 +124,8 @@ var _ = BeforeSuite(func() {
RPCURLs: []string{testConfig.Deployers[0].RPC},
PrivateKeyString: pk,
NumConfirmations: numConfirmations,
NetworkTimeout: networkTimeout,
NumRetries: numRetries,
}, logger)
Expect(err).To(BeNil())
rpcClient, err = ethrpc.Dial(testConfig.Deployers[0].RPC)
Expand All @@ -137,6 +141,8 @@ func setupRetrievalClient(testConfig *deploy.Config) error {
RPCURLs: []string{testConfig.Deployers[0].RPC},
PrivateKeyString: "351b8eca372e64f64d514f90f223c5c4f86a04ff3dcead5c27293c547daab4ca", // just random private key
NumConfirmations: numConfirmations,
NetworkTimeout: networkTimeout,
NumRetries: numRetries,
}
client, err := geth.NewMultiHomingClient(ethClientConfig, logger)
if err != nil {
Expand Down

0 comments on commit b08c404

Please sign in to comment.