Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI test using a3p #31

Merged
merged 27 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a827591
chore: gitignore for aider
turadg Dec 10, 2024
f8dc610
chore(deps): bump subql deps
turadg Dec 11, 2024
2f09e6a
chore(deps): rm unused
turadg Dec 11, 2024
9923514
feat: AGORIC_NET env option
turadg Dec 10, 2024
7c30fde
ci: Rename PR workflow job from 'pr' to 'test'
turadg Dec 10, 2024
4a07e02
ci: Add a3p container service to GitHub Actions workflow
turadg Dec 10, 2024
3c298f4
ci: subql-node-cosmos test
turadg Dec 10, 2024
51a3001
feat: parameterize startBlock
turadg Dec 10, 2024
b8d18ab
test: a3p
turadg Dec 10, 2024
ff4fe8b
test: update tests
turadg Dec 12, 2024
d6802ca
test: update tests
rabi-siddique Dec 13, 2024
903008e
chore: remove encoding/decoding
rabi-siddique Dec 13, 2024
ac00815
test: add tests for vault and reserve entities
rabi-siddique Dec 16, 2024
c9738e7
test: add tests for boardaux, oraclePriceDaily and PsmMetricsDaily
rabi-siddique Dec 16, 2024
59c6dba
test: bundle install test
frazarshad Dec 16, 2024
c7ea1fe
test: psmMetrics, psmGovernance, oraclePrice tests added
frazarshad Dec 17, 2024
6ed47f2
fix: casting value to bigint
frazarshad Dec 17, 2024
43b7c8b
chore: prettier
frazarshad Dec 17, 2024
4913583
test: disabled vault manager tests
frazarshad Dec 17, 2024
cc0d163
ci: initial setup for liquidation testing
rabi-siddique Dec 17, 2024
fef6f99
ci: set ATOM price and create vaults
rabi-siddique Dec 17, 2024
300bdee
ci: place bids and set ATOM price to 9.99
rabi-siddique Dec 17, 2024
e308f84
ci: get active vaults
rabi-siddique Dec 17, 2024
7996f70
ci: validate liquidating vaults
rabi-siddique Dec 18, 2024
c23d4c8
ci: set execute permission for all .mjs files in scripts
rabi-siddique Dec 18, 2024
6ddb269
chore(deps): install ses
rabi-siddique Dec 18, 2024
470125a
ci: validate vault and reserve metrics data
rabi-siddique Dec 19, 2024
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
130 changes: 130 additions & 0 deletions .github/workflows/liquidation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: Liquidation Indexing
on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Start A3P container
run: docker compose --profile ci up -d a3p

- run: corepack enable
shell: bash

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install

- name: Start subql indexer
env:
AGORIC_NET: ci
run: yarn dev

- name: Print initial logs of all containers
run: |
echo "Fetching initial logs for all containers..."
containers=$(docker ps --format '{{.ID}}')
for container in $containers; do
echo "Fetching initial logs for container $container..."
docker logs $container
done

- name: Set ATOM Price to 12.34
run: ./scripts/changePrice.mjs
env:
amount: 12.34
containerName: agd
AGORIC_NET: local

- name: Get active vaults
run: ./scripts/getActiveVaults.mjs
env:
expectedVaults: 7

- name: Create Vault with 100 Minted and 15 Collateral
run: ./scripts/createVault.mjs
env:
wantMinted: '100'
giveCollateral: '15'
userKey: 'gov3'
AGORIC_NET: 'local'
commandTimeout: '120'
containerName: 'agd'

- name: Create Vault with 103 Minted and 15 Collateral
run: ./scripts/createVault.mjs
env:
wantMinted: '103'
giveCollateral: '15'
userKey: 'gov3'
AGORIC_NET: 'local'
commandTimeout: '120'
containerName: 'agd'

- name: Create Vault with 105 Minted and 15 Collateral
run: ./scripts/createVault.mjs
env:
wantMinted: '105'
giveCollateral: '15'
userKey: 'gov3'
AGORIC_NET: 'local'
commandTimeout: '120'
containerName: 'agd'

