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

clients/js: add worm cli tests (parse, recover, info) + worm submit (testing all chains) #3229

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
240 commits
Select commit Hold shift + click to select a range
f828c7e
chore: add jest config
AlberErre Apr 12, 2023
ef36cf6
chore: add jest dependencies & update test script
AlberErre Apr 12, 2023
929c46a
feat: init chain-id tests
AlberErre Apr 12, 2023
b350e76
chore: update tsconfig to ignore test files
AlberErre Apr 12, 2023
f911ace
feat: chain-id positional arguments tests
AlberErre Apr 12, 2023
09011a3
feat: chain-id functionality tests
AlberErre Apr 12, 2023
94bab1a
feat: update chain-id test
AlberErre Apr 12, 2023
9f268ac
feat: add contractAddress tests
AlberErre Apr 12, 2023
a23dd4e
chore: update contract test description
AlberErre Apr 12, 2023
6de61d3
chore: update jest config
AlberErre Apr 12, 2023
0ff1c22
feat: add rpc tests
AlberErre Apr 12, 2023
bd72550
feat: add info namespace tests
AlberErre Apr 12, 2023
b0ec43b
chore: tsconfig es2020 to allow BigInts on testing
AlberErre Apr 12, 2023
1a2d84d
feat: add parse tests
AlberErre Apr 12, 2023
6ed5de5
chore: update parse test
AlberErre Apr 12, 2023
9ceaba1
feat: add recover tests
AlberErre Apr 12, 2023
1638997
chore: fix typo on tests
AlberErre Apr 12, 2023
d783986
chore: update parse test
AlberErre Apr 12, 2023
ac31cd8
feat: add submit tests
AlberErre Apr 12, 2023
c744906
chore: jest config verbose true
AlberErre Apr 12, 2023
e72a141
chore: update comment
AlberErre Apr 13, 2023
b4743b8
chore: move exclude section on tsconfig
AlberErre Apr 13, 2023
5bdd0f4
chore: rm extra comma
AlberErre Apr 13, 2023
1733609
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Apr 16, 2023
8d32ac5
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Apr 18, 2023
58a7fec
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Apr 24, 2023
8c775bc
chore: update package-lock after merging main
AlberErre Apr 24, 2023
66b3a3d
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Apr 27, 2023
e4131a9
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre May 9, 2023
7bf5dfa
fix: add missing ts-jest dependency after merge
AlberErre May 9, 2023
06a5751
fix: broken require paths
AlberErre May 9, 2023
ed0426a
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jun 15, 2023
1f6126c
chore: use package-lock from main & reinstall
AlberErre Jun 15, 2023
b0da52f
fix: route certusone module to commonJS on jest
AlberErre Jun 16, 2023
c17621a
feat: utils-jest functions (worm path & commands)
AlberErre Jun 16, 2023
0ba4f38
chore: fix spacing
AlberErre Jun 16, 2023
8b2234b
feat: implement run_worm_help_command on test
AlberErre Jun 16, 2023
7c95867
feat: reduce complexity on chain-id tests
AlberErre Jun 16, 2023
1427ee1
feat: use wormhole-sdk chain as consts
AlberErre Jun 17, 2023
5f4931a
feat: dinamically test chain-id functionality
AlberErre Jun 17, 2023
3b66bea
feat: derive chain list for chain-id tests
AlberErre Jun 17, 2023
604dd9f
feat: add failed case for chain-id
AlberErre Jun 17, 2023
f2c4f68
refactor: check args using array
AlberErre Jun 17, 2023
e126ab7
feat: test multiple args on contract info command
AlberErre Jun 18, 2023
d8e275a
feat: extract positional arguments checker function
AlberErre Jun 18, 2023
1902ff4
feat: use test_command_positional_args on tests
AlberErre Jun 18, 2023
9385396
chore: rename chain-id file
AlberErre Jun 18, 2023
2fba93b
feat: add contract tests & export getChains method
AlberErre Jun 18, 2023
cc47dd6
feat: update errors & handle contract error cases
AlberErre Jun 18, 2023
5815d78
refactor: utils
AlberErre Jun 18, 2023
2fb1c54
fix: deep equality does not match, use toContain
AlberErre Jun 18, 2023
f6398e3
feat: add NFTBridge and TokenBridge contract cases
AlberErre Jun 18, 2023
2c48502
feat: update deploy contract errors method
AlberErre Jun 18, 2023
274d08f
feat: run contract tests by network
AlberErre Jun 18, 2023
a0c2916
fix: testnet aptos nft_bridge missing contract
AlberErre Jun 18, 2023
c51f963
feat: singleton to avoid execSync runs on all test
AlberErre Jun 18, 2023
60d97e9
chore: rename contract
AlberErre Jun 18, 2023
ea48f8b
feat: update rpc args test
AlberErre Jun 18, 2023
38d1c25
feat: update rpc functionality tests
AlberErre Jun 18, 2023
c7c4ffd
feat: update info namespace tests
AlberErre Jun 18, 2023
47f0a78
chore: move into info folder
AlberErre Jun 18, 2023
c197a83
feat: add failure cases for contract tests
AlberErre Jun 18, 2023
4ded5eb
chore: move into utils folder
AlberErre Jun 18, 2023
b014038
feat: add test_command_flags method
AlberErre Jun 18, 2023
7544eeb
feat: update submit tests
AlberErre Jun 18, 2023
f1fa665
feat: handle flag alias on test_command_flags
AlberErre Jun 18, 2023
a56068b
feat: update submit tests (flags)
AlberErre Jun 18, 2023
bf68b41
feat: update worm recover tests
AlberErre Jun 19, 2023
c3f2eb7
feat: update worm parse tests
AlberErre Jun 19, 2023
8828e9e
feat: add edit-vaa tests
AlberErre Jun 19, 2023
61c91d2
feat: add verify-vaa tests
AlberErre Jun 19, 2023
bbd0db0
feat: add worm info emitter & origin tests
AlberErre Jun 19, 2023
352d160
feat: add worm info registrations tests
AlberErre Jun 19, 2023
ecf2509
feat: add worm info wrapped tests
AlberErre Jun 19, 2023
ad388d7
chore: ignore utils folder while testing
AlberErre Jun 19, 2023
4e7d715
fix: skip tests until wormhole SDK publish
AlberErre Jun 19, 2023
6a194f0
feat: extract tests utils
AlberErre Jun 19, 2023
024951f
feat: update utils imports
AlberErre Jun 19, 2023
fdf9374
fix: guard using regex
AlberErre Jun 20, 2023
bd6c56c
feat: add skip param
AlberErre Jun 20, 2023
37fd1b9
feat: add aptos tests (missing 2 with errors)
AlberErre Jun 20, 2023
f63cd7e
feat: add evm tests
AlberErre Jun 20, 2023
72924f8
feat: add near tests
AlberErre Jun 20, 2023
6f43fa2
feat: add sui tests
AlberErre Jun 20, 2023
dd51d07
feat: add worm generate tests
AlberErre Jun 20, 2023
905796c
chore: add jest-html-reporters dependency
AlberErre Jun 20, 2023
4f2ea70
feat: generate HTML worm-cli-tests-report
AlberErre Jun 20, 2023
ad700e1
chore: update CHANGELOG (v0.0.4)
AlberErre Jun 20, 2023
d0894cb
chore: bump worm cli version (v0.0.4)
AlberErre Jun 20, 2023
3de613d
feat: avoid false positives with alias matching
AlberErre Jun 20, 2023
08a029a
feat: update npm commands for Githun Actions CI
AlberErre Jun 21, 2023
6ba0afb
feat: add worm cli github actions
AlberErre Jun 21, 2023
8ee9b94
feat: update npm commands for Githun Actions CI
AlberErre Jun 21, 2023
916ff2b
feat: add worm cli github actions
AlberErre Jun 21, 2023
90f30e3
chore: add PR source con skip comment
AlberErre Jun 21, 2023
49613fc
chore: update comments on aptos (runtime errors)
AlberErre Jun 21, 2023
b8a49c5
feat: save HTML test report as artifact
AlberErre Jun 21, 2023
22053fc
feat: save HTML test report as artifact
AlberErre Jun 21, 2023
7c4d438
fix: aptos testsnet unstable, handle case manually
AlberErre Jun 21, 2023
dfe8c99
chore: update github action, show report correctly
AlberErre Jun 21, 2023
f8077af
chore: update github action, show report correctly
AlberErre Jun 21, 2023
70db9f1
test: skip heavy tests to try out github action
AlberErre Jun 21, 2023
33772de
test: rollback, unskip heavy tests
AlberErre Jun 21, 2023
b7a6792
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jun 21, 2023
82d6e78
chore: update package-lock after merge main
AlberErre Jun 21, 2023
770f061
fix: rollback fake aptos contract
AlberErre Jun 22, 2023
9012ded
Merge branch 'wormhole-foundation:main' into clients/js/worm-cli-tests
AlberErre Jun 22, 2023
4e3ad78
Merge branch 'wormhole-foundation:main' into clients/js/worm-cli-tests
AlberErre Jun 22, 2023
a3389ff
Merge branch 'main' of https://github.com/AlberErre/wormhole
AlberErre Jun 22, 2023
0d44d8f
feat: remove aptos case on tests after PR merge
AlberErre Jun 22, 2023
3153fd1
fix: add missing CommandModule type
AlberErre Jun 23, 2023
351da33
chore: rm unused import
AlberErre Jun 23, 2023
8d97c21
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jun 23, 2023
f300ae3
Merge branch 'wormhole-foundation:main' into main
AlberErre Jul 3, 2023
fecd1f7
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jul 4, 2023
7bb6636
fix: add YargsCommandModule to new module
AlberErre Jul 3, 2023
07ea440
fix: override auto-detected locale by OS system
AlberErre Jul 3, 2023
b419ba1
feat: infere command modules on doc.ts & main.ts
AlberErre Jul 4, 2023
7eb70f5
feat: command args accepts an array of modules
AlberErre Jul 4, 2023
f6cb226
feat: test positional args against README file
AlberErre Jul 4, 2023
7847f96
feat: add cmd tests for README comparison method
AlberErre Jul 4, 2023
319e9cf
fix: cmds must be outside main, breaks otherwise
AlberErre Jul 4, 2023
82b3eb7
feat: test_command_args_with_readme_file method
AlberErre Jul 4, 2023
7c2880e
fix: import CLI_COMMAND_MODULES outside of main
AlberErre Jul 4, 2023
057ccbb
chore: test command from package.json
AlberErre Jul 4, 2023
2870782
chore: add missing transfer command from README
AlberErre Jul 4, 2023
884c8c9
refactor: clean previous command builders
AlberErre Jul 4, 2023
24c61c1
refactor: clean args specific tests
AlberErre Jul 4, 2023
6608f78
Merge branch 'wormhole-foundation:main' into main
AlberErre Jul 6, 2023
38cfe5d
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jul 6, 2023
ffab4b7
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jul 6, 2023
371d9e6
refactor: rm utils file &s simplify cmds tests
AlberErre Jul 6, 2023
c5db457
feat: init submit tests
AlberErre Jul 9, 2023
df471b3
refactor: simplify WORM_CLI_PATH
AlberErre Jul 9, 2023
1fb7878
feat: set ContractUpgrade cases & args
AlberErre Jul 9, 2023
1413a05
fix: add missing CommandModule type
AlberErre Jun 23, 2023
c65cd13
chore: rm unused import
AlberErre Jun 23, 2023
c8f4759
fix: override auto-detected locale by OS system
AlberErre Jul 3, 2023
9d27611
feat: infere command modules on doc.ts & main.ts
AlberErre Jul 4, 2023
b98eec9
feat: command args accepts an array of modules
AlberErre Jul 4, 2023
98b0319
fix: cmds must be outside main, breaks otherwise
AlberErre Jul 4, 2023
d80a53c
fix: import CLI_COMMAND_MODULES outside of main
AlberErre Jul 4, 2023
b39c548
chore: add missing transfer command from README
AlberErre Jul 4, 2023
7eb8a74
chore: rm test branch dependencies
AlberErre Jul 9, 2023
6402d1b
feat: extract info cmds into array const
AlberErre Jul 9, 2023
1209c61
chore: document command imports as list
AlberErre Jul 9, 2023
fd009f4
chore: package.json spacing
AlberErre Jul 9, 2023
552a68c
Merge branch 'main' into clients/js/refactor-cmds
AlberErre Jul 9, 2023
ae13aa7
chore: bump @types/yargs version
AlberErre Jul 9, 2023
6bdb56b
feat: cast correct array type YargsCommandModule[]
AlberErre Jul 9, 2023
dab913a
Merge branch 'main' into clients/js/refactor-cmds
AlberErre Jul 10, 2023
4630ca0
Merge branch 'clients/js/refactor-cmds' into clients/js/worm-cli-tests
AlberErre Jul 12, 2023
03aecd0
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jul 12, 2023
4127067
Merge branch 'wormhole-foundation:main' into main
AlberErre Jul 12, 2023
29c595f
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jul 12, 2023
ca21b3d
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jul 12, 2023
57a88b4
feat: use simple array for networks on tests utils
AlberErre Jul 13, 2023
c756c3a
Merge branch 'clients/js/worm-cli-tests' of https://github.com/AlberE…
AlberErre Jul 13, 2023
29f3b45
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jul 13, 2023
9b87827
Merge branch 'clients/js/worm-cli-tests' into clients/js/test-worm-cl…
AlberErre Jul 15, 2023
720366b
feat: sample solana tokenBridge vaa
AlberErre Jul 15, 2023
2f15023
chore: install msw
AlberErre Jul 15, 2023
b9f6194
feat: init msw capture server
AlberErre Jul 15, 2023
fb6fe52
chore: add missing worm-cli file
AlberErre Jul 15, 2023
d9b2b76
fix: add missing env chain values
AlberErre Jul 15, 2023
58fef01
chore: add .env.test file (jest environment)
AlberErre Jul 15, 2023
ec27faf
feat: load .env.test into jest environment
AlberErre Jul 15, 2023
79308bf
Merge branch 'main' into clients/js/worm-cli-tests
AlberErre Jul 17, 2023
1136d3a
wip: tests API calls for solana
AlberErre Jul 17, 2023
bc0aac4
Merge branch 'clients/js/worm-cli-tests' into clients/js/test-worm-cl…
AlberErre Jul 19, 2023
0a51c29
feat: use worm generate to dynamically get vaa
AlberErre Jul 19, 2023
e87e14f
feat: handle solana request handler
AlberErre Jul 19, 2023
aa200ac
feat: test to verify transaction is sent on solana
AlberErre Jul 19, 2023
0588206
feat: update submit test to handle all VAA modules
AlberErre Jul 19, 2023
725c14c
feat: add negative case for submit on solana
AlberErre Jul 19, 2023
4427862
chore: update test name
AlberErre Jul 20, 2023
17d1aa7
feat: add ethereum tests
AlberErre Jul 20, 2023
f180f46
refactor: msw into folder
AlberErre Jul 20, 2023
3ba673d
chore: update test descriptions
AlberErre Jul 20, 2023
10f414f
wip: generate all evm chains tests dinamically
AlberErre Jul 20, 2023
59ca516
feat: update handlers for evm chains (mainnet)
AlberErre Jul 20, 2023
6b9bddc
feat: rm evm chains that does not work on mainnet
AlberErre Jul 20, 2023
f226499
chore: add comment
AlberErre Jul 20, 2023
e568b6a
feat: handle gnosis case (just Core contract)
AlberErre Jul 20, 2023
1ff2f65
feat: add vaa from other chain test cases
AlberErre Jul 21, 2023
83b7a93
fix: rm 'only' keyword from tests
AlberErre Jul 21, 2023
91678b5
feat: add aptos test cases
AlberErre Jul 21, 2023
5a87a3c
fix: get both aptos simulated & actual transaction
AlberErre Jul 22, 2023
ab4161f
feat: handle sui test cases
AlberErre Jul 22, 2023
008ce29
feat: add near tests cases
AlberErre Jul 22, 2023
1767c25
feat: msw version node16 compatible (fetch method)
AlberErre Jul 22, 2023
a7ec506
feat: add algorand test cases
AlberErre Jul 22, 2023
4ab59d0
refactor: extract failure cases into functions
AlberErre Jul 22, 2023
6a08680
feat: add xpla test cases
AlberErre Jul 23, 2023
c27f339
feat: extract into array
AlberErre Jul 23, 2023
f8c3cf9
feat: add sei test cases
AlberErre Jul 23, 2023
b2f33a6
feat: add injective test cases
AlberErre Jul 23, 2023
f8c2faa
feat: add terra2 test cases
AlberErre Jul 23, 2023
b3d19f0
feat: add terra test cases
AlberErre Jul 23, 2023
45b19e7
feat: rm only flag
AlberErre Jul 23, 2023
7378357
feat: add failure test cosmwasm & increase timeout
AlberErre Jul 23, 2023
0a510f7
refactor: msw handlers
AlberErre Jul 23, 2023
f1bf862
feat: handle sei tests case (broadcast_tx_sync)
AlberErre Jul 23, 2023
e1b23c0
feat: update testTimeout
AlberErre Jul 23, 2023
bcf9d35
feat: add missing evm chains (test cases)
AlberErre Jul 23, 2023
4794f1a
feat: rename env values to .env.mock.jest
AlberErre Jul 23, 2023
3c9f5df
chore: update CHANGELOG
AlberErre Jul 23, 2023
302f673
chore: remove HTML report generation
AlberErre Jul 23, 2023
b1484ed
chore: gitignore spacing
AlberErre Jul 23, 2023
cde78ad
Merge branch 'main' into clients/js/test-worm-cli-submit-all-chains
AlberErre Jul 23, 2023
35bcced
Merge branch 'wormhole-foundation:main' into main
AlberErre Jul 23, 2023
73e41df
Update worm-cli.yml
AlberErre Jul 23, 2023
9da8493
Merge branch 'main' into clients/js/test-worm-cli-submit-all-chains
AlberErre Jul 30, 2023
5107ded
chore: rollback .env.sample changes
AlberErre Jul 30, 2023
3562193
feat: refactor env value handling into utils/env
AlberErre Jul 30, 2023
b1f04db
feat: handle file path & add try-catch
AlberErre Jul 30, 2023
bc85e40
Merge branch 'main' into clients/js/test-worm-cli-submit-all-chains
AlberErre Aug 5, 2023
12db2d3
feat: refactor env injection into wormSubmitCliEnv
AlberErre Aug 5, 2023
ba13cf3
feat: isolate env injection for worm submit tests
AlberErre Aug 5, 2023
5aa21a2
fix: types issues with wormSubmitCliEnv
AlberErre Aug 5, 2023
77d03f6
fix: inject env only if missing (CI env conflicts)
AlberErre Aug 6, 2023
1525ccd
Merge branch 'wormhole-foundation:main' into main
AlberErre Aug 6, 2023
01eac4b
fix: network & rpc blocking issues (moonbean, sei)
AlberErre Aug 6, 2023
e6c64ae
Merge branch 'main' into clients/js/test-worm-cli-submit-all-chains
AlberErre Aug 6, 2023
694d758
chore: comment sei (network issues 'EPIPE')
AlberErre Aug 6, 2023
28eaad7
chore: add --watchAll flag on local tests
AlberErre Aug 6, 2023
eac69f4
fix: clean responses after each test
AlberErre Aug 6, 2023
1251343
fix: maxWorkers flag on CI (avoid network issues)
AlberErre Aug 6, 2023
c929e89
fix: moonbeam rpc server fails without notice
AlberErre Aug 7, 2023
990e313
Merge branch 'wormhole-foundation:main' into main
AlberErre Aug 14, 2023
5603371
Update worm-cli.yml
AlberErre Aug 14, 2023
890895e
Update worm-cli.yml
AlberErre Aug 14, 2023
8c3f6f1
Update worm-cli.yml
AlberErre Aug 14, 2023
533d80b
Update worm-cli.yml
AlberErre Aug 14, 2023
03b6b17
Merge branch 'main' into clients/js/test-worm-cli-submit-all-chains
AlberErre Aug 14, 2023
c0e1d2e
chore: update package-lock after merge
AlberErre Aug 14, 2023
56c168b
Update worm-cli.yml
AlberErre Aug 14, 2023
8d50f98
Merge branch 'main' into clients/js/test-worm-cli-submit-all-chains
AlberErre Aug 14, 2023
c8cd0bd
feat: move jest setup into command flag arg
AlberErre Aug 14, 2023
877b57b
fix: comonjs export
AlberErre Aug 14, 2023
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
35 changes: 35 additions & 0 deletions .github/workflows/worm-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Worm CLI

