Add instructions to run integration tests
This commit is contained in:
parent
9181d24514
commit
5a038317bc
6
Makefile
6
Makefile
@ -20,12 +20,6 @@ test: | $(GINKGO) $(GOOSE)
|
|||||||
go fmt ./...
|
go fmt ./...
|
||||||
$(GINKGO) -r validator_test/ -v
|
$(GINKGO) -r validator_test/ -v
|
||||||
|
|
||||||
.PHONY: integrationtest_local
|
|
||||||
integrationtest_local: | $(GINKGO) $(GOOSE)
|
|
||||||
go vet ./...
|
|
||||||
go fmt ./...
|
|
||||||
./scripts/run_integration_test.sh
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
GO111MODULE=on go build
|
GO111MODULE=on go build
|
||||||
|
@ -31,11 +31,7 @@ We must consider the following edge cases for the validator.
|
|||||||
|
|
||||||
# Instructions for Testing
|
# Instructions for Testing
|
||||||
|
|
||||||
To run the test, do the following:
|
Follow steps in [test/README.md](./test/README.md)
|
||||||
|
|
||||||
1. Make sure `GOPATH` is set in your `~/.bashrc` or `~/.bash_profile`: `export GOPATH=$(go env GOPATH)`
|
|
||||||
2. `./scripts/run_unit_test.sh`
|
|
||||||
3. `./scripts/run_integration_test.sh`
|
|
||||||
|
|
||||||
# Code Overview
|
# Code Overview
|
||||||
|
|
||||||
|
@ -1,36 +1,6 @@
|
|||||||
version: '3.2'
|
version: '3.2'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
contract:
|
|
||||||
depends_on:
|
|
||||||
- dapptools
|
|
||||||
build:
|
|
||||||
context: ./test/contract
|
|
||||||
args:
|
|
||||||
ETH_ADDR: "http://dapptools:8545"
|
|
||||||
environment:
|
|
||||||
ETH_ADDR: "http://dapptools:8545"
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:3000:3000"
|
|
||||||
|
|
||||||
dapptools:
|
|
||||||
restart: unless-stopped
|
|
||||||
depends_on:
|
|
||||||
- ipld-eth-db
|
|
||||||
image: vulcanize/dapptools:v0.30.0-v1.10.16-statediff-3.0.2a
|
|
||||||
environment:
|
|
||||||
DB_USER: vdbm
|
|
||||||
DB_NAME: vulcanize_testing
|
|
||||||
DB_HOST: ipld-eth-db
|
|
||||||
DB_PORT: 5432
|
|
||||||
DB_PASSWORD: password
|
|
||||||
DB_WRITE: $DB_WRITE
|
|
||||||
DB_TYPE: postgres
|
|
||||||
DB_DRIVER: sqlx
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:8545:8545"
|
|
||||||
- "127.0.0.1:8546:8546"
|
|
||||||
|
|
||||||
ipld-eth-db:
|
ipld-eth-db:
|
||||||
restart: always
|
restart: always
|
||||||
image: vulcanize/ipld-eth-db:v3.2.0
|
image: vulcanize/ipld-eth-db:v3.2.0
|
||||||
|
@ -24,7 +24,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var IntegrationTestChainConfig = ¶ms.ChainConfig{
|
var IntegrationTestChainConfig = ¶ms.ChainConfig{
|
||||||
ChainID: big.NewInt(4),
|
ChainID: big.NewInt(99),
|
||||||
HomesteadBlock: big.NewInt(0),
|
HomesteadBlock: big.NewInt(0),
|
||||||
EIP150Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
EIP155Block: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
|
@ -1,17 +1,6 @@
|
|||||||
set -e
|
set -e
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
|
||||||
export ETH_FORWARD_ETH_CALLS=false
|
|
||||||
export DB_WRITE=true
|
|
||||||
export ETH_HTTP_PATH=""
|
|
||||||
export ETH_PROXY_ON_ERROR=false
|
|
||||||
|
|
||||||
# Clear up existing docker images and volume.
|
|
||||||
docker-compose down --remove-orphans --volumes
|
|
||||||
|
|
||||||
# Build and start the containers.
|
|
||||||
docker-compose -f docker-compose.yml up -d ipld-eth-db dapptools contract
|
|
||||||
|
|
||||||
export PGPASSWORD=password
|
export PGPASSWORD=password
|
||||||
export DATABASE_USER=vdbm
|
export DATABASE_USER=vdbm
|
||||||
export DATABASE_PORT=8077
|
export DATABASE_PORT=8077
|
||||||
|
80
test/README.md
Normal file
80
test/README.md
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
# Test Insructions
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
- For running integration tests:
|
||||||
|
|
||||||
|
- Clone [stack-orchestrator](https://github.com/vulcanize/stack-orchestrator) and [go-ethereum](https://github.com/vulcanize/go-ethereum) repositories.
|
||||||
|
|
||||||
|
- Checkout [v3 release](https://github.com/vulcanize/go-ethereum/releases/tag/v1.10.17-statediff-3.2.1) in go-ethereum repo.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# In go-ethereum repo.
|
||||||
|
git checkout v1.10.17-statediff-3.2.1
|
||||||
|
```
|
||||||
|
|
||||||
|
- Checkout working commit in stack-orchestrator repo.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# In stack-orchestrator repo.
|
||||||
|
git checkout 3bb1796a59827fb755410c5ce69fac567a0f832b
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run
|
||||||
|
|
||||||
|
- Run unit tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# In ipld-eth-db-validator root directory.
|
||||||
|
./scripts/run_unit_test.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- Run integration tests:
|
||||||
|
|
||||||
|
- In stack-orchestrator repo:
|
||||||
|
|
||||||
|
- Create config file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd helper-scripts
|
||||||
|
|
||||||
|
./create-config.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
A `config.sh` will be created in the root directory.
|
||||||
|
|
||||||
|
- Update/Edit the config file `config.sh`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Path to go-ethereum repo.
|
||||||
|
vulcanize_go_ethereum=~/go-ethereum
|
||||||
|
|
||||||
|
# Path to contract folder.
|
||||||
|
vulcanize_test_contract=~/ipld-eth-db-validator/test/contract
|
||||||
|
|
||||||
|
db_write=true
|
||||||
|
```
|
||||||
|
|
||||||
|
- Run stack-orchestrator:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# In stack-orchestrator root directory.
|
||||||
|
cd helper-scripts
|
||||||
|
|
||||||
|
./wrapper.sh \
|
||||||
|
-e docker \
|
||||||
|
-d ../docker/latest/docker-compose-db.yml \
|
||||||
|
-d ../docker/local/docker-compose-go-ethereum.yml \
|
||||||
|
-d ../docker/local/docker-compose-contract.yml \
|
||||||
|
-v remove \
|
||||||
|
-p ../config.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- Run tests:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# In ipld-eth-db-validator root directory.
|
||||||
|
./scripts/run_integration_test.sh
|
||||||
|
```
|
@ -21,11 +21,11 @@ module.exports = {
|
|||||||
networks: {
|
networks: {
|
||||||
local: {
|
local: {
|
||||||
url: 'http://127.0.0.1:8545',
|
url: 'http://127.0.0.1:8545',
|
||||||
chainId: 4
|
chainId: 99
|
||||||
},
|
},
|
||||||
docker: {
|
docker: {
|
||||||
url: process.env.ETH_ADDR,
|
url: process.env.ETH_ADDR,
|
||||||
chainId: 4
|
chainId: 99
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -2,8 +2,6 @@ package integration_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
@ -18,10 +16,6 @@ import (
|
|||||||
const trail = 0
|
const trail = 0
|
||||||
|
|
||||||
var _ = Describe("Integration test", func() {
|
var _ = Describe("Integration test", func() {
|
||||||
directProxyEthCalls, err := strconv.ParseBool(os.Getenv("ETH_FORWARD_ETH_CALLS"))
|
|
||||||
Expect(err).To(BeNil())
|
|
||||||
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
var contract *integration.ContractDeployed
|
var contract *integration.ContractDeployed
|
||||||
@ -30,9 +24,10 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
Describe("Validate state", func() {
|
Describe("Validate state", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
if directProxyEthCalls {
|
// Deploy a dummy contract as the first contract might get deployed at block number 0
|
||||||
Skip("skipping no-direct-proxy-forwarding integration tests")
|
_, _ = integration.DeployContract()
|
||||||
}
|
time.Sleep(sleepInterval)
|
||||||
|
|
||||||
contract, contractErr = integration.DeployContract()
|
contract, contractErr = integration.DeployContract()
|
||||||
time.Sleep(sleepInterval)
|
time.Sleep(sleepInterval)
|
||||||
})
|
})
|
||||||
@ -42,7 +37,7 @@ var _ = Describe("Integration test", func() {
|
|||||||
|
|
||||||
db := shared.SetupDB()
|
db := shared.SetupDB()
|
||||||
srvc := validator.NewService(db, uint64(contract.BlockNumber), trail, validator.IntegrationTestChainConfig)
|
srvc := validator.NewService(db, uint64(contract.BlockNumber), trail, validator.IntegrationTestChainConfig)
|
||||||
_, err = srvc.Start(ctx)
|
_, err := srvc.Start(ctx)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user