Rename geth to eth, signifying client independence (#161)

This commit is contained in:
Edvard Hübinette 2019-10-28 12:30:24 +01:00 committed by GitHub
parent f7c4a6736d
commit 3fff2896aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 111 additions and 111 deletions

View File

@ -23,10 +23,10 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/crypto" "github.com/vulcanize/vulcanizedb/pkg/crypto"
"github.com/vulcanize/vulcanizedb/pkg/datastore/ethereum" "github.com/vulcanize/vulcanizedb/pkg/datastore/ethereum"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/eth/cold_import"
"github.com/vulcanize/vulcanizedb/pkg/eth/converters/cold_db"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
"github.com/vulcanize/vulcanizedb/pkg/fs" "github.com/vulcanize/vulcanizedb/pkg/fs"
"github.com/vulcanize/vulcanizedb/pkg/geth/cold_import"
"github.com/vulcanize/vulcanizedb/pkg/geth/converters/cold_db"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common"
"github.com/vulcanize/vulcanizedb/utils" "github.com/vulcanize/vulcanizedb/utils"
) )

View File

@ -25,7 +25,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/pkg/history" "github.com/vulcanize/vulcanizedb/pkg/history"
"github.com/vulcanize/vulcanizedb/utils" "github.com/vulcanize/vulcanizedb/utils"
) )
@ -100,7 +100,7 @@ func headerSync() {
} }
} }
func validateArgs(blockChain *geth.BlockChain) { func validateArgs(blockChain *eth.BlockChain) {
lastBlock, err := blockChain.LastBlock() lastBlock, err := blockChain.LastBlock()
if err != nil { if err != nil {
LogWithCommand.Error("validateArgs: Error getting last block: ", err) LogWithCommand.Error("validateArgs: Error getting last block: ", err)

View File

@ -28,10 +28,10 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/vulcanize/vulcanizedb/pkg/config" "github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" vRpc "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node" "github.com/vulcanize/vulcanizedb/pkg/eth/node"
) )
var ( var (
@ -155,12 +155,12 @@ func initConfig() {
} }
} }
func getBlockChain() *geth.BlockChain { func getBlockChain() *eth.BlockChain {
rpcClient, ethClient := getClients() rpcClient, ethClient := getClients()
vdbEthClient := client.NewEthClient(ethClient) vdbEthClient := client.NewEthClient(ethClient)
vdbNode := node.MakeNode(rpcClient) vdbNode := node.MakeNode(rpcClient)
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient) transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
return geth.NewBlockChain(vdbEthClient, rpcClient, vdbNode, transactionConverter) return eth.NewBlockChain(vdbEthClient, rpcClient, vdbNode, transactionConverter)
} }
func getClients() (client.RpcClient, *ethclient.Client) { func getClients() (client.RpcClient, *ethclient.Client) {

View File

@ -22,10 +22,10 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" vRpc "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node" "github.com/vulcanize/vulcanizedb/pkg/eth/node"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
) )
@ -39,7 +39,7 @@ var _ = Describe("Rewards calculations", func() {
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient) transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
block, err := blockChain.GetBlockByNumber(1071819) block, err := blockChain.GetBlockByNumber(1071819)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(block.Reward).To(Equal("5313550000000000000")) Expect(block.Reward).To(Equal("5313550000000000000"))
@ -53,7 +53,7 @@ var _ = Describe("Rewards calculations", func() {
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient) transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
block, err := blockChain.GetBlockByNumber(1071819) block, err := blockChain.GetBlockByNumber(1071819)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(block.UnclesReward).To(Equal("6875000000000000000")) Expect(block.UnclesReward).To(Equal("6875000000000000000"))

View File

@ -26,11 +26,11 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" rpc2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node" "github.com/vulcanize/vulcanizedb/pkg/eth/node"
"github.com/vulcanize/vulcanizedb/pkg/geth/testing" "github.com/vulcanize/vulcanizedb/pkg/eth/testing"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
) )
@ -56,7 +56,7 @@ var _ = Describe("Reading contracts", func() {
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
contract := testing.SampleContract() contract := testing.SampleContract()
logs, err := blockChain.GetFullSyncLogs(contract, big.NewInt(4703824), nil) logs, err := blockChain.GetFullSyncLogs(contract, big.NewInt(4703824), nil)
@ -74,7 +74,7 @@ var _ = Describe("Reading contracts", func() {
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
logs, err := blockChain.GetFullSyncLogs(core.Contract{Hash: "0x123"}, big.NewInt(4703824), nil) logs, err := blockChain.GetFullSyncLogs(core.Contract{Hash: "0x123"}, big.NewInt(4703824), nil)
@ -92,7 +92,7 @@ var _ = Describe("Reading contracts", func() {
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
contract := testing.SampleContract() contract := testing.SampleContract()
var balance = new(big.Int) var balance = new(big.Int)

View File

@ -24,17 +24,17 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/eth/node"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
"github.com/vulcanize/vulcanizedb/pkg/history" "github.com/vulcanize/vulcanizedb/pkg/history"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
) )
var _ = Describe("Reading from the Geth blockchain", func() { var _ = Describe("Reading from the Geth blockchain", func() {
var blockChain *geth.BlockChain var blockChain *eth.BlockChain
BeforeEach(func() { BeforeEach(func() {
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath) rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath)
@ -44,7 +44,7 @@ var _ = Describe("Reading from the Geth blockchain", func() {
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain = geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) blockChain = eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
}) })
It("reads two blocks", func(done Done) { It("reads two blocks", func(done Done) {

View File

@ -19,7 +19,7 @@ package config
import ( import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"strings" "strings"
) )
@ -98,7 +98,7 @@ func (contractConfig *ContractConfig) PrepConfig() {
} }
} }
if abi != "" { if abi != "" {
if _, abiErr := geth.ParseAbi(abi); abiErr != nil { if _, abiErr := eth.ParseAbi(abi); abiErr != nil {
log.Fatal(addr, "transformer `abi` not valid JSON") log.Fatal(addr, "transformer `abi` not valid JSON")
} }
} }

View File

@ -24,10 +24,10 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/getter" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/getter"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" rpc2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node" "github.com/vulcanize/vulcanizedb/pkg/eth/node"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
) )
@ -45,12 +45,12 @@ var _ = Describe("Interface Getter", func() {
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
interfaceGetter := getter.NewInterfaceGetter(blockChain) interfaceGetter := getter.NewInterfaceGetter(blockChain)
abi, err := interfaceGetter.GetABI(constants.PublicResolverAddress, blockNumber) abi, err := interfaceGetter.GetABI(constants.PublicResolverAddress, blockNumber)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(abi).To(Equal(expectedABI)) Expect(abi).To(Equal(expectedABI))
_, err = geth.ParseAbi(abi) _, err = eth.ParseAbi(abi)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
}) })

View File

@ -30,10 +30,10 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" rpc2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node" "github.com/vulcanize/vulcanizedb/pkg/eth/node"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
) )
@ -117,7 +117,7 @@ func SetupDBandBC() (*postgres.DB, core.BlockChain) {
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
madeNode := node.MakeNode(rpcClient) madeNode := node.MakeNode(rpcClient)
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, madeNode, transactionConverter) blockChain := eth.NewBlockChain(blockChainClient, rpcClient, madeNode, transactionConverter)
db, err := postgres.NewDB(config.Database{ db, err := postgres.NewDB(config.Database{
Hostname: "localhost", Hostname: "localhost",

View File

@ -20,7 +20,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
) )
// Mock parser // Mock parser
@ -50,7 +50,7 @@ func (p *parser) ParsedAbi() abi.ABI {
// for the given contract address // for the given contract address
func (p *parser) Parse() error { func (p *parser) Parse() error {
var err error var err error
p.parsedAbi, err = geth.ParseAbi(p.abi) p.parsedAbi, err = eth.ParseAbi(p.abi)
return err return err
} }

View File

@ -24,7 +24,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants"
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
) )
// Parser is used to fetch and parse contract ABIs // Parser is used to fetch and parse contract ABIs
@ -40,16 +40,16 @@ type Parser interface {
} }
type parser struct { type parser struct {
client *geth.EtherScanAPI client *eth.EtherScanAPI
abi string abi string
parsedAbi abi.ABI parsedAbi abi.ABI
} }
func NewParser(network string) *parser { func NewParser(network string) *parser {
url := geth.GenURL(network) url := eth.GenURL(network)
return &parser{ return &parser{
client: geth.NewEtherScanClient(url), client: eth.NewEtherScanClient(url),
} }
} }
@ -69,7 +69,7 @@ func (p *parser) Parse(contractAddr string) error {
knownAbi, err := p.lookUp(contractAddr) knownAbi, err := p.lookUp(contractAddr)
if err == nil { if err == nil {
p.abi = knownAbi p.abi = knownAbi
p.parsedAbi, err = geth.ParseAbi(knownAbi) p.parsedAbi, err = eth.ParseAbi(knownAbi)
return err return err
} }
// Try getting abi from etherscan // Try getting abi from etherscan
@ -79,7 +79,7 @@ func (p *parser) Parse(contractAddr string) error {
} }
//TODO: Implement other ways to fetch abi //TODO: Implement other ways to fetch abi
p.abi = abiStr p.abi = abiStr
p.parsedAbi, err = geth.ParseAbi(abiStr) p.parsedAbi, err = eth.ParseAbi(abiStr)
return err return err
} }
@ -88,7 +88,7 @@ func (p *parser) Parse(contractAddr string) error {
func (p *parser) ParseAbiStr(abiStr string) error { func (p *parser) ParseAbiStr(abiStr string) error {
var err error var err error
p.abi = abiStr p.abi = abiStr
p.parsedAbi, err = geth.ParseAbi(abiStr) p.parsedAbi, err = eth.ParseAbi(abiStr)
return err return err
} }

View File

@ -25,7 +25,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/helpers/test_helpers/mocks" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/helpers/test_helpers/mocks"
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/parser" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/parser"
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types" "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
) )
var _ = Describe("Parser", func() { var _ = Describe("Parser", func() {
@ -44,7 +44,7 @@ var _ = Describe("Parser", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
parsedAbi := mp.ParsedAbi() parsedAbi := mp.ParsedAbi()
expectedAbi, err := geth.ParseAbi(constants.DaiAbiString) expectedAbi, err := eth.ParseAbi(constants.DaiAbiString)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(parsedAbi).To(Equal(expectedAbi)) Expect(parsedAbi).To(Equal(expectedAbi))
@ -73,7 +73,7 @@ var _ = Describe("Parser", func() {
expectedAbi := constants.DaiAbiString expectedAbi := constants.DaiAbiString
Expect(p.Abi()).To(Equal(expectedAbi)) Expect(p.Abi()).To(Equal(expectedAbi))
expectedParsedAbi, err := geth.ParseAbi(expectedAbi) expectedParsedAbi, err := eth.ParseAbi(expectedAbi)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(p.ParsedAbi()).To(Equal(expectedParsedAbi)) Expect(p.ParsedAbi()).To(Equal(expectedParsedAbi))
}) })

View File

@ -20,7 +20,7 @@ import (
"context" "context"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
) )
type RpcClient interface { type RpcClient interface {

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
package geth package eth
import ( import (
"errors" "errors"

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
package geth_test package eth_test
import ( import (
"net/http" "net/http"
@ -25,7 +25,7 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp" "github.com/onsi/gomega/ghttp"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
) )
@ -36,7 +36,7 @@ var _ = Describe("ABI files", func() {
It("loads a valid ABI file", func() { It("loads a valid ABI file", func() {
path := test_config.ABIFilePath + "valid_abi.json" path := test_config.ABIFilePath + "valid_abi.json"
contractAbi, err := geth.ParseAbiFile(path) contractAbi, err := eth.ParseAbiFile(path)
Expect(contractAbi).NotTo(BeNil()) Expect(contractAbi).NotTo(BeNil())
Expect(err).To(BeNil()) Expect(err).To(BeNil())
@ -45,7 +45,7 @@ var _ = Describe("ABI files", func() {
It("reads the contents of a valid ABI file", func() { It("reads the contents of a valid ABI file", func() {
path := test_config.ABIFilePath + "valid_abi.json" path := test_config.ABIFilePath + "valid_abi.json"
contractAbi, err := geth.ReadAbiFile(path) contractAbi, err := eth.ReadAbiFile(path)
Expect(contractAbi).To(Equal("[{\"foo\": \"bar\"}]")) Expect(contractAbi).To(Equal("[{\"foo\": \"bar\"}]"))
Expect(err).To(BeNil()) Expect(err).To(BeNil())
@ -54,38 +54,38 @@ var _ = Describe("ABI files", func() {
It("returns an error when the file does not exist", func() { It("returns an error when the file does not exist", func() {
path := test_config.ABIFilePath + "missing_abi.json" path := test_config.ABIFilePath + "missing_abi.json"
contractAbi, err := geth.ParseAbiFile(path) contractAbi, err := eth.ParseAbiFile(path)
Expect(contractAbi).To(Equal(abi.ABI{})) Expect(contractAbi).To(Equal(abi.ABI{}))
Expect(err).To(Equal(geth.ErrMissingAbiFile)) Expect(err).To(Equal(eth.ErrMissingAbiFile))
}) })
It("returns an error when the file has invalid contents", func() { It("returns an error when the file has invalid contents", func() {
path := test_config.ABIFilePath + "invalid_abi.json" path := test_config.ABIFilePath + "invalid_abi.json"
contractAbi, err := geth.ParseAbiFile(path) contractAbi, err := eth.ParseAbiFile(path)
Expect(contractAbi).To(Equal(abi.ABI{})) Expect(contractAbi).To(Equal(abi.ABI{}))
Expect(err).To(Equal(geth.ErrInvalidAbiFile)) Expect(err).To(Equal(eth.ErrInvalidAbiFile))
}) })
Describe("Request ABI from endpoint", func() { Describe("Request ABI from endpoint", func() {
var ( var (
server *ghttp.Server server *ghttp.Server
client *geth.EtherScanAPI client *eth.EtherScanAPI
abiString string abiString string
err error err error
) )
BeforeEach(func() { BeforeEach(func() {
server = ghttp.NewServer() server = ghttp.NewServer()
client = geth.NewEtherScanClient(server.URL()) client = eth.NewEtherScanClient(server.URL())
path := test_config.ABIFilePath + "sample_abi.json" path := test_config.ABIFilePath + "sample_abi.json"
abiString, err = geth.ReadAbiFile(path) abiString, err = eth.ReadAbiFile(path)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
_, err = geth.ParseAbi(abiString) _, err = eth.ParseAbi(abiString)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })
@ -117,14 +117,14 @@ var _ = Describe("ABI files", func() {
Describe("Generating etherscan endpoints based on network", func() { Describe("Generating etherscan endpoints based on network", func() {
It("should return the main endpoint as the default", func() { It("should return the main endpoint as the default", func() {
url := geth.GenURL("") url := eth.GenURL("")
Expect(url).To(Equal("https://api.etherscan.io")) Expect(url).To(Equal("https://api.etherscan.io"))
}) })
It("generates various test network endpoint if test network is supplied", func() { It("generates various test network endpoint if test network is supplied", func() {
ropstenUrl := geth.GenURL("ropsten") ropstenUrl := eth.GenURL("ropsten")
rinkebyUrl := geth.GenURL("rinkeby") rinkebyUrl := eth.GenURL("rinkeby")
kovanUrl := geth.GenURL("kovan") kovanUrl := eth.GenURL("kovan")
Expect(ropstenUrl).To(Equal("https://ropsten.etherscan.io")) Expect(ropstenUrl).To(Equal("https://ropsten.etherscan.io"))
Expect(kovanUrl).To(Equal("https://kovan.etherscan.io")) Expect(kovanUrl).To(Equal("https://kovan.etherscan.io"))

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
package geth package eth
import ( import (
"errors" "errors"
@ -28,8 +28,8 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
) )
var ErrEmptyHeader = errors.New("empty header returned over RPC") var ErrEmptyHeader = errors.New("empty header returned over RPC")

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
package geth_test package eth_test
import ( import (
"context" "context"
@ -29,14 +29,14 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
vulcCore "github.com/vulcanize/vulcanizedb/pkg/core" vulcCore "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth"
) )
var _ = Describe("Geth blockchain", func() { var _ = Describe("Geth blockchain", func() {
var ( var (
mockClient *fakes.MockEthClient mockClient *fakes.MockEthClient
blockChain *geth.BlockChain blockChain *eth.BlockChain
mockRpcClient *fakes.MockRpcClient mockRpcClient *fakes.MockRpcClient
mockTransactionConverter *fakes.MockTransactionConverter mockTransactionConverter *fakes.MockTransactionConverter
node vulcCore.Node node vulcCore.Node
@ -47,7 +47,7 @@ var _ = Describe("Geth blockchain", func() {
mockRpcClient = fakes.NewMockRpcClient() mockRpcClient = fakes.NewMockRpcClient()
mockTransactionConverter = fakes.NewMockTransactionConverter() mockTransactionConverter = fakes.NewMockTransactionConverter()
node = vulcCore.Node{} node = vulcCore.Node{}
blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, mockTransactionConverter) blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, mockTransactionConverter)
}) })
Describe("getting a block", func() { Describe("getting a block", func() {
@ -105,7 +105,7 @@ var _ = Describe("Geth blockchain", func() {
node.NetworkID = vulcCore.KOVAN_NETWORK_ID node.NetworkID = vulcCore.KOVAN_NETWORK_ID
blockNumber := hexutil.Big(*big.NewInt(100)) blockNumber := hexutil.Big(*big.NewInt(100))
mockRpcClient.SetReturnPOAHeader(vulcCore.POAHeader{Number: &blockNumber}) mockRpcClient.SetReturnPOAHeader(vulcCore.POAHeader{Number: &blockNumber})
blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter())
_, err := blockChain.GetHeaderByNumber(100) _, err := blockChain.GetHeaderByNumber(100)
@ -116,7 +116,7 @@ var _ = Describe("Geth blockchain", func() {
It("returns err if rpcClient returns err", func() { It("returns err if rpcClient returns err", func() {
node.NetworkID = vulcCore.KOVAN_NETWORK_ID node.NetworkID = vulcCore.KOVAN_NETWORK_ID
mockRpcClient.SetCallContextErr(fakes.FakeError) mockRpcClient.SetCallContextErr(fakes.FakeError)
blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter())
_, err := blockChain.GetHeaderByNumber(100) _, err := blockChain.GetHeaderByNumber(100)
@ -126,12 +126,12 @@ var _ = Describe("Geth blockchain", func() {
It("returns error if returned header is empty", func() { It("returns error if returned header is empty", func() {
node.NetworkID = vulcCore.KOVAN_NETWORK_ID node.NetworkID = vulcCore.KOVAN_NETWORK_ID
blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter()) blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter())
_, err := blockChain.GetHeaderByNumber(100) _, err := blockChain.GetHeaderByNumber(100)
Expect(err).To(HaveOccurred()) Expect(err).To(HaveOccurred())
Expect(err).To(MatchError(geth.ErrEmptyHeader)) Expect(err).To(MatchError(eth.ErrEmptyHeader))
}) })
It("returns multiple headers with multiple blocknumbers", func() { It("returns multiple headers with multiple blocknumbers", func() {

View File

@ -19,7 +19,7 @@ package cold_import
import ( import (
"github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore"
"github.com/vulcanize/vulcanizedb/pkg/datastore/ethereum" "github.com/vulcanize/vulcanizedb/pkg/datastore/ethereum"
"github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
) )
type ColdImporter struct { type ColdImporter struct {

View File

@ -21,9 +21,9 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/eth/cold_import"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth/cold_import"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common"
) )
var _ = Describe("Geth cold importer", func() { var _ = Describe("Geth cold importer", func() {

View File

@ -21,8 +21,8 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/eth/cold_import"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth/cold_import"
) )
var _ = Describe("Cold importer node builder", func() { var _ = Describe("Cold importer node builder", func() {

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
package geth package eth
import ( import (
"context" "context"

View File

@ -29,9 +29,9 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
"github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common"
"github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
) )
var _ = Describe("Conversion of GethBlock to core.Block", func() { var _ = Describe("Conversion of GethBlock to core.Block", func() {

View File

@ -26,7 +26,7 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
) )
var _ = Describe("Conversion of GethLog to core.FullSyncLog", func() { var _ = Describe("Conversion of GethLog to core.FullSyncLog", func() {

View File

@ -26,8 +26,8 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
common2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
common2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common"
) )
var _ = Describe("Block header converter", func() { var _ = Describe("Block header converter", func() {

View File

@ -25,7 +25,7 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
) )
var _ = Describe("Conversion of GethReceipt to core.Receipt", func() { var _ = Describe("Conversion of GethReceipt to core.Receipt", func() {

View File

@ -31,7 +31,7 @@ import (
"golang.org/x/sync/errgroup" "golang.org/x/sync/errgroup"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common" vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
) )
type RpcTransactionConverter struct { type RpcTransactionConverter struct {

View File

@ -20,8 +20,8 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
) )
var _ = Describe("RPC transaction converter", func() { var _ = Describe("RPC transaction converter", func() {

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
package geth_test package eth_test
import ( import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
@ -25,5 +25,5 @@ import (
func TestGeth(t *testing.T) { func TestGeth(t *testing.T) {
RegisterFailHandler(Fail) RegisterFailHandler(Fail)
RunSpecs(t, "Geth Suite") RunSpecs(t, "eth Suite")
} }

View File

@ -23,8 +23,8 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/eth/node"
"github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
) )
var EmpytHeaderHash = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" var EmpytHeaderHash = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"

View File

@ -20,7 +20,7 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
) )
@ -32,7 +32,7 @@ func SampleContract() core.Contract {
} }
func sampleAbiFileContents() string { func sampleAbiFileContents() string {
abiFileContents, err := geth.ReadAbiFile(test_config.ABIFilePath + "sample_abi.json") abiFileContents, err := eth.ReadAbiFile(test_config.ABIFilePath + "sample_abi.json")
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
) )
type MockEthClient struct { type MockEthClient struct {

View File

@ -28,7 +28,7 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/geth/client" "github.com/vulcanize/vulcanizedb/pkg/eth/client"
) )
type MockRpcClient struct { type MockRpcClient struct {

View File

@ -91,7 +91,7 @@ func setInfuraConfig() {
func setABIPath() { func setABIPath() {
gp := os.Getenv("GOPATH") gp := os.Getenv("GOPATH")
ABIFilePath = gp + "/src/github.com/vulcanize/vulcanizedb/pkg/geth/testing/" ABIFilePath = gp + "/src/github.com/vulcanize/vulcanizedb/pkg/eth/testing/"
} }
func NewTestDB(node core.Node) *postgres.DB { func NewTestDB(node core.Node) *postgres.DB {

View File

@ -18,7 +18,7 @@ package utils
import ( import (
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
logrus "github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"math/big" "math/big"
"os" "os"
"path/filepath" "path/filepath"
@ -26,7 +26,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/config" "github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/geth" "github.com/vulcanize/vulcanizedb/pkg/eth"
) )
func LoadPostgres(database config.Database, node core.Node) postgres.DB { func LoadPostgres(database config.Database, node core.Node) postgres.DB {
@ -39,7 +39,7 @@ func LoadPostgres(database config.Database, node core.Node) postgres.DB {
func ReadAbiFile(abiFilepath string) string { func ReadAbiFile(abiFilepath string) string {
abiFilepath = AbsFilePath(abiFilepath) abiFilepath = AbsFilePath(abiFilepath)
abi, err := geth.ReadAbiFile(abiFilepath) abi, err := eth.ReadAbiFile(abiFilepath)
if err != nil { if err != nil {
logrus.Fatalf("Error reading ABI file at \"%s\"\n %v", abiFilepath, err) logrus.Fatalf("Error reading ABI file at \"%s\"\n %v", abiFilepath, err)
} }
@ -59,12 +59,12 @@ func GetAbi(abiFilepath string, contractHash string, network string) string {
if abiFilepath != "" { if abiFilepath != "" {
contractAbiString = ReadAbiFile(abiFilepath) contractAbiString = ReadAbiFile(abiFilepath)
} else { } else {
url := geth.GenURL(network) url := eth.GenURL(network)
etherscan := geth.NewEtherScanClient(url) etherscan := eth.NewEtherScanClient(url)
logrus.Printf("No ABI supplied. Retrieving ABI from Etherscan: %s", url) logrus.Printf("No ABI supplied. Retrieving ABI from Etherscan: %s", url)
contractAbiString, _ = etherscan.GetAbi(contractHash) contractAbiString, _ = etherscan.GetAbi(contractHash)
} }
_, err := geth.ParseAbi(contractAbiString) _, err := eth.ParseAbi(contractAbiString)
if err != nil { if err != nil {
logrus.Fatalln("Invalid ABI: ", err) logrus.Fatalln("Invalid ABI: ", err)
} }