on:
workflow_dispatch:
pull_request:
push:
branches: [main]

jobs:
worm-cli:
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install
working-directory: ./clients/js
run: |
npm ci

- name: build worm CLI (Makefile)
working-directory: ./clients/js
run: |
npm run make

- name: Run tests
working-directory: ./clients/js
run: |
npm run test-ci
2 changes: 1 addition & 1 deletion clients/js/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
INFURA_KEY=""
ETH_KEY=""
TERRA_MNEMONIC=""
SOLANA_KEY=""
SOLANA_KEY=""
14 changes: 14 additions & 0 deletions clients/js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.0.4

### Changed

- Add Github Actions CI pipeline for Worm CLI `build` & `test` processes (`.github/workflows/worm-cli.yml`)
- Add unit test to verify all worm CLI commands are in sync with documentation (`cmds.test.ts`)
- Add unit tests to check functionality on the following commands:
- `worm submit` (using msw)
- `worm parse`
- `worm recover`
- `worm info chain-id`
- `worm info rpc`
- `worm info contract`

## 0.0.3

### Changed
Expand Down
34 changes: 34 additions & 0 deletions clients/js/__tests__/cmds.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { describe, it, expect } from "@jest/globals";
import * as fs from "fs";
import { CLI_COMMAND_MODULES } from "../src/cmds";
import { run_worm_help_command } from "./utils/cli";

