forked from cerc-io/ipld-eth-server
Use testing.toml and vulcanize_testing in tests
- remove legacy references to infura.toml and vulcanize_private
This commit is contained in:
parent
92650f0981
commit
234fff83c5
@ -13,9 +13,6 @@ before_install:
|
||||
- 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
|
||||
- sudo apt-get update && sudo apt-get install yarn
|
||||
before_script:
|
||||
- sudo -u postgres createdb vulcanize_private
|
||||
- make migrate NAME=vulcanize_private
|
||||
script:
|
||||
- env GO111MODULE=on make test
|
||||
- env GO111MODULE=on make integrationtest
|
||||
|
@ -135,12 +135,12 @@ build and run custom transformers as Go plugins can be found
|
||||
|
||||
|
||||
### 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
|
||||
- `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 integrationtest` will run just the integration tests
|
||||
- `make test` and `make integrationtest` setup a clean `vulcanize_testing` db
|
||||
|
||||
|
||||
## Contributing
|
||||
|
@ -1,5 +1,5 @@
|
||||
[database]
|
||||
name = "vulcanize_private"
|
||||
name = "vulcanize_testing"
|
||||
hostname = "localhost"
|
||||
port = 5432
|
||||
|
||||
|
@ -32,9 +32,9 @@ import (
|
||||
var _ = Describe("Rewards calculations", 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())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath)
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
@ -46,9 +46,9 @@ var _ = Describe("Rewards calculations", 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())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath)
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
|
@ -49,9 +49,9 @@ var _ = Describe("Reading contracts", func() {
|
||||
},
|
||||
Index: 19,
|
||||
Data: "0x0000000000000000000000000000000000000000000000000c7d713b49da0000"}
|
||||
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath)
|
||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath)
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
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() {
|
||||
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath)
|
||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath)
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
@ -85,9 +85,9 @@ var _ = Describe("Reading contracts", func() {
|
||||
|
||||
Describe("Fetching Contract data", 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())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath)
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
|
@ -37,9 +37,9 @@ var _ = Describe("Reading from the Geth blockchain", func() {
|
||||
var blockChain *eth.BlockChain
|
||||
|
||||
BeforeEach(func() {
|
||||
rawRpcClient, err := rpc.Dial(test_config.InfuraClient.IPCPath)
|
||||
rawRpcClient, err := rpc.Dial(test_config.TestClient.IPCPath)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.InfuraClient.IPCPath)
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, test_config.TestClient.IPCPath)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
|
@ -35,12 +35,12 @@ var _ = Describe("Interface Getter", func() {
|
||||
Describe("GetAbi", 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 + `]`
|
||||
con := test_config.InfuraClient
|
||||
infuraIPC := con.IPCPath
|
||||
con := test_config.TestClient
|
||||
testIPC := con.IPCPath
|
||||
blockNumber := int64(6885696)
|
||||
rawRpcClient, err := rpc.Dial(infuraIPC)
|
||||
rawRpcClient, err := rpc.Dial(testIPC)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, testIPC)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
|
@ -108,11 +108,11 @@ type Owner struct {
|
||||
}
|
||||
|
||||
func SetupDBandBC() (*postgres.DB, core.BlockChain) {
|
||||
con := test_config.InfuraClient
|
||||
infuraIPC := con.IPCPath
|
||||
rawRpcClient, err := rpc.Dial(infuraIPC)
|
||||
con := test_config.TestClient
|
||||
testIPC := con.IPCPath
|
||||
rawRpcClient, err := rpc.Dial(testIPC)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, testIPC)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
madeNode := node.MakeNode(rpcClient)
|
||||
@ -121,7 +121,7 @@ func SetupDBandBC() (*postgres.DB, core.BlockChain) {
|
||||
|
||||
db, err := postgres.NewDB(config.Database{
|
||||
Hostname: "localhost",
|
||||
Name: "vulcanize_private",
|
||||
Name: "vulcanize_testing",
|
||||
Port: 5432,
|
||||
}, blockChain.Node())
|
||||
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) {
|
||||
db, err := postgres.NewDB(config.Database{
|
||||
Hostname: "localhost",
|
||||
Name: "vulcanize_private",
|
||||
Name: "vulcanize_testing",
|
||||
Port: 5432,
|
||||
}, core.Node{})
|
||||
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) {
|
||||
db, err := postgres.NewDB(config.Database{
|
||||
Hostname: "localhost",
|
||||
Name: "vulcanize_private",
|
||||
Name: "vulcanize_testing",
|
||||
Port: 5432,
|
||||
}, core.Node{})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -32,13 +32,10 @@ import (
|
||||
var TestConfig *viper.Viper
|
||||
var DBConfig config.Database
|
||||
var TestClient config.Client
|
||||
var Infura *viper.Viper
|
||||
var InfuraClient config.Client
|
||||
var ABIFilePath string
|
||||
|
||||
func init() {
|
||||
setTestConfig()
|
||||
setInfuraConfig()
|
||||
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() {
|
||||
gp := os.Getenv("GOPATH")
|
||||
ABIFilePath = gp + "/src/github.com/vulcanize/vulcanizedb/pkg/eth/testing/"
|
||||
|
Loading…
Reference in New Issue
Block a user