Skip to content

Commit

Permalink
ci test works
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Jul 16, 2024
1 parent 0ed7b24 commit 532851f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 25 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,39 +574,37 @@ A complete working flow can be found in [routing e2e tests](./src/__tests__/rout
4) fetch VAA and redeem on the target evm chain

## Tests
### with coverage report
- run tests and generate coverage data
### test setup
use the test env file
```
yarn test:coverage
mv .env.test .env
```

show coverage report in GUI
start a local test stack
```
yarn vite preview --outDir ./coverage/
yarn start:test-stack
```

### with separate relayer (no coverage report)
first start a relayer: `yarn dev`

### run tests with coverage report
- run tests and generate coverage data
```
yarn test
yarn test:coverage
```

### test setup
first start a local acala fork
show coverage report in GUI
```
npx @acala-network/chopsticks@latest -c src/__tests__/configs/acala.yml -p 8000
yarn vite preview --outDir ./coverage/
```

start an rpc adapter
### run tests with separate relayer (no coverage report)
first start a local relayer
```
npx @acala-network/eth-rpc-adapter -e ws://localhost:8000
yarn dev
```

start the relayer
run tests
```
mv .env.test .env
yarn dev
yarn test
```

## Production Config
Expand Down
37 changes: 31 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,29 @@ services:
ports:
- 8000:8000
healthcheck:
test: "exit 0"
# FIXME: does not seem to work
# test: "curl --fail -X POST -H \"Content-Type: application/json\" http://localhost:8000 -d \"{\"id\": 1, \"jsonrpc\": \"2.0\", \"method\": \"system_health\", \"params\": []}\" || exit 1"
# bun image doesn't have wget or curl ...
test: |
bun --eval '
fetch("http://localhost:8000", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id: 1, jsonrpc: "2.0", method: "system_health", params: [] })
})
.then(res => res.json())
.then(data => {
const exitCode = data.result ? 0 : 1;
process.exit(exitCode)
})
.catch(() => process.exit(1));
'
interval: 2s
timeout: 5s
retries: 100
start_period: 10s

eth-rpc:
container_name: eth-rpc
image: acala/eth-rpc-adapter:2.8.7
restart: always
restart: on-failure
depends_on:
node:
condition: service_healthy
Expand All @@ -32,4 +44,17 @@ services:
- host.docker.internal:host-gateway
environment:
- ENDPOINT_URL=ws://node:8000
command: yarn start
healthcheck:
test: |
wget -q -O- --post-data='{"id": 1, "jsonrpc": "2.0", "method": "eth_chainId", "params": []}' --header='Content-Type: application/json' http://localhost:8545 || exit 1
interval: 2s
timeout: 5s
retries: 100

test-stack-ready:
image: alpine:latest
restart: on-failure
depends_on:
eth-rpc:
condition: service_healthy
command: echo "test stack ready 🚀"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"start:test-stack": "docker compose up -d",
"dev": "ts-node-dev --respawn src/index.ts | pino-pretty --singleLine --colorize --ignore time,hostname",
"test": "vitest src/__tests__/*.test.ts --singleThread",
"test:coverage": "COVERAGE=1 yarn test --coverage",
"test:ci": "yarn start:test-stack; yarn test:coverage",
"relay": "ts-node src/scripts/manual-relay.ts",
"start:test-stack": "docker compose up"
"relay": "ts-node src/scripts/manual-relay.ts"
},
"dependencies": {
"@acala-network/api": "~6.0.4",
Expand Down

0 comments on commit 532851f

Please sign in to comment.