const readme = fs.readFileSync("./README.md", "utf8");

const getCommandNamesFromCommandModules = (
cmdModules: typeof CLI_COMMAND_MODULES
) => {
return cmdModules
.map((cmdModule) => cmdModule.command)
.map(
(commandStr) => commandStr.split("<")[0].trim() //Removing <positional> arguments from commands module strings
);
};

const getCommandWithArgsFromOutput = (rawOutput: string) => {
return rawOutput.split("worm")[1].split("\n")[0].trim();
};

const commandNames = getCommandNamesFromCommandModules(CLI_COMMAND_MODULES);

commandNames.forEach((cmd) => {
describe(`worm ${cmd}`, () => {
it(`should have same command args as documentation`, async () => {
// Run the command module with --help as argument
const output = run_worm_help_command(cmd);
const commandWithArgs = getCommandWithArgsFromOutput(output);

expect(readme).toContain(commandWithArgs);
});
});
});
29 changes: 29 additions & 0 deletions clients/js/__tests__/info/chain-id.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { describe, expect, it } from "@jest/globals";
import { run_worm_command } from "../utils/cli";
import { CHAINS } from "@certusone/wormhole-sdk/lib/esm/utils/consts";
import { YARGS_COMMAND_FAILED } from "../utils/errors";
import { WormholeSDKChainName, getChains } from "../utils/getters";

