Refactoring

* Move flip kick files pkg/transformers/flip_kick

* Consolidate test database setup

* Pull ganache ipcPath from config

* Update README to include info about using a Ganache chain
This commit is contained in:
Elizabeth
2018-08-07 15:17:29 -05:00
committed by GitHub
parent c617cd9c9d
commit b37324bf3d
257 changed files with 188 additions and 173 deletions
+26 -5
View File
@@ -2,17 +2,20 @@ package test_config
import (
"log"
"os"
. "github.com/onsi/gomega"
"github.com/spf13/viper"
"github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
)
var TestConfig *viper.Viper
var DBConfig config.Database
var TestClient config.Client
var Infura *viper.Viper
var InfuraClient config.Client
var ABIFilePath string
@@ -28,6 +31,7 @@ func setTestConfig() {
TestConfig.SetConfigName("private")
TestConfig.AddConfigPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/environments/")
err := TestConfig.ReadInConfig()
ipc := TestConfig.GetString("client.ipcPath")
if err != nil {
log.Fatal(err)
}
@@ -39,6 +43,9 @@ func setTestConfig() {
Name: name,
Port: port,
}
TestClient = config.Client{
IPCPath: ipc,
}
}
func setInfuraConfig() {
@@ -62,6 +69,10 @@ func setABIPath() {
func NewTestDB(node core.Node) *postgres.DB {
db, _ := postgres.NewDB(DBConfig, node)
return db
}
func CleanTestDB(db *postgres.DB) {
db.MustExec("DELETE FROM blocks")
db.MustExec("DELETE FROM headers")
db.MustExec("DELETE FROM log_filters")
@@ -69,10 +80,20 @@ func NewTestDB(node core.Node) *postgres.DB {
db.MustExec("DELETE FROM receipts")
db.MustExec("DELETE FROM transactions")
db.MustExec("DELETE FROM watched_contracts")
return db
}
func NewTestDBWithoutDeletingRecords(node core.Node) *postgres.DB {
db, _ := postgres.NewDB(DBConfig, node)
return db
func NewTestNode() core.Node {
return core.Node{
GenesisBlock: "GENESIS",
NetworkID: 1,
ID: "b6f90c0fdd8ec9607aed8ee45c69322e47b7063f0bfb7a29c8ecafab24d0a22d24dd2329b5ee6ed4125a03cb14e57fd584e67f9e53e6c631055cbbd82f080845",
ClientName: "Geth/v1.7.2-stable-1db4ecdc/darwin-amd64/go1.9",
}
}
func NewTestBlock(blockNumber int64, repository repositories.BlockRepository) (blockId int64) {
blockId, err := repository.CreateOrUpdateBlock(core.Block{Number: blockNumber})
Expect(err).NotTo(HaveOccurred())
return blockId
}