diff --git a/pkg/eth/api_test.go b/pkg/eth/api_test.go index f434d83f..b972c0d1 100644 --- a/pkg/eth/api_test.go +++ b/pkg/eth/api_test.go @@ -32,7 +32,6 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql" "github.com/ethereum/go-ethereum/statediff/indexer/interfaces" - "github.com/ethereum/go-ethereum/statediff/indexer/node" sdtypes "github.com/ethereum/go-ethereum/statediff/types" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -196,14 +195,7 @@ var _ = Describe("API", func() { tx interfaces.Batch ) - testInfo := node.Info{ - GenesisBlock: test_helpers.Genesis.Hash().String(), - NetworkID: "1", - ID: "1", - ClientName: "geth", - ChainID: params.TestChainConfig.ChainID.Uint64(), - } - db, err = eth.Setup(ctx, testInfo) + db, err = eth.SetupDB(ctx, test_helpers.Genesis.Hash()) Expect(err).ToNot(HaveOccurred()) indexAndPublisher, err := sql.NewStateDiffIndexer(ctx, chainConfig, db) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/eth/cid_retriever_test.go b/pkg/eth/cid_retriever_test.go index fea6def4..dd6b025e 100644 --- a/pkg/eth/cid_retriever_test.go +++ b/pkg/eth/cid_retriever_test.go @@ -23,7 +23,6 @@ import ( "github.com/ethereum/go-ethereum/statediff/indexer/database/sql" "github.com/ethereum/go-ethereum/statediff/indexer/interfaces" "github.com/ethereum/go-ethereum/statediff/indexer/models" - "github.com/ethereum/go-ethereum/statediff/indexer/node" "github.com/ethereum/go-ethereum/trie" "github.com/ethereum/go-ethereum/common" @@ -218,17 +217,9 @@ var _ = Describe("Retriever", func() { ) BeforeEach(func() { var err error - testInfo := node.Info{ - GenesisBlock: test_helpers.Genesis.Hash().String(), - NetworkID: "2", - ID: "2", - ClientName: "geth", - ChainID: params.TestChainConfig.ChainID.Uint64(), - } - db, err = eth.Setup(ctx, testInfo) + db, err = eth.SetupDB(ctx, test_helpers.Genesis.Hash()) Expect(err).ToNot(HaveOccurred()) diffIndexer, err = sql.NewStateDiffIndexer(ctx, params.TestChainConfig, db) - Expect(err).ToNot(HaveOccurred()) retriever = eth.NewCIDRetriever(db) diff --git a/pkg/eth/eth_state_test.go b/pkg/eth/eth_state_test.go index a582e054..d167f74f 100644 --- a/pkg/eth/eth_state_test.go +++ b/pkg/eth/eth_state_test.go @@ -33,7 +33,6 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/statediff" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql" - "github.com/ethereum/go-ethereum/statediff/indexer/node" sdtypes "github.com/ethereum/go-ethereum/statediff/types" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -75,15 +74,7 @@ var _ = Describe("eth state reading tests", func() { It("test init", func() { // db and type initializations var err error - testInfo := node.Info{ - GenesisBlock: test_helpers.Genesis.Hash().String(), - NetworkID: "3", - ID: "3", - ClientName: "geth", - ChainID: params.TestChainConfig.ChainID.Uint64(), - } - - db, err = eth.Setup(ctx, testInfo) + db, err = eth.SetupDB(ctx, test_helpers.Genesis.Hash()) Expect(err).ToNot(HaveOccurred()) transformer, err := sql.NewStateDiffIndexer(ctx, chainConfig, db) diff --git a/pkg/eth/ipld_fetcher_test.go b/pkg/eth/ipld_fetcher_test.go index c76615f5..84515034 100644 --- a/pkg/eth/ipld_fetcher_test.go +++ b/pkg/eth/ipld_fetcher_test.go @@ -20,7 +20,6 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql" "github.com/ethereum/go-ethereum/statediff/indexer/interfaces" - "github.com/ethereum/go-ethereum/statediff/indexer/node" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -40,15 +39,8 @@ var _ = Describe("IPLDFetcher", func() { err error tx interfaces.Batch ) - testInfo := node.Info{ - GenesisBlock: test_helpers.Genesis.Hash().String(), - NetworkID: "4", - ID: "4", - ClientName: "geth", - ChainID: params.TestChainConfig.ChainID.Uint64(), - } - db, err = eth.Setup(ctx, testInfo) + db, err = eth.SetupDB(ctx, test_helpers.Genesis.Hash()) Expect(err).ToNot(HaveOccurred()) pubAndIndexer, err = sql.NewStateDiffIndexer(ctx, params.TestChainConfig, db) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/eth/test_helpers.go b/pkg/eth/test_helpers.go index a83fd9b7..bb481f36 100644 --- a/pkg/eth/test_helpers.go +++ b/pkg/eth/test_helpers.go @@ -20,6 +20,8 @@ import ( "context" "os" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql/postgres" "github.com/ethereum/go-ethereum/statediff/indexer/models" @@ -27,8 +29,15 @@ import ( . "github.com/onsi/gomega" ) -func Setup(ctx context.Context, info node.Info) (sql.Database, error) { - driver, err := postgres.NewSQLXDriver(ctx, getConfig(), info) +func SetupDB(ctx context.Context, genHash common.Hash) (sql.Database, error) { + testInfo := node.Info{ + GenesisBlock: genHash.String(), + NetworkID: "1", + ID: "1", + ClientName: "geth", + ChainID: params.TestChainConfig.ChainID.Uint64(), + } + driver, err := postgres.NewSQLXDriver(ctx, getConfig(), testInfo) Expect(err).NotTo(HaveOccurred()) return postgres.NewPostgresDB(driver), nil } diff --git a/pkg/graphql/graphql_test.go b/pkg/graphql/graphql_test.go index 33aa0203..503bdbed 100644 --- a/pkg/graphql/graphql_test.go +++ b/pkg/graphql/graphql_test.go @@ -31,7 +31,6 @@ import ( "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/statediff" "github.com/ethereum/go-ethereum/statediff/indexer/database/sql" - "github.com/ethereum/go-ethereum/statediff/indexer/node" sdtypes "github.com/ethereum/go-ethereum/statediff/types" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -66,14 +65,7 @@ var _ = Describe("GraphQL", func() { It("test init", func() { var err error - testInfo := node.Info{ - GenesisBlock: test_helpers.Genesis.Hash().String(), - NetworkID: "5", - ID: "5", - ClientName: "geth", - ChainID: params.TestChainConfig.ChainID.Uint64(), - } - db, err = eth.Setup(ctx, testInfo) + db, err = eth.SetupDB(ctx, test_helpers.Genesis.Hash()) Expect(err).ToNot(HaveOccurred()) transformer, err := sql.NewStateDiffIndexer(ctx, chainConfig, db)