Skip to content

Commit ab8d12b

Browse files
committed
Merge branch 'feature/local-test' into feature/poco-sponsoring
2 parents a8ef9ad + 7cf21ad commit ab8d12b

File tree

8 files changed

+110
-4
lines changed

8 files changed

+110
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ yarn.lock
55
test/.bin
66
subgraph.yaml
77
subgraph.test.yaml
8+
.env

.mocharc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"extension": ["ts"],
33
"spec": "itest/**/*.ts",
44
"require": ["ts-node/register"],
5-
"timeout": 600000
5+
"timeout": 1000000
66
}

generate_subgraph_file.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ generate_yaml() {
1515
local network=$1
1616
local config_file="config.json"
1717
local template_file="subgraph.template.yaml"
18-
local output_file="subgraph.${network}.yaml"
18+
local output_file="subgraph.yaml"
1919

2020
# Read values from config.json
2121
local start_block=$(jq -r ".${network}.START_BLOCK" ${config_file})
@@ -25,6 +25,13 @@ generate_yaml() {
2525
local dataset_registry_address=$(jq -r ".${network}.DATATSET_REGISTRY_ADDRESS" ${config_file})
2626
local workerpool_registry_address=$(jq -r ".${network}.WORKERPOOL_REGISTRY_ADDRESS" ${config_file})
2727

28+
if [ -n "$START_BLOCK" ]; then
29+
echo "START_BLOCK is set to $START_BLOCK"
30+
start_block=$START_BLOCK
31+
else
32+
echo "START_BLOCK is not set. Using start_block from config.json: $start_block"
33+
fi
34+
2835
# Replace placeholders in the template and create the output file
2936
sed -e "s/#NETWORK_NAME#/network: ${network}/g" \
3037
-e "s/#START_BLOCK#/startBlock: ${start_block}/g" \

itest/integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('Integration tests', () => {
2727
),
2828
);
2929
await environment.up();
30-
const secondsToWait = 5;
30+
const secondsToWait = 10;
3131
console.log(
3232
`Waiting ${secondsToWait}s for graphnode to ingest a few blocks before querying it..`,
3333
);

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
"test": "npm run codegen && graph test",
1010
"test-docker": "npm run codegen && docker run -it --rm -v $(pwd):/matchstick/subgraph rainprotocol/matchstick:main",
1111
"build": "npm run codegen && cp subgraph.template.yaml subgraph.yaml && graph build --network ${NETWORK_NAME:-bellecour}",
12+
"build:local-test": "npm run codegen && cp subgraph.template.yaml subgraph.yaml && graph build --network ${NETWORK_NAME:-bellecour} && ./generate_subgraph_file.sh ${NETWORK_NAME:-bellecour}",
1213
"create": "graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}",
1314
"deploy": "graph deploy ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020} --ipfs ${IPFS_URL:-http://localhost:5001} --version-label ${VERSION_LABEL:-bellecour/poco-v5}",
1415
"deploy:all": "npm run build && npm run create && npm run deploy",
15-
"itest": "DEBUG=testcontainers:* mocha"
16+
"deploy:all-local-test": "npm run build:local-test && npm run create && npm run deploy",
17+
"itest": "DEBUG=testcontainers:* mocha",
18+
"stop-test-stack": "cd test-stack && docker compose down --remove-orphans --volumes",
19+
"start-test-stack": "npm run stop-test-stack && cd test-stack && docker compose build && docker compose up -d"
1620
},
1721
"lint-staged": {
1822
"*.{js,ts}": [

test-stack/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM node:22-alpine
2+
RUN apk --no-cache add jq bash
3+
WORKDIR /iexec-poco-subgraph
4+
COPY package*.json .
5+
RUN npm ci
6+
COPY schema.graphql .
7+
COPY subgraph.template.yaml .
8+
COPY networks.json .
9+
COPY config.json .
10+
COPY generate_subgraph_file.sh .
11+
COPY src src
12+
ENTRYPOINT [ "npm", "run", "deploy:all-local-test" ]

test-stack/docker-compose.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
services:
2+
graphnode-postgres:
3+
image: postgres:16.4
4+
restart: unless-stopped
5+
command:
6+
- "postgres"
7+
- "-cshared_preload_libraries=pg_stat_statements"
8+
expose:
9+
- 5432
10+
environment:
11+
POSTGRES_USER: graphnode
12+
POSTGRES_PASSWORD: password
13+
POSTGRES_DB: graphnode-db
14+
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
15+
healthcheck:
16+
test: pg_isready -U graphnode -d graphnode-db
17+
interval: 10s
18+
timeout: 5s
19+
retries: 3
20+
start_period: 30s
21+
22+
ipfs:
23+
restart: unless-stopped
24+
image: ipfs/go-ipfs:v0.22.0
25+
expose:
26+
- 8080
27+
- 5001
28+
ports:
29+
- 8080:8080
30+
- 5001:5001
31+
32+
graphnode:
33+
image: graphprotocol/graph-node:v0.35.1
34+
restart: unless-stopped
35+
expose:
36+
- 8000
37+
- 8020
38+
ports:
39+
# GraphQL HTTP
40+
- 8000:8000
41+
# GraphQL WS
42+
# - 8001:8001
43+
# admin RPC
44+
- 8020:8020
45+
# metrics
46+
# - 8040:8040
47+
environment:
48+
postgres_host: graphnode-postgres
49+
postgres_port: 5432
50+
postgres_user: graphnode
51+
postgres_pass: password
52+
postgres_db: graphnode-db
53+
ipfs: ipfs:5001
54+
ethereum: ${NETWORK_NAME}:${BELLECOUR_NODE_URL}
55+
GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: $START_BLOCK
56+
depends_on:
57+
graphnode-postgres:
58+
condition: service_healthy
59+
ipfs:
60+
condition: service_started
61+
healthcheck:
62+
test: netcat -w 1 0.0.0.0 8020
63+
interval: 10s
64+
timeout: 5s
65+
retries: 5
66+
start_period: 30s
67+
68+
poco-subgraph-deployer:
69+
build:
70+
context: ..
71+
dockerfile: docker/Dockerfile
72+
environment:
73+
GRAPHNODE_URL: http://graphnode:8020
74+
IPFS_URL: http://ipfs:5001
75+
NETWORK_NAME: $NETWORK_NAME
76+
START_BLOCK: $START_BLOCK
77+
depends_on:
78+
graphnode:
79+
condition: service_healthy

test-stack/template.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
BELLECOUR_NODE_URL=
2+
START_BLOCK=
3+
NETWORK_NAME=

0 commit comments

Comments
 (0)