Skip to content

Commit

Permalink
upgrade logger to remove noop
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Dec 12, 2024
1 parent 2008bd7 commit c571978
Show file tree
Hide file tree
Showing 39 changed files with 110 additions and 96 deletions.
5 changes: 3 additions & 2 deletions api/clients/retrieval_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package clients_test
import (
"bytes"
"context"

"runtime"
"testing"

"github.com/Layr-Labs/eigenda/api/clients"
clientsmock "github.com/Layr-Labs/eigenda/api/clients/mock"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
coreindexer "github.com/Layr-Labs/eigenda/core/indexer"
coremock "github.com/Layr-Labs/eigenda/core/mock"
Expand All @@ -17,7 +19,6 @@ import (
"github.com/Layr-Labs/eigenda/encoding/kzg/verifier"
"github.com/Layr-Labs/eigenda/encoding/utils/codec"
indexermock "github.com/Layr-Labs/eigenda/indexer/mock"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/consensys/gnark-crypto/ecc/bn254"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -96,7 +97,7 @@ func setup(t *testing.T) {
if err != nil {
t.Fatal(err)
}
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()
indexer = &indexermock.MockIndexer{}
indexer.On("Index").Return(nil).Once()

Expand Down
5 changes: 3 additions & 2 deletions common/geth/multihoming_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package geth_test
import (
"context"
"fmt"

"math/big"
"testing"

"github.com/Layr-Labs/eigenda/common/geth"
damock "github.com/Layr-Labs/eigenda/common/mock"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand All @@ -25,7 +26,7 @@ func (j *JsonError) Error() string { return "json error" }
func (j *JsonError) ErrorCode() int { return -32000 }

func makeTestMultihomingClient(numRetries int, designatedError error) (*geth.MultiHomingClient, error) {
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()

ethClientCfg := geth.EthClientConfig{
RPCURLs: rpcURLs,
Expand Down
4 changes: 2 additions & 2 deletions common/ratelimit/ratelimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/common/ratelimit"
"github.com/Layr-Labs/eigenda/common/store"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/assert"
)
Expand All @@ -26,7 +26,7 @@ func makeTestRatelimiter() (common.RateLimiter, error) {
return nil, err
}

ratelimiter := ratelimit.NewRateLimiter(prometheus.NewRegistry(), globalParams, bucketStore, logging.NewNoopLogger())
ratelimiter := ratelimit.NewRateLimiter(prometheus.NewRegistry(), globalParams, bucketStore, testutils.GetLogger())

return ratelimiter, nil

Expand Down
5 changes: 3 additions & 2 deletions common/store/dynamo_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package store_test
import (
"context"
"fmt"

"os"
"testing"
"time"
Expand All @@ -12,14 +13,14 @@ import (
"github.com/Layr-Labs/eigenda/common/aws/dynamodb"
test_utils "github.com/Layr-Labs/eigenda/common/aws/dynamodb/utils"
"github.com/Layr-Labs/eigenda/common/store"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/inabox/deploy"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/ory/dockertest/v3"
"github.com/stretchr/testify/assert"
)

var (
logger = logging.NewNoopLogger()
logger = testutils.GetLogger()

dockertestPool *dockertest.Pool
dockertestResource *dockertest.Resource
Expand Down
6 changes: 6 additions & 0 deletions common/testutils/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package testutils
import (
"context"
"fmt"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/stretchr/testify/assert"
"golang.org/x/exp/rand"
"os"
"testing"
"time"
)
Expand Down Expand Up @@ -108,3 +110,7 @@ func RandomString(length int) string {
}
return string(b)
}

func GetLogger() logging.Logger {
return logging.NewTextSLogger(os.Stdout, &logging.SLoggerOptions{})
}
4 changes: 2 additions & 2 deletions core/aggregation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"os"
"testing"

"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/mock"
"github.com/Layr-Labs/eigensdk-go/logging"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
)
Expand All @@ -30,7 +30,7 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}
logger := logging.NewTextSLogger(os.Stdout, &logging.SLoggerOptions{})
logger := testutils.GetLogger()
transactor := &mock.MockWriter{}
transactor.On("OperatorIDToAddress").Return(gethcommon.Address{}, nil)
agg, err = core.NewStdSignatureAggregator(logger, transactor)
Expand Down
3 changes: 2 additions & 1 deletion core/indexer/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/common/geth"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/eth"
indexedstate "github.com/Layr-Labs/eigenda/core/indexer"
Expand Down Expand Up @@ -154,7 +155,7 @@ var _ = Describe("Indexer", func() {
Skip("No test path provided")
}

logger := logging.NewNoopLogger()
logger := testutils.GetLogger()
ctx, cancel := context.WithCancel(context.Background())
_ = cancel

Expand Down
5 changes: 2 additions & 3 deletions core/meterer/meterer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/Layr-Labs/eigenda/common"
commonaws "github.com/Layr-Labs/eigenda/common/aws"
commondynamodb "github.com/Layr-Labs/eigenda/common/aws/dynamodb"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/meterer"
"github.com/Layr-Labs/eigenda/core/mock"
Expand All @@ -22,8 +23,6 @@ import (
"github.com/ory/dockertest/v3"
"github.com/stretchr/testify/assert"
testifymock "github.com/stretchr/testify/mock"

"github.com/Layr-Labs/eigensdk-go/logging"
)

var (
Expand Down Expand Up @@ -101,7 +100,7 @@ func setup(_ *testing.M) {
panic("failed to generate private key")
}

logger = logging.NewNoopLogger()
logger = testutils.GetLogger()
config := meterer.Config{
ChainReadTimeout: 3 * time.Second,
UpdateInterval: 1 * time.Second,
Expand Down
3 changes: 2 additions & 1 deletion core/thegraph/state_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/common/geth"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core/eth"
"github.com/Layr-Labs/eigenda/core/thegraph"
"github.com/Layr-Labs/eigenda/inabox/deploy"
Expand Down Expand Up @@ -81,7 +82,7 @@ func TestIndexerIntegration(t *testing.T) {
setup()
defer teardown()

logger := logging.NewNoopLogger()
logger := testutils.GetLogger()
client := mustMakeTestClient(t, testConfig, testConfig.Batcher[0].BATCHER_PRIVATE_KEY, logger)
tx, err := eth.NewWriter(logger, client, testConfig.EigenDA.OperatorStateRetreiver, testConfig.EigenDA.ServiceManager)
assert.NoError(t, err)
Expand Down
10 changes: 5 additions & 5 deletions core/thegraph/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"context"
"testing"

"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/mock"
"github.com/Layr-Labs/eigenda/core/thegraph"
"github.com/Layr-Labs/eigensdk-go/logging"
ethcomm "github.com/ethereum/go-ethereum/common"
"github.com/shurcooL/graphql"
"github.com/stretchr/testify/assert"
Expand All @@ -26,7 +26,7 @@ func (m mockGraphQLQuerier) Query(ctx context.Context, q any, variables map[stri
}

func TestIndexedChainState_GetIndexedOperatorState(t *testing.T) {
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()

chainState, _ := mock.MakeChainDataMock(map[uint8]int{
0: 1,
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestIndexedChainState_GetIndexedOperatorState(t *testing.T) {
}

func TestIndexedChainState_GetIndexedOperatorStateMissingOperator(t *testing.T) {
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()

chainState, _ := mock.MakeChainDataMock(map[uint8]int{
0: 2,
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestIndexedChainState_GetIndexedOperatorStateMissingOperator(t *testing.T)
}

func TestIndexedChainState_GetIndexedOperatorStateExtraOperator(t *testing.T) {
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()

chainState, _ := mock.MakeChainDataMock(map[uint8]int{
0: 1,
Expand Down Expand Up @@ -243,7 +243,7 @@ func TestIndexedChainState_GetIndexedOperatorStateExtraOperator(t *testing.T) {
}

func TestIndexedChainState_GetIndexedOperatorInfoByOperatorId(t *testing.T) {
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()

chainState, _ := mock.MakeChainDataMock(map[uint8]int{
0: 1,
Expand Down
6 changes: 3 additions & 3 deletions core/v2/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/core/mock"
corev2 "github.com/Layr-Labs/eigenda/core/v2"
Expand All @@ -18,7 +19,6 @@ import (
"github.com/Layr-Labs/eigenda/encoding/kzg/prover"
"github.com/Layr-Labs/eigenda/encoding/kzg/verifier"
"github.com/Layr-Labs/eigenda/encoding/utils/codec"
"github.com/Layr-Labs/eigensdk-go/logging"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/gammazero/workerpool"
"github.com/hashicorp/go-multierror"
Expand Down Expand Up @@ -53,7 +53,7 @@ func TestMain(m *testing.M) {
if err != nil {
panic(err)
}
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()
reader := &mock.MockWriter{}
reader.On("OperatorIDToAddress").Return(gethcommon.Address{}, nil)
agg, err = core.NewStdSignatureAggregator(logger, reader)
Expand Down Expand Up @@ -227,7 +227,7 @@ func checkBatchByUniversalVerifier(

for id := range state.IndexedOperators {

val := corev2.NewShardValidator(v, id, logging.NewNoopLogger())
val := corev2.NewShardValidator(v, id, testutils.GetLogger())

blobs := packagedBlobs[id]

Expand Down
5 changes: 3 additions & 2 deletions disperser/apiserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/rand"
"flag"
"fmt"

"math"
"math/big"
"net"
Expand All @@ -22,7 +23,6 @@ import (
"github.com/Layr-Labs/eigenda/encoding/kzg"
p "github.com/Layr-Labs/eigenda/encoding/kzg/prover"
"github.com/Layr-Labs/eigenda/encoding/utils/codec"
"github.com/Layr-Labs/eigensdk-go/logging"
gethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/google/uuid"
Expand All @@ -37,6 +37,7 @@ import (
"github.com/Layr-Labs/eigenda/common/aws/s3"
"github.com/Layr-Labs/eigenda/common/ratelimit"
"github.com/Layr-Labs/eigenda/common/store"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
"github.com/Layr-Labs/eigenda/disperser"
"github.com/Layr-Labs/eigenda/inabox/deploy"
Expand Down Expand Up @@ -718,7 +719,7 @@ func teardown() {
}

func newTestServer(transactor core.Writer, testName string) *apiserver.DispersalServer {
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()

awsConfig := aws.ClientConfig{
Region: "us-east-1",
Expand Down
4 changes: 2 additions & 2 deletions disperser/apiserver/server_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/Layr-Labs/eigenda/common/aws"
"github.com/Layr-Labs/eigenda/common/aws/dynamodb"
"github.com/Layr-Labs/eigenda/common/aws/s3"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
auth "github.com/Layr-Labs/eigenda/core/auth/v2"
"github.com/Layr-Labs/eigenda/core/meterer"
Expand All @@ -24,7 +25,6 @@ import (
"github.com/Layr-Labs/eigenda/disperser/common/v2/blobstore"
"github.com/Layr-Labs/eigenda/encoding"
"github.com/Layr-Labs/eigenda/encoding/utils/codec"
"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/consensys/gnark-crypto/ecc/bn254"
"google.golang.org/grpc/peer"

Expand Down Expand Up @@ -412,7 +412,7 @@ func TestV2GetBlobCommitment(t *testing.T) {
}

func newTestServerV2(t *testing.T) *testComponents {
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()
// logger, err := common.NewLogger(common.DefaultLoggerConfig())
// if err != nil {
// panic("failed to create logger")
Expand Down
6 changes: 3 additions & 3 deletions disperser/batcher/batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"context"
"encoding/hex"
"errors"

"math/big"
"runtime"
"sync"
"testing"
"time"

"github.com/Layr-Labs/eigenda/common"
"github.com/Layr-Labs/eigensdk-go/logging"

cmock "github.com/Layr-Labs/eigenda/common/mock"
"github.com/Layr-Labs/eigenda/common/testutils"
"github.com/Layr-Labs/eigenda/core"
coremock "github.com/Layr-Labs/eigenda/core/mock"
"github.com/Layr-Labs/eigenda/disperser"
Expand Down Expand Up @@ -78,7 +78,7 @@ func makeBatcher(t *testing.T) (*batcherComponents, *bat.Batcher, func() []time.
// Common Components
// logger, err := common.NewLogger(common.DefaultLoggerConfig())
// assert.NoError(t, err)
logger := logging.NewNoopLogger()
logger := testutils.GetLogger()

finalizationBlockDelay := uint(75)

Expand Down
Loading

0 comments on commit c571978

Please sign in to comment.