Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

mainnet tests v2 #6

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/on-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,31 @@ jobs:
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://docker.pkg.github.com -u vulcanize --password-stdin
- name: Docker Push
run: docker push docker.pkg.github.com/vulcanize/tracing-api/tracing-api:${{steps.vars.outputs.sha}}

test:
name: Run integration tests
env:
GOPATH: /tmp/go
strategy:
matrix:
go-version: [1.14.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Create GOPATH
run: mkdir -p /tmp/go
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v2
- name: Run services
run: cd test/enviroment/local && docker-compose pull && docker-compose up -d
- name: Checking running containers
run: |
sleep 10 && \
cd test/enviroment/local && \
docker-compose ps -a
- name: Test
run: |
cd test && \
go test -v .
46 changes: 39 additions & 7 deletions .github/workflows/on-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
- uses: actions/checkout@v2
- name: Run docker build
run: make docker-build
test:
name: Run integration tests
testlocal:
name: Run integration tests on local network
env:
GOPATH: /tmp/go
strategy:
Expand All @@ -26,19 +26,51 @@ jobs:
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
# - uses: actions/setup-node@v2
# with:
# node-version: '14'
- uses: actions/checkout@v2
- name: Run services
run: cd test/enviroment && docker-compose pull && docker-compose up -d
run: cd test/enviroment/local && docker-compose pull && docker-compose up -d
- name: Checking running containers
run: |
sleep 10 && \
cd test/enviroment && \
cd test/enviroment/local && \
docker-compose ps -a
- name: Test
run: |
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3000/v1/healthz)" != "200" ]; do echo "wait for contracts being deployed..." && sleep 5; done && \
cd test && \
go test -v .
testmainnet:
name: Run integration tests on mainnet
env:
GOPATH: /tmp/go
strategy:
matrix:
go-version: [1.14.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Create GOPATH
run: mkdir -p /tmp/go
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v2
- name: Run services
run: |
mkdir -p /tmp/a && \
cd test/enviroment/mainnet && \
sed -i 's/%user%/${{secrets.DB_HOST_USER}}/g' ssh/config && \
sed -i 's/%host%/${{secrets.DB_HOST_NAME}}/g' ssh/config && \
echo "${{secrets.SSH_PRIVATE_KEY}}" > ssh/id_rsa_github_actions
cp ssh -r /tmp/a && \
docker-compose pull && docker-compose up -d
- name: Checking running containers
run: |
sleep 10 && \
cd test/enviroment/local && \
docker-compose ps -a
# - name: Test
# run: |
# cd test && \
# go test -v .
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": "graph build",
"create": "graph create --node http://localhost:8020/ vulcanize/bnumstore",
"remove": "graph remove --node http://localhost:8020/ vulcanize/bnumstore",
"deploy": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 vulcanize/bnumstore"
"deploy": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 vulcanize/bnumstore",
"deploy-mainnet": "graph deploy --debug --node https://api.thegraph.com/deploy/ --ipfs https://api.thegraph.com/ipfs/ ramilexe/blocknumstorage"
},
"devDependencies": {
"@graphprotocol/graph-cli": "^0.19.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dataSources:
name: BlockNumStorage
network: mainnet
source:
address: "0xf3f2a4e8F42db8afE4d60cB950720C3fBc559891"
address: "0x51900544dfef84a65f6dbe0c999f88ebe87ba2dd"
abi: BlockNumStorage
mapping:
kind: ethereum/events
Expand All @@ -26,7 +26,7 @@ dataSources:
name: UintStorage
network: mainnet
source:
address: "0xD5AD01A3521a3633eA2D628F000BeF830CE80314"
address: "0xddfe1a03bab27687f49f1864c98ceaf8a26caf2f"
abi: UintStorage
mapping:
kind: ethereum/events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ services:
- vulcanizedb
- tracingdb
build:
context: ../../
dockerfile: ./test/enviroment/tracing-api/Dockerfile
context: ../../../
dockerfile: ./test/enviroment/local/tracing-api/Dockerfile
cache_from:
- alpine:latest
- golang:1.13-alpine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ COPY --from=builder /go/src/github.com/vulcanize/tracing-api/build/tracer-linux
COPY --from=builder /go/src/github.com/pressly/goose/cmd/goose/goose /usr/local/bin/goose
COPY --from=builder /go/src/github.com/vulcanize/tracing-api/startup_script.sh .
COPY --from=builder /go/src/github.com/vulcanize/tracing-api/db/migrations migrations
COPY --from=builder /go/src/github.com/vulcanize/tracing-api/test/enviroment/tracing-api/chain.json .
COPY --from=builder /go/src/github.com/vulcanize/tracing-api/test/enviroment/local/tracing-api/chain.json .

EXPOSE 8080

Expand Down
14 changes: 14 additions & 0 deletions test/enviroment/mainnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Smart Contract being deployed to [mainnet](https://etherscan.io/address/0x51900544dfef84a65f6dbe0c999f88ebe87ba2dd#code)

Update addresses in `subgraph.yaml` to:
* `0x51900544dfef84a65f6dbe0c999f88ebe87ba2dd` for BlockNumStorage
* `0xddfe1a03bab27687f49f1864c98ceaf8a26caf2f` for UintStorage

Add `startBlock: 12056420` to `dataSources[*].source`

### Deploy mainnet subgraph

* `npm i`
* `npm run codegen`
* `npm run build`
* `npm run deploy-mainnet`
52 changes: 52 additions & 0 deletions test/enviroment/mainnet/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: '3.3'

services:
vulcanizedb:
build:
context: ./ssh
volumes:
- /tmp/a:/root/ssh:ro
environment:
TUNNEL_HOST: mainnet-db
REMOTE_HOST: 127.0.0.1
LOCAL_PORT: 5432
REMOTE_PORT: 5432
tracingdb:
restart: always
image: postgres:12.6
environment:
POSTGRES_DB: "tracing"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "pwd"
command: ["postgres", "-cshared_preload_libraries=pg_stat_statements"]
ports:
- "127.0.0.1:5433:5432"
tracing-api:
depends_on:
- vulcanizedb
- tracingdb
build:
context: ../../../
cache_from:
- alpine:latest
- golang:1.13-alpine
environment:
VDB_COMMAND: "serve"
DATABASE_HOSTNAME: vulcanizedb
DATABASE_PORT: 5432
DATABASE_NAME: vulcanize
DATABASE_USER: postgres
DATABASE_PASSWORD: pwd
CACHE_DATABASE_HOSTNAME: tracingdb
CACHE_DATABASE_PORT: 5432
CACHE_DATABASE_NAME: tracing
CACHE_DATABASE_USER: postgres
CACHE_DATABASE_PASSWORD: pwd
SERVER_HTTP_PATH: "0.0.0.0:8083"
ETH_HTTP_PATH: "geth:8545"
ETH_WS_PATH: "geth:8546"
ETH_CHAIN_ID: 1
ETH_NETWORK_ID: 1
ETH_GENESIS_BLOCK: "0xa1569030790a6ca195d69a98217028ebcb2a3cde096407e189cf35d3c91f26ef"
ports:
- "127.0.0.1:8083:8083"
13 changes: 13 additions & 0 deletions test/enviroment/mainnet/ssh/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM alpine:3.2

RUN apk add --update openssh-client && rm -rf /var/cache/apk/*

CMD rm -rf /root/.ssh && mkdir /root/.ssh && cp -R /root/ssh/* /root/.ssh/ && chmod -R 600 /root/.ssh/* && \
ls -l /root/.ssh/ && \
ssh \
-o StrictHostKeyChecking=no \
-N $TUNNEL_HOST \
-L *:$LOCAL_PORT:$REMOTE_HOST:$REMOTE_PORT \
&& while true; do sleep 30; done;

EXPOSE 5432
4 changes: 4 additions & 0 deletions test/enviroment/mainnet/ssh/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Host mainnet-db
HostName %host%
IdentityFile ~/.ssh/id_rsa_github_actions
User %user%