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

Testing b #37

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a827591
chore: gitignore for aider
turadg Dec 10, 2024
b3bd7cd
chore(deps): bump subql deps
turadg Dec 11, 2024
ef0fc4a
chore(deps): rm unused
turadg Dec 11, 2024
704a737
feat: AGORIC_NET env option
turadg Dec 10, 2024
6599ee6
ci: Rename PR workflow job from 'pr' to 'test'
turadg Dec 10, 2024
2a3a539
ci: Add a3p container service to GitHub Actions workflow
turadg Dec 10, 2024
658514c
ci: subql-node-cosmos test
turadg Dec 10, 2024
ebe26e6
feat: parameterize startBlock
turadg Dec 10, 2024
5c1033d
test: a3p
turadg Dec 10, 2024
93e39b9
fixup! chore(deps): bump subql deps
turadg Dec 11, 2024
475cf4c
WIP
turadg Dec 12, 2024
b29ea2a
test: update tests
rabi-siddique Dec 13, 2024
0970e1f
chore: remove encoding/decoding
rabi-siddique Dec 13, 2024
f9d7d2d
test: add tests for vault and reserve entities
rabi-siddique Dec 16, 2024
349741a
test: add tests for boardaux, oraclePriceDaily and PsmMetricsDaily
rabi-siddique Dec 16, 2024
962afe2
ci: initial setup for liquidation testing
rabi-siddique Dec 17, 2024
b74de95
ci: set ATOM price and create vaults
rabi-siddique Dec 17, 2024
4040adf
ci: place bids and set ATOM price to 9.99
rabi-siddique Dec 17, 2024
05619b3
ci: get active vaults
rabi-siddique Dec 17, 2024
fccc9a0
ci: validate liquidating vaults
rabi-siddique Dec 18, 2024
deee3de
fixup! ci: validate liquidating vaults
rabi-siddique Dec 18, 2024
da6b46d
ci: set execute permission for all .mjs files in scripts
rabi-siddique Dec 18, 2024
9fb678c
chore(deps): install ses
rabi-siddique Dec 18, 2024
9201fe9
fixup! chore(deps): install ses
rabi-siddique Dec 18, 2024
7dc8b52
fixup! fixup! chore(deps): install ses
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
138 changes: 138 additions & 0 deletions .github/workflows/liquidation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
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 Execute Permission for All Scripts
run: chmod +x ./scripts/*.mjs

- 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:
apiUrl: 'http://localhost:3000/'
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:
apiUrl: 'http://localhost:3000/'
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
env:
apiUrl: 'http://localhost:3000/'

- name: Get active vaults
run: ./scripts/getActiveVaults.mjs
env:
apiUrl: 'http://localhost:3000/'
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 }}
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"
},
"packageManager": "[email protected]"
}
Loading
Loading