Code Clean Up
This commit is contained in:
parent
bcfc34dd81
commit
68a0c09657
@ -14,3 +14,7 @@ It is recommended that you move the following repositories under this folder. Ke
|
|||||||
## Symlinks
|
## Symlinks
|
||||||
|
|
||||||
You can also create symlinks in this folder with the location of your repositories.
|
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.
|
||||||
|
@ -2,23 +2,18 @@ package sql_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/jmoiron/sqlx"
|
|
||||||
"github.com/multiformats/go-multihash"
|
"github.com/multiformats/go-multihash"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"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"
|
||||||
"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/interfaces"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
"github.com/ethereum/go-ethereum/statediff/indexer/ipld"
|
||||||
"github.com/ethereum/go-ethereum/statediff/indexer/mocks"
|
"github.com/ethereum/go-ethereum/statediff/indexer/mocks"
|
||||||
@ -26,7 +21,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
db sql.Database
|
db sql.Database
|
||||||
sqlxdb *sqlx.DB
|
|
||||||
err error
|
err error
|
||||||
ind interfaces.StateDiffIndexer
|
ind interfaces.StateDiffIndexer
|
||||||
chainConf = params.MainnetChainConfig
|
chainConf = params.MainnetChainConfig
|
||||||
@ -173,25 +167,6 @@ func checkTxClosure(t *testing.T, idle, inUse, open int64) {
|
|||||||
require.Equal(t, open, db.Stats().Open())
|
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) {
|
func tearDown(t *testing.T) {
|
||||||
sql.TearDownDB(t, db)
|
sql.TearDownDB(t, db)
|
||||||
err := ind.Close()
|
err := ind.Close()
|
||||||
|
@ -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()
|
db, err = postgres.SetupSQLXDB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
ind, err = sql.NewStateDiffIndexer(context.Background(), chainConf, db)
|
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)
|
require.NoError(t, err)
|
||||||
var tx interfaces.Batch
|
var tx interfaces.Batch
|
||||||
tx, err = ind.PushBlock(
|
tx, err = ind.PushBlock(
|
||||||
|
@ -147,8 +147,6 @@ type Service struct {
|
|||||||
maxRetry uint
|
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
|
// BlockCache caches the last block for safe access from different service loops
|
||||||
type BlockCache struct {
|
type BlockCache struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
Loading…
Reference in New Issue
Block a user