Add instructions to run integration tests

This commit is contained in:
Prathamesh Musale 2022-05-20 16:47:02 +05:30
parent 9181d24514
commit 5a038317bc
8 changed files with 89 additions and 65 deletions

View File

@ -20,12 +20,6 @@ test: | $(GINKGO) $(GOOSE)
go fmt ./...
$(GINKGO) -r validator_test/ -v
.PHONY: integrationtest_local
integrationtest_local: | $(GINKGO) $(GOOSE)
go vet ./...
go fmt ./...
./scripts/run_integration_test.sh
build:
go fmt ./...
GO111MODULE=on go build

View File

@ -31,11 +31,7 @@ We must consider the following edge cases for the validator.
# Instructions for Testing
To run the test, do the following:
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`
Follow steps in [test/README.md](./test/README.md)
# Code Overview

View File

@ -1,36 +1,6 @@
version: '3.2'
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:
restart: always
image: vulcanize/ipld-eth-db:v3.2.0

View File

@ -24,7 +24,7 @@ var (
)
var IntegrationTestChainConfig = &params.ChainConfig{
ChainID: big.NewInt(4),
ChainID: big.NewInt(99),
HomesteadBlock: big.NewInt(0),
EIP150Block: big.NewInt(0),
EIP155Block: big.NewInt(0),

View File

@ -1,17 +1,6 @@
set -e
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 DATABASE_USER=vdbm
export DATABASE_PORT=8077

80
test/README.md Normal file
View 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
```

View File

@ -21,11 +21,11 @@ module.exports = {
networks: {
local: {
url: 'http://127.0.0.1:8545',
chainId: 4
chainId: 99
},
docker: {
url: process.env.ETH_ADDR,
chainId: 4
chainId: 99
}
}
};

View File

@ -2,8 +2,6 @@ package integration_test
import (
"context"
"os"
"strconv"
"time"
. "github.com/onsi/ginkgo"
@ -18,10 +16,6 @@ import (
const trail = 0
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()
var contract *integration.ContractDeployed
@ -30,9 +24,10 @@ var _ = Describe("Integration test", func() {
Describe("Validate state", func() {
BeforeEach(func() {
if directProxyEthCalls {
Skip("skipping no-direct-proxy-forwarding integration tests")
}
// Deploy a dummy contract as the first contract might get deployed at block number 0
_, _ = integration.DeployContract()
time.Sleep(sleepInterval)
contract, contractErr = integration.DeployContract()
time.Sleep(sleepInterval)
})
@ -42,7 +37,7 @@ var _ = Describe("Integration test", func() {
db := shared.SetupDB()
srvc := validator.NewService(db, uint64(contract.BlockNumber), trail, validator.IntegrationTestChainConfig)
_, err = srvc.Start(ctx)
_, err := srvc.Start(ctx)
Expect(err).ToNot(HaveOccurred())
})
})