forked from cerc-io/ipld-eth-server
Rename geth to eth, signifying client independence (#161)
This commit is contained in:
parent
f7c4a6736d
commit
3fff2896aa
@ -23,10 +23,10 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/crypto"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/ethereum"
|
||||
"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/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"
|
||||
)
|
||||
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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/utils"
|
||||
)
|
||||
@ -100,7 +100,7 @@ func headerSync() {
|
||||
}
|
||||
}
|
||||
|
||||
func validateArgs(blockChain *geth.BlockChain) {
|
||||
func validateArgs(blockChain *eth.BlockChain) {
|
||||
lastBlock, err := blockChain.LastBlock()
|
||||
if err != nil {
|
||||
LogWithCommand.Error("validateArgs: Error getting last block: ", err)
|
||||
|
12
cmd/root.go
12
cmd/root.go
@ -28,10 +28,10 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/config"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
||||
vRpc "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/node"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -155,12 +155,12 @@ func initConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
func getBlockChain() *geth.BlockChain {
|
||||
func getBlockChain() *eth.BlockChain {
|
||||
rpcClient, ethClient := getClients()
|
||||
vdbEthClient := client.NewEthClient(ethClient)
|
||||
vdbNode := node.MakeNode(rpcClient)
|
||||
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
|
||||
return geth.NewBlockChain(vdbEthClient, rpcClient, vdbNode, transactionConverter)
|
||||
return eth.NewBlockChain(vdbEthClient, rpcClient, vdbNode, transactionConverter)
|
||||
}
|
||||
|
||||
func getClients() (client.RpcClient, *ethclient.Client) {
|
||||
|
@ -22,10 +22,10 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
||||
vRpc "github.com/vulcanize/vulcanizedb/pkg/eth/converters/rpc"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/node"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
@ -39,7 +39,7 @@ var _ = Describe("Rewards calculations", func() {
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
|
||||
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
block, err := blockChain.GetBlockByNumber(1071819)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(block.Reward).To(Equal("5313550000000000000"))
|
||||
@ -53,7 +53,7 @@ var _ = Describe("Rewards calculations", func() {
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
|
||||
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
block, err := blockChain.GetBlockByNumber(1071819)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(block.UnclesReward).To(Equal("6875000000000000000"))
|
||||
|
@ -26,11 +26,11 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"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/geth/testing"
|
||||
"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/eth/testing"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
@ -56,7 +56,7 @@ var _ = Describe("Reading contracts", func() {
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
||||
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
contract := testing.SampleContract()
|
||||
|
||||
logs, err := blockChain.GetFullSyncLogs(contract, big.NewInt(4703824), nil)
|
||||
@ -74,7 +74,7 @@ var _ = Describe("Reading contracts", func() {
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
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)
|
||||
|
||||
@ -92,7 +92,7 @@ var _ = Describe("Reading contracts", func() {
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
||||
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
|
||||
contract := testing.SampleContract()
|
||||
var balance = new(big.Int)
|
||||
|
@ -24,17 +24,17 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"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/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/test_config"
|
||||
)
|
||||
|
||||
var _ = Describe("Reading from the Geth blockchain", func() {
|
||||
var blockChain *geth.BlockChain
|
||||
var blockChain *eth.BlockChain
|
||||
|
||||
BeforeEach(func() {
|
||||
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath)
|
||||
@ -44,7 +44,7 @@ var _ = Describe("Reading from the Geth blockchain", func() {
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
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) {
|
||||
|
@ -19,7 +19,7 @@ package config
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -98,7 +98,7 @@ func (contractConfig *ContractConfig) PrepConfig() {
|
||||
}
|
||||
}
|
||||
if abi != "" {
|
||||
if _, abiErr := geth.ParseAbi(abi); abiErr != nil {
|
||||
if _, abiErr := eth.ParseAbi(abi); abiErr != nil {
|
||||
log.Fatal(addr, "transformer `abi` not valid JSON")
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ import (
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/getter"
|
||||
"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/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/test_config"
|
||||
)
|
||||
|
||||
@ -45,12 +45,12 @@ var _ = Describe("Interface Getter", func() {
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
||||
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
interfaceGetter := getter.NewInterfaceGetter(blockChain)
|
||||
abi, err := interfaceGetter.GetABI(constants.PublicResolverAddress, blockNumber)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(abi).To(Equal(expectedABI))
|
||||
_, err = geth.ParseAbi(abi)
|
||||
_, err = eth.ParseAbi(abi)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
@ -30,10 +30,10 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
|
||||
"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/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/test_config"
|
||||
)
|
||||
|
||||
@ -117,7 +117,7 @@ func SetupDBandBC() (*postgres.DB, core.BlockChain) {
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
madeNode := node.MakeNode(rpcClient)
|
||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
||||
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, madeNode, transactionConverter)
|
||||
blockChain := eth.NewBlockChain(blockChainClient, rpcClient, madeNode, transactionConverter)
|
||||
|
||||
db, err := postgres.NewDB(config.Database{
|
||||
Hostname: "localhost",
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
)
|
||||
|
||||
// Mock parser
|
||||
@ -50,7 +50,7 @@ func (p *parser) ParsedAbi() abi.ABI {
|
||||
// for the given contract address
|
||||
func (p *parser) Parse() error {
|
||||
var err error
|
||||
p.parsedAbi, err = geth.ParseAbi(p.abi)
|
||||
p.parsedAbi, err = eth.ParseAbi(p.abi)
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/constants"
|
||||
"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
|
||||
@ -40,16 +40,16 @@ type Parser interface {
|
||||
}
|
||||
|
||||
type parser struct {
|
||||
client *geth.EtherScanAPI
|
||||
client *eth.EtherScanAPI
|
||||
abi string
|
||||
parsedAbi abi.ABI
|
||||
}
|
||||
|
||||
func NewParser(network string) *parser {
|
||||
url := geth.GenURL(network)
|
||||
url := eth.GenURL(network)
|
||||
|
||||
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)
|
||||
if err == nil {
|
||||
p.abi = knownAbi
|
||||
p.parsedAbi, err = geth.ParseAbi(knownAbi)
|
||||
p.parsedAbi, err = eth.ParseAbi(knownAbi)
|
||||
return err
|
||||
}
|
||||
// Try getting abi from etherscan
|
||||
@ -79,7 +79,7 @@ func (p *parser) Parse(contractAddr string) error {
|
||||
}
|
||||
//TODO: Implement other ways to fetch abi
|
||||
p.abi = abiStr
|
||||
p.parsedAbi, err = geth.ParseAbi(abiStr)
|
||||
p.parsedAbi, err = eth.ParseAbi(abiStr)
|
||||
|
||||
return err
|
||||
}
|
||||
@ -88,7 +88,7 @@ func (p *parser) Parse(contractAddr string) error {
|
||||
func (p *parser) ParseAbiStr(abiStr string) error {
|
||||
var err error
|
||||
p.abi = abiStr
|
||||
p.parsedAbi, err = geth.ParseAbi(abiStr)
|
||||
p.parsedAbi, err = eth.ParseAbi(abiStr)
|
||||
|
||||
return err
|
||||
}
|
||||
|
@ -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/parser"
|
||||
"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() {
|
||||
@ -44,7 +44,7 @@ var _ = Describe("Parser", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
parsedAbi := mp.ParsedAbi()
|
||||
expectedAbi, err := geth.ParseAbi(constants.DaiAbiString)
|
||||
expectedAbi, err := eth.ParseAbi(constants.DaiAbiString)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(parsedAbi).To(Equal(expectedAbi))
|
||||
|
||||
@ -73,7 +73,7 @@ var _ = Describe("Parser", func() {
|
||||
expectedAbi := constants.DaiAbiString
|
||||
Expect(p.Abi()).To(Equal(expectedAbi))
|
||||
|
||||
expectedParsedAbi, err := geth.ParseAbi(expectedAbi)
|
||||
expectedParsedAbi, err := eth.ParseAbi(expectedAbi)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(p.ParsedAbi()).To(Equal(expectedParsedAbi))
|
||||
})
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"context"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
||||
)
|
||||
|
||||
type RpcClient interface {
|
||||
|
@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
package geth
|
||||
package eth
|
||||
|
||||
import (
|
||||
"errors"
|
@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
package geth_test
|
||||
package eth_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@ -25,7 +25,7 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/ghttp"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
@ -36,7 +36,7 @@ var _ = Describe("ABI files", func() {
|
||||
It("loads a valid ABI file", func() {
|
||||
path := test_config.ABIFilePath + "valid_abi.json"
|
||||
|
||||
contractAbi, err := geth.ParseAbiFile(path)
|
||||
contractAbi, err := eth.ParseAbiFile(path)
|
||||
|
||||
Expect(contractAbi).NotTo(BeNil())
|
||||
Expect(err).To(BeNil())
|
||||
@ -45,7 +45,7 @@ var _ = Describe("ABI files", func() {
|
||||
It("reads the contents of a valid ABI file", func() {
|
||||
path := test_config.ABIFilePath + "valid_abi.json"
|
||||
|
||||
contractAbi, err := geth.ReadAbiFile(path)
|
||||
contractAbi, err := eth.ReadAbiFile(path)
|
||||
|
||||
Expect(contractAbi).To(Equal("[{\"foo\": \"bar\"}]"))
|
||||
Expect(err).To(BeNil())
|
||||
@ -54,38 +54,38 @@ var _ = Describe("ABI files", func() {
|
||||
It("returns an error when the file does not exist", func() {
|
||||
path := test_config.ABIFilePath + "missing_abi.json"
|
||||
|
||||
contractAbi, err := geth.ParseAbiFile(path)
|
||||
contractAbi, err := eth.ParseAbiFile(path)
|
||||
|
||||
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() {
|
||||
path := test_config.ABIFilePath + "invalid_abi.json"
|
||||
|
||||
contractAbi, err := geth.ParseAbiFile(path)
|
||||
contractAbi, err := eth.ParseAbiFile(path)
|
||||
|
||||
Expect(contractAbi).To(Equal(abi.ABI{}))
|
||||
Expect(err).To(Equal(geth.ErrInvalidAbiFile))
|
||||
Expect(err).To(Equal(eth.ErrInvalidAbiFile))
|
||||
})
|
||||
|
||||
Describe("Request ABI from endpoint", func() {
|
||||
|
||||
var (
|
||||
server *ghttp.Server
|
||||
client *geth.EtherScanAPI
|
||||
client *eth.EtherScanAPI
|
||||
abiString string
|
||||
err error
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
server = ghttp.NewServer()
|
||||
client = geth.NewEtherScanClient(server.URL())
|
||||
client = eth.NewEtherScanClient(server.URL())
|
||||
path := test_config.ABIFilePath + "sample_abi.json"
|
||||
abiString, err = geth.ReadAbiFile(path)
|
||||
abiString, err = eth.ReadAbiFile(path)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, err = geth.ParseAbi(abiString)
|
||||
_, err = eth.ParseAbi(abiString)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -117,14 +117,14 @@ var _ = Describe("ABI files", func() {
|
||||
|
||||
Describe("Generating etherscan endpoints based on network", 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"))
|
||||
})
|
||||
|
||||
It("generates various test network endpoint if test network is supplied", func() {
|
||||
ropstenUrl := geth.GenURL("ropsten")
|
||||
rinkebyUrl := geth.GenURL("rinkeby")
|
||||
kovanUrl := geth.GenURL("kovan")
|
||||
ropstenUrl := eth.GenURL("ropsten")
|
||||
rinkebyUrl := eth.GenURL("rinkeby")
|
||||
kovanUrl := eth.GenURL("kovan")
|
||||
|
||||
Expect(ropstenUrl).To(Equal("https://ropsten.etherscan.io"))
|
||||
Expect(kovanUrl).To(Equal("https://kovan.etherscan.io"))
|
@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
package geth
|
||||
package eth
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@ -28,8 +28,8 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
||||
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
|
||||
)
|
||||
|
||||
var ErrEmptyHeader = errors.New("empty header returned over RPC")
|
@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
package geth_test
|
||||
package eth_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -29,14 +29,14 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
vulcCore "github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
)
|
||||
|
||||
var _ = Describe("Geth blockchain", func() {
|
||||
var (
|
||||
mockClient *fakes.MockEthClient
|
||||
blockChain *geth.BlockChain
|
||||
blockChain *eth.BlockChain
|
||||
mockRpcClient *fakes.MockRpcClient
|
||||
mockTransactionConverter *fakes.MockTransactionConverter
|
||||
node vulcCore.Node
|
||||
@ -47,7 +47,7 @@ var _ = Describe("Geth blockchain", func() {
|
||||
mockRpcClient = fakes.NewMockRpcClient()
|
||||
mockTransactionConverter = fakes.NewMockTransactionConverter()
|
||||
node = vulcCore.Node{}
|
||||
blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, mockTransactionConverter)
|
||||
blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, mockTransactionConverter)
|
||||
})
|
||||
|
||||
Describe("getting a block", func() {
|
||||
@ -105,7 +105,7 @@ var _ = Describe("Geth blockchain", func() {
|
||||
node.NetworkID = vulcCore.KOVAN_NETWORK_ID
|
||||
blockNumber := hexutil.Big(*big.NewInt(100))
|
||||
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)
|
||||
|
||||
@ -116,7 +116,7 @@ var _ = Describe("Geth blockchain", func() {
|
||||
It("returns err if rpcClient returns err", func() {
|
||||
node.NetworkID = vulcCore.KOVAN_NETWORK_ID
|
||||
mockRpcClient.SetCallContextErr(fakes.FakeError)
|
||||
blockChain = geth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter())
|
||||
blockChain = eth.NewBlockChain(mockClient, mockRpcClient, node, fakes.NewMockTransactionConverter())
|
||||
|
||||
_, err := blockChain.GetHeaderByNumber(100)
|
||||
|
||||
@ -126,12 +126,12 @@ var _ = Describe("Geth blockchain", func() {
|
||||
|
||||
It("returns error if returned header is empty", func() {
|
||||
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)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(geth.ErrEmptyHeader))
|
||||
Expect(err).To(MatchError(eth.ErrEmptyHeader))
|
||||
})
|
||||
|
||||
It("returns multiple headers with multiple blocknumbers", func() {
|
@ -19,7 +19,7 @@ package cold_import
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
"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 {
|
@ -21,9 +21,9 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"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/geth/cold_import"
|
||||
vulcCommon "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common"
|
||||
)
|
||||
|
||||
var _ = Describe("Geth cold importer", func() {
|
@ -21,8 +21,8 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/cold_import"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/cold_import"
|
||||
)
|
||||
|
||||
var _ = Describe("Cold importer node builder", func() {
|
@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
package geth
|
||||
package eth
|
||||
|
||||
import (
|
||||
"context"
|
@ -29,9 +29,9 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "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"
|
||||
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() {
|
@ -26,7 +26,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"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() {
|
@ -26,8 +26,8 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
common2 "github.com/vulcanize/vulcanizedb/pkg/eth/converters/common"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
common2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/common"
|
||||
)
|
||||
|
||||
var _ = Describe("Block header converter", func() {
|
@ -25,7 +25,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"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() {
|
@ -31,7 +31,7 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"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 {
|
@ -20,8 +20,8 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"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/geth/converters/rpc"
|
||||
)
|
||||
|
||||
var _ = Describe("RPC transaction converter", func() {
|
@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
package geth_test
|
||||
package eth_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
@ -25,5 +25,5 @@ import (
|
||||
|
||||
func TestGeth(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Geth Suite")
|
||||
RunSpecs(t, "eth Suite")
|
||||
}
|
@ -23,8 +23,8 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/node"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
|
||||
)
|
||||
|
||||
var EmpytHeaderHash = "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
|
@ -20,7 +20,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
@ -32,7 +32,7 @@ func SampleContract() core.Contract {
|
||||
}
|
||||
|
||||
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 {
|
||||
log.Fatal(err)
|
||||
}
|
@ -25,7 +25,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
||||
)
|
||||
|
||||
type MockEthClient struct {
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth/client"
|
||||
)
|
||||
|
||||
type MockRpcClient struct {
|
||||
|
@ -91,7 +91,7 @@ func setInfuraConfig() {
|
||||
|
||||
func setABIPath() {
|
||||
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 {
|
||||
|
@ -18,7 +18,7 @@ package utils
|
||||
|
||||
import (
|
||||
"github.com/jmoiron/sqlx"
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
"math/big"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -26,7 +26,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/config"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"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 {
|
||||
@ -39,7 +39,7 @@ func LoadPostgres(database config.Database, node core.Node) postgres.DB {
|
||||
|
||||
func ReadAbiFile(abiFilepath string) string {
|
||||
abiFilepath = AbsFilePath(abiFilepath)
|
||||
abi, err := geth.ReadAbiFile(abiFilepath)
|
||||
abi, err := eth.ReadAbiFile(abiFilepath)
|
||||
if err != nil {
|
||||
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 != "" {
|
||||
contractAbiString = ReadAbiFile(abiFilepath)
|
||||
} else {
|
||||
url := geth.GenURL(network)
|
||||
etherscan := geth.NewEtherScanClient(url)
|
||||
url := eth.GenURL(network)
|
||||
etherscan := eth.NewEtherScanClient(url)
|
||||
logrus.Printf("No ABI supplied. Retrieving ABI from Etherscan: %s", url)
|
||||
contractAbiString, _ = etherscan.GetAbi(contractHash)
|
||||
}
|
||||
_, err := geth.ParseAbi(contractAbiString)
|
||||
_, err := eth.ParseAbi(contractAbiString)
|
||||
if err != nil {
|
||||
logrus.Fatalln("Invalid ABI: ", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user