Code Clean Up

This commit is contained in:
Abdul Rabbani 2022-03-30 17:30:19 -04:00
parent bcfc34dd81
commit 68a0c09657
4 changed files with 5 additions and 33 deletions

View File

@ -14,3 +14,7 @@ It is recommended that you move the following repositories under this folder. Ke
## Symlinks
You can also create symlinks in this folder with the location of your repositories.
# Dependencies
If you want to use `foundry-test`, you will need to utilize the recommended setup.

View File

@ -2,23 +2,18 @@ package sql_test
import (
"bytes"
"context"
"errors"
"fmt"
"os"
"testing"
"github.com/ipfs/go-cid"
"github.com/jmoiron/sqlx"
"github.com/multiformats/go-multihash"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/statediff/indexer/database/file"
"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/interfaces"
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
"github.com/ethereum/go-ethereum/statediff/indexer/mocks"
@ -26,7 +21,6 @@ import (
var (
db sql.Database
sqlxdb *sqlx.DB
err error
ind interfaces.StateDiffIndexer
chainConf = params.MainnetChainConfig
@ -173,25 +167,6 @@ func checkTxClosure(t *testing.T, idle, inUse, open int64) {
require.Equal(t, open, db.Stats().Open())
}
func setupDb(t *testing.T) (*sql.StateDiffIndexer, error) {
db, err = postgres.SetupSQLXDB()
if err != nil {
t.Fatal(err)
}
stateDiff, err := sql.NewStateDiffIndexer(context.Background(), chainConf, db)
return stateDiff, err
}
func setupFile(t *testing.T) interfaces.StateDiffIndexer {
if _, err := os.Stat(file.TestConfig.FilePath); !errors.Is(err, os.ErrNotExist) {
err := os.Remove(file.TestConfig.FilePath)
require.NoError(t, err)
}
ind, err = file.NewStateDiffIndexer(context.Background(), mocks.TestConfig, file.TestConfig)
require.NoError(t, err)
return ind
}
func tearDown(t *testing.T) {
sql.TearDownDB(t, db)
err := ind.Close()

View File

@ -75,17 +75,12 @@ func testPushBlockAndState(t *testing.T, block *types.Block, receipts types.Rece
})
}
func setupDb(t *testing.T) (interfaces.StateDiffIndexer, error) {
func setup(t *testing.T, testBlock *types.Block, testReceipts types.Receipts) {
db, err = postgres.SetupSQLXDB()
if err != nil {
t.Fatal(err)
}
ind, err = sql.NewStateDiffIndexer(context.Background(), chainConf, db)
return ind, err
}
func setup(t *testing.T, testBlock *types.Block, testReceipts types.Receipts) (interfaces.StateDiffIndexer, interfaces.Batch) {
ind, err = setupDb(t)
require.NoError(t, err)
var tx interfaces.Batch
tx, err = ind.PushBlock(

View File

@ -147,8 +147,6 @@ type Service struct {
maxRetry uint
}
// This structure keeps track of the knownGaps at any given moment in time
// BlockCache caches the last block for safe access from different service loops
type BlockCache struct {
sync.Mutex