Use testing.toml and vulcanize_testing in tests

- remove legacy references to infura.toml and vulcanize_private
This commit is contained in:
Rob Mulholand 2019-10-31 11:19:34 -05:00
parent 92650f0981
commit 234fff83c5
9 changed files with 27 additions and 57 deletions

View File

@ -13,9 +13,6 @@ before_install:
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
- echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- sudo apt-get update && sudo apt-get install yarn - sudo apt-get update && sudo apt-get install yarn
before_script:
- sudo -u postgres createdb vulcanize_private
- make migrate NAME=vulcanize_private
script: script:
- env GO111MODULE=on make test - env GO111MODULE=on make test
- env GO111MODULE=on make integrationtest - env GO111MODULE=on make integrationtest

View File

@ -135,12 +135,12 @@ build and run custom transformers as Go plugins can be found
### Tests ### Tests
- Replace the empty `ipcPath` in the `environments/infura.toml` with a path to a full node's eth_jsonrpc endpoint (e.g. local geth node ipc path or infura url) - Replace the empty `ipcPath` in the `environments/testing.toml` with a path to a full node's eth_jsonrpc endpoint (e.g. local geth node ipc path or infura url)
- Note: must be mainnet
- Note: integration tests require configuration with an archival node - Note: integration tests require configuration with an archival node
- `createdb vulcanize_private` will create the test db
- `make migrate NAME=vulcanize_private` will run the db migrations
- `make test` will run the unit tests and skip the integration tests - `make test` will run the unit tests and skip the integration tests
- `make integrationtest` will run just the integration tests - `make integrationtest` will run just the integration tests
- `make test` and `make integrationtest` setup a clean `vulcanize_testing` db
## Contributing ## Contributing

View File

@ -1,5 +1,5 @@
[database] [database]
name = "vulcanize_private" name = "vulcanize_testing"
hostname = "localhost" hostname = "localhost"
port = 5432 port = 5432

View File

