Skip to content

Commit

Permalink
feat: Add e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mj52951 committed Dec 12, 2024
1 parent 0d017ec commit a878abc
Show file tree
Hide file tree
Showing 9 changed files with 677 additions and 122 deletions.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
DB_NAME=squid
DB_PASS=squid
DB_PORT=5432
DB_USERNAME=postgres
DB_HOST=localhost

SHARED_CONFIG_URL=
165 changes: 70 additions & 95 deletions commands.json
Original file line number Diff line number Diff line change
@@ -1,98 +1,73 @@
{
"$schema": "https://cdn.subsquid.io/schemas/commands.json",
"commands": {
"clean": {
"description": "delete all build artifacts",
"cmd": ["npx", "--yes", "rimraf", "lib"]
},
"build": {
"description": "Build the squid project",
"deps": ["clean"],
"cmd": ["tsc"]
},
"up": {
"description": "Start indexer",
"cmd": [
"docker",
"compose",
"up",
"-d"
]
},
"down": {
"description": "Drop indexer",
"cmd": [
"docker",
"compose",
"down"
]
},
"migration:apply": {
"description": "Apply the DB migrations",
"cmd": ["squid-typeorm-migration", "apply"]
},
"migration:generate": {
"description": "Generate a DB migration matching the TypeORM entities",
"deps": ["migration:clean"],
"cmd": ["squid-typeorm-migration", "generate"]
},
"migration:clean": {
"description": "Clean the migrations folder",
"cmd": ["npx", "--yes", "rimraf", "./db/migrations/*.js"]
},
"migration": {
"cmd": ["squid-typeorm-migration", "generate"],
"hidden": true
},
"codegen": {
"description": "Generate TypeORM entities from the schema file",
"cmd": ["squid-typeorm-codegen"]
},
"evm-typegen": {
"description": "Generate data access classes for an ABI file(s) in the ./abi folder",
"cmd": ["squid-evm-typegen", "./src/abi", {"glob": "./src/abi/*.json"}, "--multicall"]
},
"substrate-typegen": {
"description": "Generate data access classes for an substrate metadata",
"cmd": ["squid-substrate-typegen", "./typegen.json"]
},
"start-sepolia":{
"description": "Start Sepolia indexer",
"deps": ["build", "migration:apply"],
"cmd": ["node", "--require=dotenv/config", "lib/main.js", "dotenv_config_path=envs/.env.sepolia"]
},
"start-holesky":{
"description": "Start Holesky indexer",
"deps": ["build", "migration:apply"],
"cmd": ["node", "--require=dotenv/config", "lib/main.js", "dotenv_config_path=envs/.env.holesky"]
},
"process": {
"description": "Load .env and start the squid processor",
"deps": ["build", "migration:apply"],
"cmd": ["node", "--require=dotenv/config", "lib/main.js"]
},
"start-init": {
"description": "Initialize the database and load config data",
"deps": ["build", "migration:apply"],
"cmd": ["node", "--require=dotenv/config", "lib/main_init.js"]
},
"process:prod": {
"description": "Start the squid processor",
"cmd": ["node", "lib/main.js"],
"hidden": true
},
"check-updates": {
"cmd": ["npx", "--yes", "npm-check-updates", "--filter=/subsquid/", "--upgrade"],
"hidden": true
},
"bump": {
"description": "Bump @subsquid packages to the latest versions",
"deps": ["check-updates"],
"cmd": ["npm", "i", "-f"]
},
"open": {
"description": "Open a local browser window",
"cmd": ["npx", "--yes", "opener"]
}
"$schema": "https://cdn.subsquid.io/schemas/commands.json",
"commands": {
"clean": {
"description": "delete all build artifacts",
"cmd": ["npx", "--yes", "rimraf", "lib"]
},
"build": {
"description": "Build the squid project",
"deps": ["clean"],
"cmd": ["tsc"]
},
"up": {
"description": "Start indexer",
"cmd": [
"docker",
"compose",
"up",
"-d"
]
},
"down": {
"description": "Drop indexer",
"cmd": [
"docker",
"compose",
"down"
]
},
"migration:apply": {
"description": "Apply the DB migrations",
"cmd": ["squid-typeorm-migration", "apply"]
},
"migration:generate": {
"description": "Generate a DB migration matching the TypeORM entities",
"deps": ["migration:clean"],
"cmd": ["squid-typeorm-migration", "generate"]
},
"migration:clean": {
"description": "Clean the migrations folder",
"cmd": ["npx", "--yes", "rimraf", "./db/migrations/*.js"]
},
"migration": {
"cmd": ["squid-typeorm-migration", "generate"],
"hidden": true
},
"codegen": {
"description": "Generate TypeORM entities from the schema file",
"cmd": ["squid-typeorm-codegen"]
},
"evm-typegen": {
"description": "Generate data access classes for an ABI file(s) in the ./abi folder",
"cmd": ["squid-evm-typegen", "./src/abi", {"glob": "./src/abi/*.json"}, "--multicall"]
},
"substrate-typegen": {
"description": "Generate data access classes for an substrate metadata",
"cmd": ["squid-substrate-typegen", "./typegen.json"]
},
"check-updates": {
"cmd": ["npx", "--yes", "npm-check-updates", "--filter=/subsquid/", "--upgrade"],
"hidden": true
},
"bump": {
"description": "Bump @subsquid packages to the latest versions",
"deps": ["check-updates"],
"cmd": ["npm", "i", "-f"]
},
"open": {
"description": "Open a local browser window",
"cmd": ["npx", "--yes", "opener"]
}
}
}
48 changes: 42 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,35 @@
version: "3"

services:

evm1:
image: ghcr.io/sygmaprotocol/indexer-evm1:latest
container_name: evm1
command: ganache-cli --chainId 1337 -d --db data/ --blockTime 2 > /dev/null
logging:
driver: none
ports:
- "8545:8545"

evm2:
image: ghcr.io/sygmaprotocol/indexer-evm2:latest
command: ganache-cli --chainId 1338 -d --db data/ --blockTime 2 > /dev/null
container_name: evm2
logging:
driver: none
ports:
- "8547:8545"

substrate-pallet:
container_name: substrate-pallet
command: ["--pruning=25000"]
image: ghcr.io/sygmaprotocol/indexer-substrate:latest
ports:
- "9944:9944"
- "9933:9933"
logging:
driver: none

db:
image: postgres:15
environment:
Expand All @@ -17,22 +46,30 @@ services:
depends_on:
- db
env_file: ./envs/.env.init
indexer-sepolia:
indexer_evm1:
build:
context: .
dockerfile: ./Dockerfile
restart: on-failure
depends_on:
- indexer-init
env_file: ./envs/.env.sepolia
indexer-holesky:
env_file: ./envs/.env.evm-1
indexer_evm2:
build:
context: .
dockerfile: ./Dockerfile
restart: on-failure
depends_on:
- indexer-init
env_file: ./envs/.env.holesky
env_file: ./envs/.env.evm-2
indexer_substrate:
build:
context: .
dockerfile: ./Dockerfile
restart: on-failure
depends_on:
- indexer-init
env_file: ./envs/.env.substrate
api:
build:
context: .
Expand All @@ -41,5 +78,4 @@ services:
- indexer-init
env_file: ./envs/.env.api
ports:
- "8000:8000"

- "8000:8000"
13 changes: 13 additions & 0 deletions envs/.env.evm-1.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DB_NAME=squid
DB_PASS=squid
DB_PORT=5432
DB_USERNAME=postgres
DB_HOST=db
START_SCRIPT_ENV=index

PROCESSOR_PROMETHEUS_PORT=3000

SHARED_CONFIG_URL=

DOMAIN_ID=1
RPC_URL=[{"id": 1, "endpoint": "http://evm1:8545"},{"id": 2, "endpoint": "http://evm2:8545"}, {"id": 3, "endpoint": "ws://substrate-pallet:9944"}]
13 changes: 13 additions & 0 deletions envs/.env.evm-2.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DB_NAME=squid
DB_PASS=squid
DB_PORT=5432
DB_USERNAME=postgres
DB_HOST=db
START_SCRIPT_ENV=index

PROCESSOR_PROMETHEUS_PORT=3002

SHARED_CONFIG_URL=

DOMAIN_ID=2
RPC_URL=[{"id": 1, "endpoint": "http://evm1:8545"},{"id": 2, "endpoint": "http://evm2:8545"}, {"id": 3, "endpoint": "ws://substrate-pallet:9944"}]
21 changes: 0 additions & 21 deletions envs/.env.sepolia.example

This file was deleted.

13 changes: 13 additions & 0 deletions envs/.env.substrate.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DB_NAME=squid
DB_PASS=squid
DB_PORT=5432
DB_USERNAME=postgres
DB_HOST=db
START_SCRIPT_ENV=index

PROCESSOR_PROMETHEUS_PORT=3004

SHARED_CONFIG_URL=""

DOMAIN_ID=3
RPC_URL=[{"id": 1, "endpoint": "http://evm1:8545"},{"id": 2, "endpoint": "http://evm2:8545"}, {"id": 3, "endpoint": "ws://substrate-pallet:9944"}]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"start": "docker-compose up --build",
"stop": "docker-compose down",
"test:unit": "NODE_ENV=test nyc --exclude **/data/** --all --include \"src/**/*.ts\" mocha -r ts-node/register \"tests/unit/**/*.spec.ts\"",
"test:e2e": "NODE_ENV=test SERVER_PORT=0 mocha --timeout 40000 -r ts-node/register -r dotenv/config \"tests/e2e/**/*.spec.ts\"",
"update": "npx npm-check-updates --filter /subsquid/ --upgrade && npm i -f"
},
"dependencies": {
Expand Down
Loading

0 comments on commit a878abc

Please sign in to comment.