Skip to content
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ yarn.lock
test/.bin
subgraph.yaml
subgraph.test.yaml
.env
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"extension": ["ts"],
"spec": "itest/**/*.ts",
"require": ["ts-node/register"],
"timeout": 600000
"timeout": 1000000
}
9 changes: 8 additions & 1 deletion generate_subgraph_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ generate_yaml() {
local network=$1
local config_file="config.json"
local template_file="subgraph.template.yaml"
local output_file="subgraph.${network}.yaml"
local output_file="subgraph.yaml"

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

if [ -n "$START_BLOCK" ]; then
echo "START_BLOCK is set to $START_BLOCK"
start_block=$START_BLOCK
else
echo "START_BLOCK is not set. Using start_block from config.json: $start_block"
fi

# Replace placeholders in the template and create the output file
sed -e "s/#NETWORK_NAME#/network: ${network}/g" \
-e "s/#START_BLOCK#/startBlock: ${start_block}/g" \
Expand Down
2 changes: 1 addition & 1 deletion itest/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Integration tests', () => {
),
);
await environment.up();
const secondsToWait = 5;
const secondsToWait = 10;
console.log(
`Waiting ${secondsToWait}s for graphnode to ingest a few blocks before querying it..`,
);
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
"test": "npm run codegen && graph test",
"test-docker": "npm run codegen && docker run -it --rm -v $(pwd):/matchstick/subgraph rainprotocol/matchstick:main",
"build": "npm run codegen && cp subgraph.template.yaml subgraph.yaml && graph build --network ${NETWORK_NAME:-bellecour}",
"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}",
"create": "graph create ${NETWORK_NAME:-bellecour}/poco --node ${GRAPHNODE_URL:-http://localhost:8020}",
"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}",
"deploy:all": "npm run build && npm run create && npm run deploy",
"itest": "DEBUG=testcontainers:* mocha"
"deploy:all-local-test": "npm run build:local-test && npm run create && npm run deploy",
"itest": "DEBUG=testcontainers:* mocha",
"stop-test-stack": "cd test-stack && docker compose down --remove-orphans --volumes",
"start-test-stack": "npm run stop-test-stack && cd test-stack && docker compose build && docker compose up -d"
},
"lint-staged": {
"*.{js,ts}": [
Expand Down
12 changes: 12 additions & 0 deletions test-stack/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:22-alpine
RUN apk --no-cache add jq bash
WORKDIR /iexec-poco-subgraph
COPY package*.json .
RUN npm ci
COPY schema.graphql .
COPY subgraph.template.yaml .
COPY networks.json .
COPY config.json .
COPY generate_subgraph_file.sh .
COPY src src
ENTRYPOINT [ "npm", "run", "deploy:all-local-test" ]
79 changes: 79 additions & 0 deletions test-stack/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
services:
graphnode-postgres:
image: postgres:16.4
restart: unless-stopped
command:
- "postgres"
- "-cshared_preload_libraries=pg_stat_statements"
expose:
- 5432
environment:
POSTGRES_USER: graphnode
POSTGRES_PASSWORD: password
POSTGRES_DB: graphnode-db
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
healthcheck:
test: pg_isready -U graphnode -d graphnode-db
interval: 10s
timeout: 5s
retries: 3
start_period: 30s

ipfs:
restart: unless-stopped
image: ipfs/go-ipfs:v0.22.0
expose:
- 8080
- 5001
ports:
- 8080:8080
- 5001:5001

graphnode:
image: graphprotocol/graph-node:v0.35.1
restart: unless-stopped
expose:
- 8000
- 8020
ports:
# GraphQL HTTP
- 8000:8000
# GraphQL WS
# - 8001:8001
# admin RPC
- 8020:8020
# metrics
# - 8040:8040
environment:
postgres_host: graphnode-postgres
postgres_port: 5432
postgres_user: graphnode
postgres_pass: password
postgres_db: graphnode-db
ipfs: ipfs:5001
ethereum: ${NETWORK_NAME}:${BELLECOUR_NODE_URL}
GRAPH_ETHEREUM_GENESIS_BLOCK_NUMBER: $START_BLOCK
depends_on:
graphnode-postgres:
condition: service_healthy
ipfs:
condition: service_started
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
START_BLOCK: $START_BLOCK
depends_on:
graphnode:
condition: service_healthy
3 changes: 3 additions & 0 deletions test-stack/template.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BELLECOUR_NODE_URL=
START_BLOCK=
NETWORK_NAME=