From 80d488b8031d0c27b811dfd9c4ebd549f3dbd0c7 Mon Sep 17 00:00:00 2001 From: Hugo Caillard <911307+hugocaillard@users.noreply.github.com> Date: Tue, 25 Jul 2023 19:25:40 +0200 Subject: [PATCH] tests: add coverage --- .gitignore | 3 + package-lock.json | 515 +++++++++++++++++++++++++++++++++++- package.json | 9 +- unit-tests/pyth.test.js | 90 +++++-- unit-tests/wormhole.test.js | 64 +++-- 5 files changed, 622 insertions(+), 59 deletions(-) diff --git a/.gitignore b/.gitignore index cab0bb3..20d6943 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ history.txt relayer/target .DS_Store node_modules + +lcov.info +coverage/ diff --git a/package-lock.json b/package-lock.json index da6843c..e4269f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,28 @@ "license": "ISC", "dependencies": { "@stacks/transactions": "^6.5.4", - "obscurity-sdk": "^0.0.4" + "obscurity-sdk": "^0.0.5" + }, + "devDependencies": { + "@types/node": "^20.4.4", + "rimraf": "^5.0.1" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" } }, "node_modules/@noble/hashes": { @@ -35,6 +56,16 @@ } ] }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@stacks/common": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/@stacks/common/-/common-6.5.2.tgz", @@ -44,6 +75,11 @@ "@types/node": "^18.0.4" } }, + "node_modules/@stacks/common/node_modules/@types/node": { + "version": "18.17.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.0.tgz", + "integrity": "sha512-GXZxEtOxYGFchyUzxvKI14iff9KZ2DI+A6a37o6EQevtg6uO9t+aUZKcaC1Te5Ng1OnLM7K9NVVj+FbecD9cJg==" + }, "node_modules/@stacks/network": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/@stacks/network/-/network-6.5.4.tgz", @@ -75,15 +111,54 @@ } }, "node_modules/@types/node": { - "version": "18.16.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.19.tgz", - "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==" + "version": "20.4.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.4.tgz", + "integrity": "sha512-CukZhumInROvLq3+b5gLev+vgpsIqC2D0deQr/yS1WnxvmYLlJXZpaQrQiseMY+6xusl79E04UjWoqyr+t1/Ew==" + }, + "node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "node_modules/base-x": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.0.tgz", "integrity": "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==" }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, "node_modules/c32check": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/c32check/-/c32check-2.0.0.tgz", @@ -96,6 +171,24 @@ "node": ">=8" } }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "node_modules/cross-fetch": { "version": "3.1.8", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", @@ -104,11 +197,141 @@ "node-fetch": "^2.6.12" } }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true + }, + "node_modules/foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob": { + "version": "10.3.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.3.tgz", + "integrity": "sha512-92vPiMb/iqpmEgsOoIDvTjc50wf9CCCvMzsi6W0JLPeUKE8TWP1a73PgqSrqy7iAZxaSD1YdzU7QZR5LF51MJw==", + "dev": true, + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.0.3", + "minimatch": "^9.0.1", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", + "path-scurry": "^1.10.1" + }, + "bin": { + "glob": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/jackspeak": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.2.2.tgz", + "integrity": "sha512-mgNtVv4vUuaKA97yxUHoA3+FkuhtxkjdXEWOyB/N76fjy0FjezEt34oy3epBtvCvS+7DyKwqCFWx/oJLV5+kCg==", + "dev": true, + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, "node_modules/lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "integrity": "sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==" }, + "node_modules/lru-cache": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.0.0.tgz", + "integrity": "sha512-svTf/fzsKHffP42sujkO/Rjs37BCIsQVRCeNYIm9WN8rgT7ffoUnRtZCqU+6BqcSBdv8gwJeTz8knJpgACeQMw==", + "dev": true, + "engines": { + "node": "14 || >=16.14" + } + }, + "node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.0.2.tgz", + "integrity": "sha512-eL79dXrE1q9dBbDCLg7xfn/vl7MS4F1gvJAgjJrQli/jbQWdUttuVawphqpffoIYfRdq78LHx6GP4bU/EQ2ATA==", + "dev": true, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/node-fetch": { "version": "2.6.12", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", @@ -129,13 +352,185 @@ } }, "node_modules/obscurity-sdk": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/obscurity-sdk/-/obscurity-sdk-0.0.4.tgz", - "integrity": "sha512-99z8k8l/4cXejt9QsVa/hX09s2T9/gT1+UNfMoh8H2Hb8/E1AFAferHpGztNvhF3j1gx4D2dJeMmVBbu7UugKQ==", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/obscurity-sdk/-/obscurity-sdk-0.0.5.tgz", + "integrity": "sha512-cZLU6FYMAeMWqWiwwauJCCyC79FT19xwICk7XEWYwyqy8aHNG3i7J5HjlDduNLV2nFQXXaoHSMBiT4SNwQimfw==", "dependencies": { "@stacks/transactions": "^6.5.4" } }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.10.1.tgz", + "integrity": "sha512-MkhCqzzBEpPvxxQ71Md0b1Kk51W01lrYvlMzSUaIzNsODdd7mqhiimSZlr+VegAz5Z6Vzt9Xg2ttE//XBhH3EQ==", + "dev": true, + "dependencies": { + "lru-cache": "^9.1.1 || ^10.0.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/rimraf": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.1.tgz", + "integrity": "sha512-OfFZdwtd3lZ+XZzYP/6gTACubwFcHdLRqS9UX3UwpU2dnGQYkPFISRwvM3w9IiB2w7bW5qGo/uAwE4SmXXSKvg==", + "dev": true, + "dependencies": { + "glob": "^10.2.5" + }, + "bin": { + "rimraf": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", + "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -154,6 +549,112 @@ "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } } } } diff --git a/package.json b/package.json index 70db5ca..48e5621 100644 --- a/package.json +++ b/package.json @@ -7,13 +7,18 @@ "test": "unit-tests" }, "scripts": { - "test": "node --test" + "test": "node --test", + "coverage": "rimraf ./lcov.info; node --test " }, "author": "", "license": "ISC", "type": "module", "dependencies": { "@stacks/transactions": "^6.5.4", - "obscurity-sdk": "^0.0.4" + "obscurity-sdk": "^0.0.5" + }, + "devDependencies": { + "@types/node": "^20.4.4", + "rimraf": "^5.0.1" } } diff --git a/unit-tests/pyth.test.js b/unit-tests/pyth.test.js index 030c709..5a8792e 100644 --- a/unit-tests/pyth.test.js +++ b/unit-tests/pyth.test.js @@ -1,62 +1,96 @@ // @ts-check -import { before, describe, it } from "node:test"; +import { after, before, describe, it } from "node:test"; +import fs from "node:fs"; import assert from "node:assert/strict"; -import { main } from "obscurity-sdk"; +import path from "node:path"; +import initVM from "obscurity-sdk"; import { Cl } from "@stacks/transactions"; -import { mainnet_valid_guardians_set_upgrades, mainnet_valid_pfs } from "./constants.js"; +import { + mainnet_valid_guardians_set_upgrades, + mainnet_valid_pfs, +} from "./constants.js"; + +const pyth_oracle_v1_contract_name = "pyth-oracle-v1"; +let pyth_oracle_v1_contract_addr; +let wormhole_core_v1_contract_name = "wormhole-core-v1"; +let wormhole_core_v1_contract_addr; +let deployer; +let sender; +/** @type import("obscurity-sdk").ClarityVM */ +let vm; describe("Pyth testsuite", () => { - const cost = 1000000n; - const pyth_oracle_v1_contract_name = "pyth-oracle-v1"; - let pyth_oracle_v1_contract_addr; - let wormhole_core_v1_contract_name = "wormhole-core-v1"; - let wormhole_core_v1_contract_addr; - let deployer; - let sender; - /** @type import("obscurity-sdk").Session */ - let session; - before(async () => { - session = await main(); - await session.initSession(process.cwd(), "./Clarinet.toml"); - - const accounts = session.getAccounts(); + vm = await initVM(); + await vm.initSession(process.cwd(), "./Clarinet.toml"); + + const accounts = vm.getAccounts(); deployer = accounts.get("deployer"); pyth_oracle_v1_contract_addr = `${deployer}.${pyth_oracle_v1_contract_name}`; wormhole_core_v1_contract_addr = `${deployer}.${wormhole_core_v1_contract_name}`; sender = accounts.get("wallet_1"); }); - it("ensure that legitimate price attestations are validated", () => { + after(() => { + const lcov = vm.terminate(); + fs.appendFileSync(path.join(process.cwd(), "lcov.info"), lcov); + }); - const vaaRotation1 = Cl.bufferFromHex(mainnet_valid_guardians_set_upgrades[0].vaa); + it("ensure that legitimate price attestations are validated", () => { + const vaaRotation1 = Cl.bufferFromHex( + mainnet_valid_guardians_set_upgrades[0].vaa + ); let publicKeysRotation1 = []; for (let key of mainnet_valid_guardians_set_upgrades[0].keys) { - publicKeysRotation1.push(Cl.bufferFromHex(key)); + publicKeysRotation1.push(Cl.bufferFromHex(key)); } - const vaaRotation2 = Cl.bufferFromHex(mainnet_valid_guardians_set_upgrades[1].vaa); + const vaaRotation2 = Cl.bufferFromHex( + mainnet_valid_guardians_set_upgrades[1].vaa + ); let publicKeysRotation2 = []; for (let key of mainnet_valid_guardians_set_upgrades[1].keys) { - publicKeysRotation2.push(Cl.bufferFromHex(key)); + publicKeysRotation2.push(Cl.bufferFromHex(key)); } - const vaaRotation3 = Cl.bufferFromHex(mainnet_valid_guardians_set_upgrades[2].vaa); + const vaaRotation3 = Cl.bufferFromHex( + mainnet_valid_guardians_set_upgrades[2].vaa + ); let publicKeysRotation3 = []; for (let key of mainnet_valid_guardians_set_upgrades[2].keys) { - publicKeysRotation3.push(Cl.bufferFromHex(key)); + publicKeysRotation3.push(Cl.bufferFromHex(key)); } - session.callPublicFn(wormhole_core_v1_contract_name, "update-guardians-set", [vaaRotation1, Cl.list(publicKeysRotation1)], sender); + vm.callPublicFn( + wormhole_core_v1_contract_name, + "update-guardians-set", + [vaaRotation1, Cl.list(publicKeysRotation1)], + sender + ); - session.callPublicFn(wormhole_core_v1_contract_name, "update-guardians-set", [vaaRotation2, Cl.list(publicKeysRotation2)], sender); + vm.callPublicFn( + wormhole_core_v1_contract_name, + "update-guardians-set", + [vaaRotation2, Cl.list(publicKeysRotation2)], + sender + ); - session.callPublicFn(wormhole_core_v1_contract_name, "update-guardians-set", [vaaRotation3, Cl.list(publicKeysRotation3)], sender); + vm.callPublicFn( + wormhole_core_v1_contract_name, + "update-guardians-set", + [vaaRotation3, Cl.list(publicKeysRotation3)], + sender + ); const vaaBytes = Cl.bufferFromHex(mainnet_valid_pfs[0]); - let res = session.callPublicFn(pyth_oracle_v1_contract_name, "update-prices-feeds", [Cl.list([vaaBytes])], sender); + let res = vm.callPublicFn( + pyth_oracle_v1_contract_name, + "update-prices-feeds", + [Cl.list([vaaBytes])], + sender + ); console.log(res); }); diff --git a/unit-tests/wormhole.test.js b/unit-tests/wormhole.test.js index 58b9e48..b1892a6 100644 --- a/unit-tests/wormhole.test.js +++ b/unit-tests/wormhole.test.js @@ -1,55 +1,75 @@ // @ts-check -import { before, describe, it } from "node:test"; +import { after, before, describe, it } from "node:test"; +import fs from "node:fs"; import assert from "node:assert/strict"; -import { main } from "obscurity-sdk"; +import path from "node:path"; +import initVM from "obscurity-sdk"; import { Cl } from "@stacks/transactions"; -import { mainnet_valid_guardians_set_upgrades, mainnet_valid_pfs } from "./constants.js"; +import { mainnet_valid_guardians_set_upgrades } from "./constants.js"; + +let wormhole_core_v1_contract_name = "wormhole-core-v1"; +let wormhole_core_v1_contract_addr; +let deployer; +let sender; +/** @type import("../../clarinet/components/clarinet-sdk/dist/index").ClarityVM */ +let vm; describe("Wormhole testsuite", () => { - const cost = 1000000n; - let wormhole_core_v1_contract_name = "wormhole-core-v1"; - let wormhole_core_v1_contract_addr; - let deployer; - let sender; - /** @type import("obscurity-sdk").Session */ - let session; - before(async () => { - session = await main(); - await session.initSession(process.cwd(), "./Clarinet.toml"); - - const accounts = session.getAccounts(); + vm = await initVM(); + await vm.initSession(process.cwd(), "./Clarinet.toml"); + + const accounts = vm.getAccounts(); deployer = accounts.get("deployer"); wormhole_core_v1_contract_addr = `${deployer}.${wormhole_core_v1_contract_name}`; sender = accounts.get("wallet_1"); }); - it("ensure that guardians set can be rotated", () => { + after(() => { + const lcov = vm.terminate(); + fs.appendFileSync(path.join(process.cwd(), "lcov.info"), lcov); + }); + it("ensure that guardians set can be rotated", () => { const vaaRotation1 = Cl.bufferFromHex(mainnet_valid_guardians_set_upgrades[0].vaa); let publicKeysRotation1 = []; for (let key of mainnet_valid_guardians_set_upgrades[0].keys) { - publicKeysRotation1.push(Cl.bufferFromHex(key)); + publicKeysRotation1.push(Cl.bufferFromHex(key)); } const vaaRotation2 = Cl.bufferFromHex(mainnet_valid_guardians_set_upgrades[1].vaa); let publicKeysRotation2 = []; for (let key of mainnet_valid_guardians_set_upgrades[1].keys) { - publicKeysRotation2.push(Cl.bufferFromHex(key)); + publicKeysRotation2.push(Cl.bufferFromHex(key)); } const vaaRotation3 = Cl.bufferFromHex(mainnet_valid_guardians_set_upgrades[2].vaa); let publicKeysRotation3 = []; for (let key of mainnet_valid_guardians_set_upgrades[2].keys) { - publicKeysRotation3.push(Cl.bufferFromHex(key)); + publicKeysRotation3.push(Cl.bufferFromHex(key)); } - session.callPublicFn(wormhole_core_v1_contract_name, "update-guardians-set", [vaaRotation1, Cl.list(publicKeysRotation1)], sender); + vm.callPublicFn( + wormhole_core_v1_contract_name, + "update-guardians-set", + [vaaRotation1, Cl.list(publicKeysRotation1)], + sender + ); - session.callPublicFn(wormhole_core_v1_contract_name, "update-guardians-set", [vaaRotation2, Cl.list(publicKeysRotation2)], sender); + vm.callPublicFn( + wormhole_core_v1_contract_name, + "update-guardians-set", + [vaaRotation2, Cl.list(publicKeysRotation2)], + sender + ); - session.callPublicFn(wormhole_core_v1_contract_name, "update-guardians-set", [vaaRotation3, Cl.list(publicKeysRotation3)], sender); + vm.callPublicFn( + wormhole_core_v1_contract_name, + "update-guardians-set", + [vaaRotation3, Cl.list(publicKeysRotation3)], + sender + ); // // assert: review returned data, contract state, and other requirements // assertEquals(block.receipts.length, 3);