describe("worm info chain-id", () => {
describe("check functionality", () => {
const chains: WormholeSDKChainName[] = getChains();

chains.forEach((chain) => {
it(`should return ${chain} chain-id correctly`, async () => {
const output = run_worm_command(`info chain-id ${chain}`);
expect(output).toContain(CHAINS[chain].toString());
});
});
});

describe("check failures", () => {
it(`should fail if chain does not exist`, async () => {
const fakeChain = "IDontExist";
try {
run_worm_command(`info chain-id ${fakeChain}`);
} catch (error) {
expect((error as Error).message).toContain(YARGS_COMMAND_FAILED);
}
});
});
});
92 changes: 92 additions & 0 deletions clients/js/__tests__/info/contract.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { describe, expect, it } from "@jest/globals";
import { run_worm_command } from "../utils/cli";
import {
CONTRACTS,
Network,
} from "@certusone/wormhole-sdk/lib/esm/utils/consts";
import { CONTRACT_NOT_DEPLOYED, YARGS_COMMAND_FAILED } from "../utils/errors";
import { getChains, networks } from "../utils/getters";

describe("worm info contract", () => {
describe("check functionality", () => {
const chains = getChains();

networks.forEach((network) => {
const NETWORK = network.toUpperCase() as Network;

describe(`should return ${network} contracts`, () => {
chains.forEach((chain) => {
it(`should return ${chain} core ${network} contract correctly`, async () => {
try {
const output = run_worm_command(
`info contract ${network} ${chain} Core`
);
expect(output).toContain(CONTRACTS[NETWORK][chain]["core"]);
} catch (error) {
expect((error as Error).message).toContain(
CONTRACT_NOT_DEPLOYED(chain, "Core")
);
}
});

it(`should return ${chain} NFTBridge ${network} contract correctly`, async () => {
try {
const output = run_worm_command(
`info contract ${network} ${chain} NFTBridge`
);
expect(output).toContain(CONTRACTS[NETWORK][chain]["nft_bridge"]);
} catch (error) {
expect((error as Error).message).toContain(
CONTRACT_NOT_DEPLOYED(chain, "NFTBridge")
);
}
});

it(`should return ${chain} TokenBridge ${network} contract correctly`, async () => {
try {
const output = run_worm_command(
`info contract ${network} ${chain} TokenBridge`
);
expect(output).toContain(
CONTRACTS[NETWORK][chain]["token_bridge"]
);
} catch (error) {
expect((error as Error).message).toContain(
CONTRACT_NOT_DEPLOYED(chain, "TokenBridge")
);
}
});
});
});
});
});

describe("check failures", () => {
it(`should fail if network does not exist`, async () => {
const fakeNetwork = "DoesNotExist";
try {
run_worm_command(`info contract ${fakeNetwork} solana Core`);
} catch (error) {
expect((error as Error).message).toContain(YARGS_COMMAND_FAILED);
}
});

it(`should fail if chain does not exist`, async () => {
const fakeChain = "DoesNotExist";
try {
run_worm_command(`info contract mainnet ${fakeChain} Core`);
} catch (error) {
expect((error as Error).message).toContain(YARGS_COMMAND_FAILED);
}
});

it(`should fail if module (Core, NFTBridge, TokenBridge) does not exist`, async () => {
const fakeModule = "DoesNotExist";
try {
run_worm_command(`info contract mainnet solana ${fakeModule}`);
} catch (error) {
expect((error as Error).message).toContain(YARGS_COMMAND_FAILED);
}
});
});
});
23 changes: 23 additions & 0 deletions clients/js/__tests__/info/rpc.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { describe, expect, it } from "@jest/globals";
import { run_worm_command } from "../utils/cli";
import { NETWORKS as RPC_NETWORKS } from "../../src/consts/networks";
import { getChains, networks } from "../utils/getters";
import { Network } from "@certusone/wormhole-sdk/lib/esm/utils/consts";