- name: Get active vaults
run: ./scripts/getActiveVaults.mjs
env:
expectedVaults: 10

- name: Place bid for 90IST
run: ./scripts/placeBid.mjs
env:
fromAddress: 'gov1'
giveAmount: '90IST'
priceOrDiscount: '9'
commandType: 'by-price'
AGORIC_NET: 'local'
containerName: 'agd'

- name: Place bid for 80IST
run: ./scripts/placeBid.mjs
env:
fromAddress: 'gov1'
giveAmount: '80IST'
priceOrDiscount: '10'
commandType: 'by-discount'
AGORIC_NET: 'local'
containerName: 'agd'

- name: Place bid for 150IST
run: ./scripts/placeBid.mjs
env:
fromAddress: 'gov1'
giveAmount: '150IST'
priceOrDiscount: '15'
commandType: 'by-discount'
AGORIC_NET: 'local'
containerName: 'agd'

- name: Set ATOM Price to 9.99
run: ./scripts/changePrice.mjs
env:
amount: 9.99
containerName: agd
AGORIC_NET: local

- name: Check liquidation indexing
run: ./scripts/checkLiquidation.mjs

- name: Get active vaults
run: ./scripts/getActiveVaults.mjs
env:
expectedVaults: 7
19 changes: 13 additions & 6 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ on:
pull_request:

jobs:
pr:
test:
runs-on: ubuntu-latest
services:
a3p:
image: ghcr.io/agoric/agoric-3-proposals:use-upgrade-17
ports:
- 26657:26657
postgres:
image: postgres:16-alpine
ports:
Expand Down Expand Up @@ -41,10 +45,13 @@ jobs:
- run: yarn tsc
- name: Build
run: yarn build
# TODO: https://github.com/Agoric/agoric-subql/issues/8
env:
AGORIC_NET: local

# Runtime tests using the db
- name: Enable btree btree_gist
run: psql "postgresql://$DB_USER:$DB_PASS@$DB_HOST:$DB_PORT/$DB_DATABASE" -c "CREATE EXTENSION IF NOT EXISTS btree_gist;"
# - name: Install subql-node-cosmos
# run: yarn global add @subql/node-cosmos
# - name: Run tests with Subquery Node
# run: subql-node-cosmos test -f ${{ github.workspace }}
- name: Run tests with Subquery Node
env:
TZ: UTC # prevents: Environment Timezone is not set to UTC. This may cause issues with indexing or proof of index
run: yarn subql-node-cosmos test -f ${{ github.workspace }}
79 changes: 79 additions & 0 deletions .github/workflows/vaults-and-reserve-metrics-testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Vaults and Reserve Indexing
on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Start A3P container
run: docker compose --profile ci up -d a3p

- run: corepack enable
shell: bash

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 18
cache: yarn

- name: Install dependencies
run: yarn install

- name: Start subql indexer
env:
AGORIC_NET: ci
run: yarn dev

- name: Print initial logs of all containers
run: |
echo "Fetching initial logs for all containers..."
containers=$(docker ps --format '{{.ID}}')
for container in $containers; do
echo "Fetching initial logs for container $container..."
docker logs $container
done

# We tried delays of 10, 20, and 30 seconds, but a 60-second delay is the most efficient
# and ensures that the server is fully ready, without causing any issues.
- name: Wait for GraphQL server
run: sleep 60

- name: Test VaultManagerGovernance
run: ./scripts/validateData.mjs
env:
entity: vaultManagerGovernances
blockHeight: 1212

- name: Test VaultManagerMetrics
run: ./scripts/validateData.mjs
env:
entity: vaultManagerMetrics
blockHeight: 1212

- name: Test VaultManagerMetricsDaily
run: ./scripts/validateData.mjs
env:
entity: vaultManagerMetricsDailies
blockHeight: 1212

- name: Test ReserveMetrics
run: ./scripts/validateData.mjs
env:
entity: reserveMetrics
blockHeight: 1212

