Skip to content

Commit c2380b6

Browse files
authored
feat: custom liveness, custom bond. add tests (#103)
Signed-off-by: Gerhard Steenkamp <gerhard@umaproject.org>
1 parent fe335d0 commit c2380b6

File tree

25 files changed

+1284
-3783
lines changed

25 files changed

+1284
-3783
lines changed

.github/workflows/test.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: build-and-test
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
workflow_dispatch:
12+
13+
jobs:
14+
build_test:
15+
16+
runs-on: ubuntu-22.04
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: 22.x
23+
registry-url: https://registry.npmjs.org
24+
- name: Install Yarn
25+
run: npm install -g yarn
26+
- run: yarn install
27+
- run: yarn ci

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@ node_modules
22
build
33
generated
44
.env
5-
.DS_Store
5+
.DS_Store
6+
tests/.*
7+
matchstick
8+
9+
# Matchstick test runner generated files
10+
**/tests/.*
11+
**/matchstick/*

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,40 @@
44

55
`yarn`
66

7+
## Running Tests
8+
9+
This repository uses [Matchstick](https://github.com/LimeChain/matchstick) for subgraph testing.
10+
11+
### Prerequisites
12+
13+
- **PostgreSQL 14** must be installed and running on your machine. Matchstick requires this for its testing environment.
14+
15+
### Running the tests
16+
17+
Tests are available for select packages and can be run using the following commands:
18+
19+
```bash
20+
# Run tests for all packages with test suites
21+
yarn test
22+
23+
# Run tests in parallel (faster)
24+
yarn test:parallel
25+
26+
# Run full CI pipeline (prepare and test)
27+
yarn ci
28+
```
29+
30+
The `yarn test` command runs tests for the following packages (when available):
31+
32+
- `managed-optimistic-oracle-v2-subgraph`
33+
- `optimistic-oracle-subgraph`
34+
- `optimistic-oracle-v2-subgraph`
35+
- `optimistic-oracle-v3-subgraph`
36+
- `skinny-optimistic-oracle-subgraph`
37+
- `votingV2-subgraph`
38+
39+
To run tests for a specific package, navigate to the package directory and run `yarn test` or `graph test` directly.
40+
741
## Voting V1 Events
842

943
This subgraph indexes events emitted by the core Oracle contracts. The code can be found in `packages/voting`

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
},
1212
"scripts": {
1313
"lint": "prettier ./**",
14-
"lint-fix": "prettier ./** --write"
14+
"lint-fix": "prettier ./** --write",
15+
"codegen": "lerna run codegen ",
16+
"build": "lerna run build --scope='managed-optimistic-oracle-v2-subgraph' --scope='optimistic-oracle-subgraph' --scope='optimistic-oracle-v2-subgraph' --scope='optimistic-oracle-v3-subgraph' --scope='skinny-optimistic-oracle-subgraph' --scope='votingV2-subgraph'",
17+
"test": "lerna run test --scope='managed-optimistic-oracle-v2-subgraph' --scope='optimistic-oracle-subgraph' --scope='optimistic-oracle-v2-subgraph' --scope='optimistic-oracle-v3-subgraph' --scope='skinny-optimistic-oracle-subgraph' --scope='votingV2-subgraph'",
18+
"test:parallel": "lerna run test --parallel --scope='managed-optimistic-oracle-v2-subgraph' --scope='optimistic-oracle-subgraph' --scope='optimistic-oracle-v2-subgraph' --scope='optimistic-oracle-v3-subgraph' --scope='skinny-optimistic-oracle-subgraph' --scope='votingV2-subgraph'",
19+
"prepare-ci": "lerna run --parallel prepare-ci --scope='managed-optimistic-oracle-v2-subgraph' --scope='optimistic-oracle-subgraph' --scope='optimistic-oracle-v2-subgraph' --scope='optimistic-oracle-v3-subgraph' --scope='skinny-optimistic-oracle-subgraph' --scope='votingV2-subgraph'",
20+
"ci": "yarn prepare-ci && yarn test"
1521
},
1622
"bugs": {
1723
"url": "https://github.com/UMAprotocol/subgraphs/issues"
@@ -24,7 +30,8 @@
2430
"packages/votingV2/**",
2531
"packages/optimistic-oracle/**",
2632
"packages/optimistic-oracle-v3/**",
27-
"packages/optimistic-governor/**"
33+
"packages/optimistic-governor/**",
34+
"packages/managed-oracle-v2/**"
2835
]
2936
},
3037
"devDependencies": {

packages/financial-contracts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"codegen": "graph codegen",
77
"build": "graph build",
88
"prepare:mainnet": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml && yarn codegen && yarn build",
9+
"prepare-ci": "mustache config/mainnet.json subgraph.template.yaml > subgraph.yaml && yarn codegen && yarn build",
910
"prepare:kovan": "mustache config/kovan.json subgraph.template.yaml > subgraph.yaml && yarn codegen && yarn build",
1011
"deploy:kovan": "env STAGING=true scripts/deploy.sh kovan",
1112
"deploy:mainnet": "env STAGING=true scripts/deploy.sh mainnet",

packages/long-short-pair/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"codegen": "graph codegen",
88
"build": "graph build",
99
"prepare:mainnet": "scripts/build-manifest.sh mainnet && yarn codegen && yarn build",
10+
"prepare-ci": "scripts/build-manifest.sh mainnet && yarn codegen && yarn build",
1011
"prepare:kovan": "scripts/build-manifest.sh kovan && yarn codegen && yarn build",
1112
"prepare:polygon": "scripts/build-manifest.sh polygon && yarn codegen && yarn build",
1213
"deploy:kovan": "env STAGING=true scripts/deploy.sh kovan",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
testsFolder: tests
2+
libsFolder: ../../node_modules # binaries istalled in root of monorepo

packages/managed-oracle-v2/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
"build": "graph build",
99
"remove-call-handlers": "node ./scripts/remove-call-handlers.js",
1010
"prepare:polygon": "scripts/build-manifest.sh polygon && yarn remove-call-handlers && yarn codegen && yarn build",
11+
"prepare-ci": "scripts/build-manifest.sh polygon && yarn remove-call-handlers && yarn codegen && yarn build",
1112
"prepare:amoy": "scripts/build-manifest.sh amoy && yarn remove-call-handlers && yarn codegen && yarn build",
1213
"deploy:polygon": "env STAGING=true scripts/deploy.sh polygon",
1314
"deploy-prod:polygon": "env STUDIO=true scripts/deploy.sh polygon",
1415
"deploy:amoy": "env STAGING=true scripts/deploy.sh amoy",
1516
"deploy-prod:amoy": "env STUDIO=true scripts/deploy.sh amoy",
1617
"deploy:goldsky:amoy": "env GOLDSKY=true scripts/deploy.sh amoy",
17-
"deploy-prod:goldsky:polygon": "env GOLDSKY=true scripts/deploy.sh polygon"
18+
"deploy-prod:goldsky:polygon": "env GOLDSKY=true scripts/deploy.sh polygon",
19+
"test": "graph test"
1820
},
1921
"repository": {
2022
"type": "git",
@@ -32,5 +34,8 @@
3234
"@graphprotocol/graph-ts": "^0.32.0",
3335
"mustache": "^4.2.0",
3436
"yaml": "^2.2.1"
37+
},
38+
"devDependencies": {
39+
"matchstick-as": "0.6.0"
3540
}
3641
}

packages/managed-oracle-v2/schema.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ type CustomBond @entity {
8585
"ID is managedRequestId, ie. the hash of requester, identifier, ancillaryData"
8686
id: ID!
8787

88+
currency: Bytes!
89+
8890
requester: Bytes!
8991

9092
identifier: String!

packages/managed-oracle-v2/src/mappings/managedOracleV2.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function handleCustomBondSet(event: CustomBondSet): void {
1313
entity.requester = event.params.requester;
1414
entity.identifier = event.params.identifier.toString();
1515
entity.ancillaryData = event.params.ancillaryData.toHex();
16+
entity.currency = event.params.currency;
1617
}
1718

1819
entity.customBond = event.params.bond;

0 commit comments

Comments
 (0)