@ -32,9 +32,9 @@ import (
var _ = Describe("Rewards calculations", func() { var _ = Describe("Rewards calculations", func() {
It("calculates a block reward for a real block", func() { It("calculates a block reward for a real block", func() {
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath) rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath) rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
@ -46,9 +46,9 @@ var _ = Describe("Rewards calculations", func() {
}) })
It("calculates an uncle reward for a real block", func() { It("calculates an uncle reward for a real block", func() {
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath) rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath) rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)

View File

@ -49,9 +49,9 @@ var _ = Describe("Reading contracts", func() {
}, },
Index: 19, Index: 19,
Data: "0x0000000000000000000000000000000000000000000000000c7d713b49da0000"} Data: "0x0000000000000000000000000000000000000000000000000c7d713b49da0000"}
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath) rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath) rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
@ -67,9 +67,9 @@ var _ = Describe("Reading contracts", func() {
}) })
It("returns and empty log array when no events for a given block / contract combo", func() { It("returns and empty log array when no events for a given block / contract combo", func() {
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath) rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath) rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)
@ -85,9 +85,9 @@ var _ = Describe("Reading contracts", func() {
Describe("Fetching Contract data", func() { Describe("Fetching Contract data", func() {
It("returns the correct attribute for a real contract", func() { It("returns the correct attribute for a real contract", func() {
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath) rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath) rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)

View File

@ -37,9 +37,9 @@ var _ = Describe("Reading from the Geth blockchain", func() {
var blockChain *eth.BlockChain var blockChain *eth.BlockChain
BeforeEach(func() { BeforeEach(func() {
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath) rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath) rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)

View File

@ -35,12 +35,12 @@ var _ = Describe("Interface Getter", func() {
Describe("GetAbi", func() { Describe("GetAbi", func() {
It("Constructs and returns a custom abi based on results from supportsInterface calls", func() { It("Constructs and returns a custom abi based on results from supportsInterface calls", func() {
expectedABI := `[` + constants.AddrChangeInterface + `,` + constants.NameChangeInterface + `,` + constants.ContentChangeInterface + `,` + constants.AbiChangeInterface + `,` + constants.PubkeyChangeInterface + `]` expectedABI := `[` + constants.AddrChangeInterface + `,` + constants.NameChangeInterface + `,` + constants.ContentChangeInterface + `,` + constants.AbiChangeInterface + `,` + constants.PubkeyChangeInterface + `]`
con := test_config.InfuraClient con := test_config.TestClient
infuraIPC := con.IPCPath testIPC := con.IPCPath
blockNumber := int64(6885696) blockNumber := int64(6885696)
rawRpcClient, err := rpc.Dial(infuraIPC) rawRpcClient, err := rpc.Dial(testIPC)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC) rpcClient := client.NewRpcClient(rawRpcClient, testIPC)
ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
node := node.MakeNode(rpcClient) node := node.MakeNode(rpcClient)

View File

@ -108,11 +108,11 @@ type Owner struct {
} }
func SetupDBandBC() (*postgres.DB, core.BlockChain) { func SetupDBandBC() (*postgres.DB, core.BlockChain) {
con := test_config.InfuraClient con := test_config.TestClient
infuraIPC := con.IPCPath testIPC := con.IPCPath
rawRpcClient, err := rpc.Dial(infuraIPC) rawRpcClient, err := rpc.Dial(testIPC)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC) rpcClient := client.NewRpcClient(rawRpcClient, testIPC)
ethClient := ethclient.NewClient(rawRpcClient) ethClient := ethclient.NewClient(rawRpcClient)
blockChainClient := client.NewEthClient(ethClient) blockChainClient := client.NewEthClient(ethClient)
madeNode := node.MakeNode(rpcClient) madeNode := node.MakeNode(rpcClient)
@ -121,7 +121,7 @@ func SetupDBandBC() (*postgres.DB, core.BlockChain) {
db, err := postgres.NewDB(config.Database{ db, err := postgres.NewDB(config.Database{
Hostname: "localhost", Hostname: "localhost",
Name: "vulcanize_private", Name: "vulcanize_testing",
Port: 5432, Port: 5432,
}, blockChain.Node()) }, blockChain.Node())
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
@ -132,7 +132,7 @@ func SetupDBandBC() (*postgres.DB, core.BlockChain) {
func SetupTusdRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) { func SetupTusdRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) {
db, err := postgres.NewDB(config.Database{ db, err := postgres.NewDB(config.Database{
Hostname: "localhost", Hostname: "localhost",
Name: "vulcanize_private", Name: "vulcanize_testing",
Port: 5432, Port: 5432,
}, core.Node{}) }, core.Node{})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
@ -178,7 +178,7 @@ func SetupTusdContract(wantedEvents, wantedMethods []string) *contract.Contract
func SetupENSRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) { func SetupENSRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) {
db, err := postgres.NewDB(config.Database{ db, err := postgres.NewDB(config.Database{
Hostname: "localhost", Hostname: "localhost",
Name: "vulcanize_private", Name: "vulcanize_testing",
Port: 5432, Port: 5432,
}, core.Node{}) }, core.Node{})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())

View File

@ -32,13 +32,10 @@ import (
var TestConfig *viper.Viper var TestConfig *viper.Viper
var DBConfig config.Database var DBConfig config.Database
var TestClient config.Client var TestClient config.Client
var Infura *viper.Viper
var InfuraClient config.Client
var ABIFilePath string var ABIFilePath string
func init() { func init() {
setTestConfig() setTestConfig()
setInfuraConfig()
setABIPath() setABIPath()
} }
@ -75,30 +72,6 @@ func setTestConfig() {
} }
} }
func setInfuraConfig() {
Infura = viper.New()
Infura.SetConfigName("infura")
Infura.AddConfigPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/environments/")
err := Infura.ReadInConfig()
if err != nil {
logrus.Fatal(err)
}
ipc := Infura.GetString("client.ipcpath")
// If we don't have an ipc path in the config file, check the env variable
if ipc == "" {
Infura.BindEnv("url", "INFURA_URL")
ipc = Infura.GetString("url")
}
if ipc == "" {
logrus.Fatal(errors.New("infura.toml IPC path or $INFURA_URL env variable need to be set"))
}
InfuraClient = config.Client{
IPCPath: ipc,
}
}
func setABIPath() { func setABIPath() {
gp := os.Getenv("GOPATH") gp := os.Getenv("GOPATH")
ABIFilePath = gp + "/src/github.com/vulcanize/vulcanizedb/pkg/eth/testing/" ABIFilePath = gp + "/src/github.com/vulcanize/vulcanizedb/pkg/eth/testing/"