- name: Test ReserveAllocationMetrics
run: ./scripts/validateData.mjs
env:
entity: reserveAllocationMetrics
blockHeight: 1212

- name: Test ReserveAllocationMetricsDaily
run: ./scripts/validateData.mjs
env:
entity: reserveAllocationMetricsDailies
blockHeight: 1212
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ Thumbs.db
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.aider*
.env
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,19 @@ The fastest way to get support is by [searching our documentation](https://acade
- storage
- submit_proposal
- transfer

## Developing

### Locally

1. Start up an A3P instance:

```sh
docker run -p 26657:26657 -p 1317:1317 -p 9090:9090 ghcr.io/agoric/agoric-3-proposals:latest
```

2. Browse it with [vstorage viewer](https://vstorage.agoric.net/?endpoint=http%3A%2F%2Flocalhost%3A26657)

3. Update tests to verify some observations you've made in the vstorage viewer

4. Run `yarn test`
38 changes: 29 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
postgres:
build:
Expand All @@ -16,11 +14,14 @@ services:
interval: 5s
timeout: 5s
retries: 5
profiles:
- default
- ci

subquery-node:
image: subquerynetwork/subql-node-cosmos:v3.12.0
image: subquerynetwork/subql-node-cosmos:v4.2.1
depends_on:
'postgres':
postgres:
condition: service_healthy
restart: always
environment:
Expand All @@ -32,27 +33,28 @@ services:
volumes:
- ./:/app
command:
- ${SUB_COMMAND:-} # set SUB_COMMAND env variable to "test" to run tests
- ${SUB_COMMAND:-}
- -f=/app
- --db-schema=app
- --workers=4
- --batch-size=30
# - --log-level=debug
# - --unfinalized-blocks=true
healthcheck:
test: ['CMD', 'curl', '-f', 'http://subquery-node:3000/ready']
interval: 3s
timeout: 5s
retries: 10
profiles:
- default
- ci

graphql-engine:
image: onfinality/subql-query:v2.13.0
ports:
- 3000:3000
depends_on:
'postgres':
postgres:
condition: service_healthy
'subquery-node':
subquery-node:
condition: service_healthy
restart: always
environment:
Expand All @@ -65,3 +67,21 @@ services:
- --name=app
- --playground
- --indexer=http://subquery-node:3000
profiles:
- default
- ci

a3p:
image: ghcr.io/agoric/agoric-3-proposals:latest
container_name: agd
ports:
- 26657:26657
- 1317:1317
- 9090:9090
restart: always
profiles:
- ci

networks:
default:
driver: bridge
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "subql build",
"codegen": "subql codegen",
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
"dev": "subql codegen && subql build && docker compose pull && docker compose --profile default up --remove-orphans --detach",
"prepack": "rm -rf dist && npm run build",
"test": "subql build && subql-node-cosmos test",
"prettier:check": "prettier --list-different . --print-width 120",
Expand All @@ -23,23 +23,28 @@
"author": "Agoric OpCo",
"license": "Apache-2.0",
"devDependencies": {
"@agoric/internal": "0.4.0-u18.0",
"@cosmjs/stargate": "^0.28.9",
"@subql/cli": "^5.3.3",
"@endo/eventual-send": "^1.2.8",
"@subql/cli": "^5.4.0",
"@subql/node-cosmos": "^4.2.1",
"@subql/testing": "latest",
"execa": "^9.5.2",
"prettier": "^3.4.2",
"ses": "^1.10.0",
"starknet": "6.11.0",
"typescript": "^5.7.2"
},
"dependencies": {
"@subql/types-cosmos": "^4.0.0",
"@subql/utils": "^2.16.0",
"@subql/utils": "^2.17.0",
"@types/node": "^17.0.21",
"bech32": "^2.0.0",
"js-sha256": "^0.11.0",
"pino": "^7.8.0",
"ts-proto": "^1.112.1",
"tslib": "^2.3.1"
"pino": "^7.8.0"
},
"resolutions": {
"@subql/node-core": "^16.1.0"
Comment on lines +46 to +47
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
"packageManager": "[email protected]"
}
Loading
Loading