Skip to content

Commit

Permalink
Use multicall for tests (#21)
Browse files Browse the repository at this point in the history
* Try to improve test

* Test indexers if defined

* Clean initializer

* Fix syntax

* Improve test use multicall

* Test CI

* Test CI

* Test CI

* Test CI

* Test CI

* Test CI

* no colors

* no colors
  • Loading branch information
fewensa authored Sep 3, 2024
1 parent a98ed0b commit ce73bd8
Show file tree
Hide file tree
Showing 23 changed files with 858 additions and 839 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,30 @@ jobs:
run: npm run build:ts

- name: Check test:ts
run: npm run test:ts
run: npm run test:ts:ci 2> jest-test.local.log

- name: Prepare report
if: failure()
run: |
sed -i '1i\```' jest-test.local.log
sed -i '1i\## Jest Test Errored Report' jest-test.local.log
echo '```' >> jest-test.local.log
sed -ir "s/\x1B\[[0-9;]*[JKmsu]//g" jest-test.local.log
cat jest-test.local.log
- name: Find Comment
uses: peter-evans/find-comment@v3
if: failure()
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: 'Jest Test Errored Report'

- name: Comment configurate
uses: GrantBirki/comment@v2
if: failure()
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
file: jest-test.local.log
edit-mode: replace

5 changes: 0 additions & 5 deletions conf/mainnets/mantle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ couples:
protocol: lnv3
fee: '100000'
messager: layerzero
- chain: scroll
symbol: USDT
protocol: lnv2-default
fee: '100000'
messager: layerzero
- chain: bsc
symbol: USDT
protocol: lnv2-default
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"codegen": "zx scripts/generate/index.mjs",
"build:ts": "npm run codegen -- --language=ts --verbose && cd generated/typescript && npm i && npm run build",
"test:ts": "npm run build:ts && cd generated/typescript && npm run test"
"test:ts": "npm run build:ts && cd generated/typescript && npm run test",
"test:ts:ci": "npm run build:ts && cd generated/typescript && npm run test:ci"
},
"author": "",
"license": "MIT",
Expand Down
4 changes: 3 additions & 1 deletion template/ts/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"homepage": "https://github.com/helix-bridge/helixconf",
"scripts": {
"build": "rm -rf dist && tsc",
"test": "jest --verbose --coverage"
"test": "jest --verbose --coverage",
"test:ci": "jest --coverage --ci --no-colors"
},
"author": "HelixBridge",
"license": "MIT",
"devDependencies": {
"@types/jest": "^29.5.12",
"ethers": "^6.13.2",
"ethers-multicall-provider": "^6.4.1",
"jest": "^29.7.0",
"ts-jest": "^29.2.4",
"ts-node": "^10.9.2",
Expand Down
22 changes: 21 additions & 1 deletion template/ts/files/src/helixconf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export interface HelixProtocol {
export interface CoupleFilter {
category?: string
messager?: string
protocol?: string
relatedProtocol?: HelixProtocolName // lnv2 has different protocol names in both directions, and perhaps others as well
protocol?: HelixProtocolName
chain?: string
symbolFrom?: string
symbolTo?: string
Expand Down Expand Up @@ -379,6 +380,25 @@ export class HelixChainConf {
const eq = _equalsIgnoreCase(item.protocol.name, filter.protocol)
|| _equalsIgnoreCase(item.protocol.address, filter.protocol);
if (!eq) return false;
} else {
if (filter.relatedProtocol) {
let expectProtocols: HelixProtocolName[] = [];
switch (filter.relatedProtocol) {
case 'lnv2-default':
expectProtocols = ['lnv2-opposite', 'lnv2-default']
break;
case 'lnv2-opposite':
expectProtocols = ['lnv2-opposite', 'lnv2-default']
break;
}
if (expectProtocols.length) {
const found = expectProtocols.find(
ep => _equalsIgnoreCase(item.protocol.name, ep)
|| _equalsIgnoreCase(item.protocol.address, ep)
);
if (!found) return false;
}
}
}
if (filter.chain) {
const eq = _equalsIgnoreCase(item.chain.id.toString(), filter.chain)
Expand Down
Loading

0 comments on commit ce73bd8

Please sign in to comment.