update from PR feedback

This commit is contained in:
Taka Goto 2018-08-31 10:37:02 -05:00
parent adc7c47244
commit 415ec3d97c
5 changed files with 65 additions and 49 deletions

View File

@ -28,8 +28,7 @@ Vulcanize DB is a set of tools that make it easier for developers to write appli
* See below for configuring additional environments * See below for configuring additional environments
## Create a migration file (up and down) ## Create a migration file (up and down)
1. install migrate library: https://github.com/golang-migrate/migrate 1. ./script/create_migrate create_bite_table
1. `migrate create -ext sql -seq -dir db/migrations/ -digits 10 create_bite_table`
## Configuration ## Configuration
- To use a local Ethereum node, copy `environments/public.toml.example` to - To use a local Ethereum node, copy `environments/public.toml.example` to

View File

@ -17,8 +17,8 @@
package bite_test package bite_test
import ( import (
"math/big"
"encoding/json" "encoding/json"
"math/big"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/bite" "github.com/vulcanize/vulcanizedb/pkg/transformers/bite"

View File

@ -17,53 +17,67 @@
package bite_test package bite_test
import ( import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/ethereum/go-ethereum/rpc"
"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/transformers/bite"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
"github.com/vulcanize/vulcanizedb/test_config"
) )
var _ = Describe("Integration tests", func() { var _ = Describe("Integration tests", func() {
//It("Fetches bite event logs from a local test chain", func() { XIt("Fetches bite event logs from a local test chain", func() {
// ipcPath := test_config.TestClient.IPCPath ipcPath := test_config.TestClient.IPCPath
//
// rawRpcClient, err := rpc.Dial(ipcPath) rawRpcClient, err := rpc.Dial(ipcPath)
// Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
//
// rpcClient := client.NewRpcClient(rawRpcClient, ipcPath) rpcClient := client.NewRpcClient(rawRpcClient, ipcPath)
// ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
// blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
// realNode := node.MakeNode(rpcClient) realNode := node.MakeNode(rpcClient)
// transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
// realBlockChain := geth.NewBlockChain(blockChainClient, realNode, transactionConverter) realBlockChain := geth.NewBlockChain(blockChainClient, realNode, transactionConverter)
// realFetcher := shared.NewFetcher(realBlockChain) realFetcher := shared.NewFetcher(realBlockChain)
// topic0 := common.HexToHash(bite.BiteSignature) topic0 := common.HexToHash(bite.BiteSignature)
// topics := [][]common.Hash{{topic0}} topics := [][]common.Hash{{topic0}}
//
// result, err := realFetcher.FetchLogs(test_data.TemporaryBiteAddress, topics, int64(26)) result, err := realFetcher.FetchLogs(test_data.TemporaryBiteAddress, topics, int64(26))
// Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
//
// Expect(len(result) > 0).To(BeTrue()) Expect(len(result) > 0).To(BeTrue())
// Expect(result[0].Address).To(Equal(common.HexToAddress(test_data.TemporaryBiteAddress))) Expect(result[0].Address).To(Equal(common.HexToAddress(test_data.TemporaryBiteAddress)))
// Expect(result[0].TxHash).To(Equal(test_data.EthBiteLog.TxHash)) Expect(result[0].TxHash).To(Equal(test_data.EthBiteLog.TxHash))
// Expect(result[0].BlockNumber).To(Equal(test_data.EthBiteLog.BlockNumber)) Expect(result[0].BlockNumber).To(Equal(test_data.EthBiteLog.BlockNumber))
// Expect(result[0].Topics).To(Equal(test_data.EthBiteLog.Topics)) Expect(result[0].Topics).To(Equal(test_data.EthBiteLog.Topics))
// Expect(result[0].Index).To(Equal(test_data.EthBiteLog.Index)) Expect(result[0].Index).To(Equal(test_data.EthBiteLog.Index))
//}) })
//
//It("unpacks an event log", func() { It("unpacks an event log", func() {
// address := common.HexToAddress(test_data.TemporaryBiteAddress) address := common.HexToAddress(test_data.TemporaryBiteAddress)
// abi, err := geth.ParseAbi(bite.BiteABI) abi, err := geth.ParseAbi(bite.BiteABI)
// Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
//
// contract := bind.NewBoundContract(address, abi, nil, nil, nil) contract := bind.NewBoundContract(address, abi, nil, nil, nil)
// entity := &bite.BiteEntity{} entity := &bite.BiteEntity{}
//
// var eventLog = test_data.EthBiteLog var eventLog = test_data.EthBiteLog
//
// err = contract.UnpackLog(entity, "Bite", eventLog) err = contract.UnpackLog(entity, "Bite", eventLog)
// Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
//
// expectedEntity := test_data.BiteEntity expectedEntity := test_data.BiteEntity
// Expect(entity.Art).To(Equal(expectedEntity.Art)) Expect(entity.Art).To(Equal(expectedEntity.Art))
// Expect(entity.Ilk).To(Equal(expectedEntity.Ilk)) Expect(entity.Ilk).To(Equal(expectedEntity.Ilk))
// Expect(entity.Ink).To(Equal(expectedEntity.Ink)) Expect(entity.Ink).To(Equal(expectedEntity.Ink))
//}) })
}) })

View File

@ -65,7 +65,7 @@ var _ = Describe("Bite repository", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
var anotherBiteModel = bite.BiteModel{ var anotherBiteModel = bite.BiteModel{
Id: "11", Id: "11",
Ilk: test_data.BiteModel.Ilk, Ilk: test_data.BiteModel.Ilk,
Lad: test_data.BiteModel.Lad, Lad: test_data.BiteModel.Lad,
Ink: test_data.BiteModel.Ink, Ink: test_data.BiteModel.Ink,

View File

@ -15,6 +15,7 @@
package transformers package transformers
import ( import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/bite"
"github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick" "github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick"
"github.com/vulcanize/vulcanizedb/pkg/transformers/frob" "github.com/vulcanize/vulcanizedb/pkg/transformers/frob"
"github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds" "github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds"
@ -31,8 +32,10 @@ func TransformerInitializers() []shared.TransformerInitializer {
priceFeedTransformerInitializer := price_feeds.PriceFeedTransformerInitializer{Config: priceFeedConfig} priceFeedTransformerInitializer := price_feeds.PriceFeedTransformerInitializer{Config: priceFeedConfig}
tendConfig := tend.TendConfig tendConfig := tend.TendConfig
tendTransformerInitializer := tend.TendTransformerInitializer{Config: tendConfig} tendTransformerInitializer := tend.TendTransformerInitializer{Config: tendConfig}
biteTransformerInitializer := bite.BiteTransformerInitializer{Config: bite.BiteConfig}
return []shared.TransformerInitializer{ return []shared.TransformerInitializer{
biteTransformerInitializer.NewBiteTransformer,
flipKickTransformerInitializer.NewFlipKickTransformer, flipKickTransformerInitializer.NewFlipKickTransformer,
frobTransformerInitializer.NewFrobTransformer, frobTransformerInitializer.NewFrobTransformer,
priceFeedTransformerInitializer.NewPriceFeedTransformer, priceFeedTransformerInitializer.NewPriceFeedTransformer,