describe("worm info rpc", () => {
describe("check functionality", () => {
const chains = getChains();

networks.forEach((network) => {
const NETWORK = network.toUpperCase() as Network;

chains.forEach((chain) => {
it(`should return ${chain} ${network} rpc correctly`, async () => {
const output = run_worm_command(`info rpc ${network} ${chain}`);

expect(output).toContain(String(RPC_NETWORKS[NETWORK][chain].rpc));
});
});
});
});
});
124 changes: 124 additions & 0 deletions clients/js/__tests__/parse.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { describe, expect, it } from "@jest/globals";
import { run_worm_command } from "./utils/cli";

describe("worm parse", () => {
describe("check functionality", () => {
const vaa =
"01000000010d0012e6b39c6da90c5dfd3c228edbb78c7a4c97c488ff8a346d161a91db067e51d638c17216f368aa9bdf4836b8645a98018ca67d2fec87d769cabfdf2406bf790a0002ef42b288091a670ef3556596f4f47323717882881eaf38e03345078d07a156f312b785b64dae6e9a87e3d32872f59cb1931f728cecf511762981baf48303668f0103cef2616b84c4e511ff03329e0853f1bd7ee9ac5ba71d70a4d76108bddf94f69c2a8a84e4ee94065e8003c334e899184943634e12043d0dda78d93996da073d190104e76d166b9dac98f602107cc4b44ac82868faf00b63df7d24f177aa391e050902413b71046434e67c770b19aecdf7fce1d1435ea0be7262e3e4c18f50ddc8175c0105d9450e8216d741e0206a50f93b750a47e0a258b80eb8fed1314cc300b3d905092de25cd36d366097b7103ae2d184121329ba3aa2d7c6cc53273f11af14798110010687477c8deec89d36a23e7948feb074df95362fc8dcbd8ae910ac556a1dee1e755c56b9db5d710c940938ed79bc1895a3646523a58bc55f475a23435a373ecfdd0107fb06734864f79def4e192497362513171530daea81f07fbb9f698afe7e66c6d44db21323144f2657d4a5386a954bb94eef9f64148c33aef6e477eafa2c5c984c01088769e82216310d1827d9bd48645ec23e90de4ef8a8de99e2d351d1df318608566248d80cdc83bdcac382b3c30c670352be87f9069aab5037d0b747208eae9c650109e9796497ff9106d0d1c62e184d83716282870cef61a1ee13d6fc485b521adcce255c96f7d1bca8d8e7e7d454b65783a830bddc9d94092091a268d311ecd84c26010c468c9fb6d41026841ff9f8d7368fa309d4dbea3ea4bbd2feccf94a92cc8a20a226338a8e2126cd16f70eaf15b4fc9be2c3fa19def14e071956a605e9d1ac4162010e23fcb6bd445b7c25afb722250c1acbc061ed964ba9de1326609ae012acdfb96942b2a102a2de99ab96327859a34a2b49a767dbdb62e0a1fb26af60fe44fd496a00106bb0bac77ac68b347645f2fb1ad789ea9bd76fb9b2324f25ae06f97e65246f142df717f662e73948317182c62ce87d79c73def0dba12e5242dfc038382812cfe00126da03c5e56cb15aeeceadc1e17a45753ab4dc0ec7bf6a75ca03143ed4a294f6f61bc3f478a457833e43084ecd7c985bf2f55a55f168aac0e030fc49e845e497101626e9d9a5d9e343f00010000000000000000000000000000000000000000000000000000000000000004c1759167c43f501c2000000000000000000000000000000000000000000000000000000000436f7265020000000000021358cc3ae5c097b213ce3c81979e1b9f9570746aa5ff6cb952589bde862c25ef4392132fb9d4a42157114de8460193bdf3a2fcf81f86a09765f4762fd1107a0086b32d7a0977926a205131d8731d39cbeb8c82b2fd82faed2711d59af0f2499d16e726f6b211b39756c042441be6d8650b69b54ebe715e234354ce5b4d348fb74b958e8966e2ec3dbd4958a7cd66b9590e1c41e0b226937bf9217d1d67fd4e91f574a3bf913953d695260d88bc1aa25a4eee363ef0000ac0076727b35fbea2dac28fee5ccb0fea768eaf45ced136b9d9e24903464ae889f5c8a723fc14f93124b7c738843cbb89e864c862c38cddcccf95d2cc37a4dc036a8d232b48f62cdd4731412f4890da798f6896a3331f64b48c12d1d57fd9cbe7081171aa1be1d36cafe3867910f99c09e347899c19c38192b6e7387ccd768277c17dab1b7a5027c0b3cf178e21ad2e77ae06711549cfbb1f9c7a9d8096e85e1487f35515d02a92753504a8d75471b9f49edb6fbebc898f403e4773e95feb15e80c9a99c8348d%";

const expectedResult = {
version: 1,
guardianSetIndex: 1,
signatures: [
{
guardianSetIndex: 0,
signature:
"12e6b39c6da90c5dfd3c228edbb78c7a4c97c488ff8a346d161a91db067e51d638c17216f368aa9bdf4836b8645a98018ca67d2fec87d769cabfdf2406bf790a00",
},
{
guardianSetIndex: 2,
signature:
"ef42b288091a670ef3556596f4f47323717882881eaf38e03345078d07a156f312b785b64dae6e9a87e3d32872f59cb1931f728cecf511762981baf48303668f01",
},
{
guardianSetIndex: 3,
signature:
"cef2616b84c4e511ff03329e0853f1bd7ee9ac5ba71d70a4d76108bddf94f69c2a8a84e4ee94065e8003c334e899184943634e12043d0dda78d93996da073d1901",
},
{
guardianSetIndex: 4,
signature:
"e76d166b9dac98f602107cc4b44ac82868faf00b63df7d24f177aa391e050902413b71046434e67c770b19aecdf7fce1d1435ea0be7262e3e4c18f50ddc8175c01",
},
{
guardianSetIndex: 5,
signature:
"d9450e8216d741e0206a50f93b750a47e0a258b80eb8fed1314cc300b3d905092de25cd36d366097b7103ae2d184121329ba3aa2d7c6cc53273f11af1479811001",
},
{
guardianSetIndex: 6,
signature:
"87477c8deec89d36a23e7948feb074df95362fc8dcbd8ae910ac556a1dee1e755c56b9db5d710c940938ed79bc1895a3646523a58bc55f475a23435a373ecfdd01",
},
{
guardianSetIndex: 7,
signature:
"fb06734864f79def4e192497362513171530daea81f07fbb9f698afe7e66c6d44db21323144f2657d4a5386a954bb94eef9f64148c33aef6e477eafa2c5c984c01",
},
{
guardianSetIndex: 8,
signature:
"8769e82216310d1827d9bd48645ec23e90de4ef8a8de99e2d351d1df318608566248d80cdc83bdcac382b3c30c670352be87f9069aab5037d0b747208eae9c6501",
},
{
guardianSetIndex: 9,
signature:
"e9796497ff9106d0d1c62e184d83716282870cef61a1ee13d6fc485b521adcce255c96f7d1bca8d8e7e7d454b65783a830bddc9d94092091a268d311ecd84c2601",
},
{
guardianSetIndex: 12,
signature:
"468c9fb6d41026841ff9f8d7368fa309d4dbea3ea4bbd2feccf94a92cc8a20a226338a8e2126cd16f70eaf15b4fc9be2c3fa19def14e071956a605e9d1ac416201",
},
{
guardianSetIndex: 14,
signature:
"23fcb6bd445b7c25afb722250c1acbc061ed964ba9de1326609ae012acdfb96942b2a102a2de99ab96327859a34a2b49a767dbdb62e0a1fb26af60fe44fd496a00",
},
{
guardianSetIndex: 16,
signature:
"6bb0bac77ac68b347645f2fb1ad789ea9bd76fb9b2324f25ae06f97e65246f142df717f662e73948317182c62ce87d79c73def0dba12e5242dfc038382812cfe00",
},
{
guardianSetIndex: 18,
signature:
"6da03c5e56cb15aeeceadc1e17a45753ab4dc0ec7bf6a75ca03143ed4a294f6f61bc3f478a457833e43084ecd7c985bf2f55a55f168aac0e030fc49e845e497101",
},
],
timestamp: 1651416474,
nonce: 1570649151,
emitterChain: 1,
emitterAddress:
"0x0000000000000000000000000000000000000000000000000000000000000004",
sequence: "13940208096455381020",
consistencyLevel: 32,
payload: {
module: "Core",
type: "GuardianSetUpgrade",
chain: 0,
newGuardianSetIndex: 2,
newGuardianSetLength: 19,
newGuardianSet: [
"58cc3ae5c097b213ce3c81979e1b9f9570746aa5",
"ff6cb952589bde862c25ef4392132fb9d4a42157",
"114de8460193bdf3a2fcf81f86a09765f4762fd1",
"107a0086b32d7a0977926a205131d8731d39cbeb",
"8c82b2fd82faed2711d59af0f2499d16e726f6b2",
"11b39756c042441be6d8650b69b54ebe715e2343",
"54ce5b4d348fb74b958e8966e2ec3dbd4958a7cd",
"66b9590e1c41e0b226937bf9217d1d67fd4e91f5",
"74a3bf913953d695260d88bc1aa25a4eee363ef0",
"000ac0076727b35fbea2dac28fee5ccb0fea768e",
"af45ced136b9d9e24903464ae889f5c8a723fc14",
"f93124b7c738843cbb89e864c862c38cddcccf95",
"d2cc37a4dc036a8d232b48f62cdd4731412f4890",
"da798f6896a3331f64b48c12d1d57fd9cbe70811",
"71aa1be1d36cafe3867910f99c09e347899c19c3",
"8192b6e7387ccd768277c17dab1b7a5027c0b3cf",
"178e21ad2e77ae06711549cfbb1f9c7a9d8096e8",
"5e1487f35515d02a92753504a8d75471b9f49edb",
"6fbebc898f403e4773e95feb15e80c9a99c8348d",
],
},
digest:
"0x99656f88302bda18573212d4812daeea7d39f8af695db1fbc4d99fd94f552606",
};

it(`should return expected parse result from vaa`, async () => {
const output = run_worm_command(`parse ${vaa}`);

expect(JSON.parse(output)).toEqual(expectedResult);
});
});
});
21 changes: 21 additions & 0 deletions clients/js/__tests__/recover.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { describe, expect, it } from "@jest/globals";
import { run_worm_command } from "./utils/cli";

describe("worm recover", () => {
describe("check functionality", () => {
//mocks
const digest =
"0x99656f88302bda18573212d4812daeea7d39f8af695db1fbc4d99fd94f552606";
const signature =
"6da03c5e56cb15aeeceadc1e17a45753ab4dc0ec7bf6a75ca03143ed4a294f6f61bc3f478a457833e43084ecd7c985bf2f55a55f168aac0e030fc49e845e497101";

//expected output
const expectedAddress = "0x6FbEBc898F403E4773E95feB15E80C9A99c8348d";

it(`should return correct address from digest and signature`, async () => {
const output = run_worm_command(`recover ${digest} ${signature}`);

expect(output).toContain(expectedAddress);
});
});
});
Loading