Skip to content

Commit

Permalink
Add protocol integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjams committed Oct 17, 2024
1 parent ee9ec3b commit 3672b1b
Show file tree
Hide file tree
Showing 12 changed files with 15,656 additions and 5,175 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ jobs:
run: npm run test
- name: Test build
run: npm run build
- name: Run integration tests
run: npm run itest:all
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ build
generated
yarn.lock
test/.bin
subgraph.yaml
subgraph.test.yaml
.graphclient
6 changes: 6 additions & 0 deletions .graphclientrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# For testing purposes
sources:
- name: poco
handler:
graphql:
endpoint: http://localhost:8000/subgraphs/name/test/poco
13 changes: 13 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:22

WORKDIR /iexec-poco-subgraph

COPY package*.json .
COPY schema.graphql .
COPY subgraph.template.yaml .
COPY networks.json .
COPY src src

RUN npm ci

ENTRYPOINT [ "npm", "run", "deploy:all" ]
3 changes: 2 additions & 1 deletion docker/test/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DATA=/home/tmp/graph-test
DB_USER=graphnode
DB_PASSWORD=somerandompasswordthatishardtoguess
DB_NAME=graphnode
DB_NAME=graphnode-db
NETWORK_NAME=test
91 changes: 47 additions & 44 deletions docker/test/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
version: "3"

networks:
thegraph:
blockchain:

services:
chain:
image: "iexechub/poco-chaintest:5.3.0-token-parity"
image: docker-regis.iex.ec/poco-chain:1.0.0-poco-v5.5.0-voucher-v1.0.0-nethermind
restart: unless-stopped
networks:
- blockchain
expose:
- 8545
- 8546
Expand All @@ -18,52 +10,63 @@ services:
- 8546:8546

ipfs:
image: ipfs/go-ipfs:v0.10.0
restart: unless-stopped
networks:
- thegraph
image: ipfs/go-ipfs:v0.22.0
expose:
- 8080
- 5001
ports:
- 8080:8080
- 5001:5001
volumes:
- ${DATA}/ipfs:/data/ipfs

postgres:
image: postgres:12
graphnode-postgres:
image: postgres:16.4
restart: unless-stopped
networks:
- thegraph
command:
- "postgres"
- "-cshared_preload_libraries=pg_stat_statements"
ports:
- 5432:5432
expose:
- 5432
environment:
POSTGRES_USER: "${DB_USER}"
POSTGRES_PASSWORD: "${DB_PASSWORD}"
POSTGRES_DB: "${DB_NAME}"
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: ${DB_NAME}
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"

graphnode:
image: graphprotocol/graph-node:v0.27.0
image: graphprotocol/graph-node:v0.35.1
restart: unless-stopped
networks:
- blockchain
- thegraph
depends_on:
- ipfs
- postgres
- chain
expose:
- 8000
- 8020
ports:
- 8000:8000 # http
- 8001:8001 # ws
- 8020:8020 # deploy
- 8030:8030 # monitoring
- 8040:8040 # prometeus
- 8000:8000 # GraphQL HTTP
# - 8001:8001 # GraphQL WS
- 8020:8020 # admin RPC
# - 8040:8040 # metrics
environment:
RUST_BACKTRACE: 1
postgres_host: postgres
postgres_user: "${DB_USER}"
postgres_pass: "${DB_PASSWORD}"
postgres_db: "${DB_NAME}"
ipfs: "ipfs:5001"
ethereum: "test:http://chain:8545"
GRAPH_NODE_ID: "graphnode_id"
postgres_host: graphnode-postgres
postgres_port: 5432
postgres_user: ${DB_USER}
postgres_pass: ${DB_PASSWORD}
postgres_db: ${DB_NAME}
ipfs: ipfs:5001
ethereum: ${NETWORK_NAME}:http://chain:8545
healthcheck:
test: netcat -w 1 0.0.0.0 8020
interval: 10s
timeout: 5s
retries: 5
start_period: 30s

poco-subgraph-deployer:
build:
context: ../..
dockerfile: docker/Dockerfile
environment:
GRAPHNODE_URL: http://graphnode:8020
IPFS_URL: http://ipfs:5001
NETWORK_NAME: ${NETWORK_NAME}
depends_on:
graphnode:
condition: service_healthy
25 changes: 25 additions & 0 deletions itest/integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { strictEqual } from 'assert';
import { execute } from '../.graphclient';

async function main() {
console.log('Running integration tests..');
const result = await execute(
`
query {
protocol(id: "iExec") {
tvl
id
}
}
`,
{},
);
console.log(result);
strictEqual(
JSON.stringify(result.data),
JSON.stringify({ protocol: { tvl: '0.02025', id: 'iExec' } }),
);
console.log('integration tests completed ✔️');
}

main();
46 changes: 46 additions & 0 deletions networks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"test": {
"ERC1538": {
"address": "0xc4b11f41746D3Ad8504da5B383E1aB9aa969AbC7",
"startBlock": 0
},
"Core": {
"address": "0xc4b11f41746D3Ad8504da5B383E1aB9aa969AbC7",
"startBlock": 0
},
"AppRegistry": {
"address": "0xd5Fe43e3cDD29812949dc9b368345537D7B73001",
"startBlock": 0
},
"DatasetRegistry": {
"address": "0xf3bd0602fA481230271c5396f146e5695D3750A6",
"startBlock": 0
},
"WorkerpoolRegistry": {
"address": "0x6Cb57fA761812c34645C945cA89AAe3602D42eD3",
"startBlock": 0
}
},
"bellecour": {
"ERC1538": {
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
"startBlock": 4543300
},
"Core": {
"address": "0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f",
"startBlock": 4543300
},
"AppRegistry": {
"address": "0xB1C52075b276f87b1834919167312221d50c9D16",
"startBlock": 4543300
},
"DatasetRegistry": {
"address": "0x799DAa22654128d0C64d5b79eac9283008158730",
"startBlock": 4543300
},
"WorkerpoolRegistry": {
"address": "0xC76A18c78B7e530A165c5683CB1aB134E21938B4",
"startBlock": 4543300
}
}
}
Loading

0 comments on commit 3672b1b

Please sign in to comment.