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

Remove encoding/decoding and update tests #35

Merged
merged 16 commits into from
Dec 24, 2024
Merged
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
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
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
services:
a3p:
image: ghcr.io/agoric/agoric-3-proposals:latest
image: ghcr.io/agoric/agoric-3-proposals:use-upgrade-17
ports:
- 26657:26657
postgres:
Expand Down
36 changes: 29 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,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 @@ -30,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 @@ -63,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
6 changes: 5 additions & 1 deletion 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,11 +23,15 @@
"author": "Agoric OpCo",
"license": "Apache-2.0",
"devDependencies": {
"@agoric/internal": "0.4.0-u18.0",
"@cosmjs/stargate": "^0.28.9",
"@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"
},
Expand Down
6 changes: 6 additions & 0 deletions project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ const networkConfig = {
chaintypes: chainTypesU18,
startBlock: 1,
},
ci: {
chainId: 'agoriclocal',
endpoint: ['http://a3p:26657'],
chaintypes: chainTypesU18,
startBlock: 1,
},
main: {
chainId: 'agoric-3',
endpoint: ['https://main-a.rpc.agoric.net:443'],
Expand Down
23 changes: 23 additions & 0 deletions scripts/changePrice.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /usr/bin/env node
import './lockdown.mjs';
import { execa } from 'execa';
import { assertAllDefined } from '@agoric/internal';

const agops = '/usr/src/agoric-sdk/packages/agoric-cli/bin/agops';
const { AGORIC_NET, amount, containerName } = process.env;

assertAllDefined({ AGORIC_NET, amount, containerName });

try {
const env = {
AGORIC_NET,
};

console.log(`Initiating price change to ${amount} for ATOM...`);
const command = `${agops} oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price ${amount} --keyring-backend=test`;
const { stdout } = await execa('docker', ['exec', containerName, command], { env, shell: true });

console.log('Standard output:', stdout);
} catch (error) {
console.error('Error:', error);
}
Loading
Loading