From 3860854a55bd9a3361a78102945971af87104301 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Tue, 24 Sep 2024 01:43:20 -0400 Subject: [PATCH] Test --- napi/.tsimp/daemon/log | 34 +++++++++ napi/.tsimp/daemon/mtime | 1 + napi/__test__/index.spec.mjs | 7 -- napi/__test__/index.spec.ts | 25 +++++++ napi/package.json | 12 +++- napi/pnpm-lock.yaml | 136 +++++++++++++++++++++++++++++++++++ napi/tsconfig.json | 8 +++ 7 files changed, 214 insertions(+), 9 deletions(-) create mode 100644 napi/.tsimp/daemon/log create mode 100644 napi/.tsimp/daemon/mtime delete mode 100644 napi/__test__/index.spec.mjs create mode 100644 napi/__test__/index.spec.ts create mode 100644 napi/tsconfig.json diff --git a/napi/.tsimp/daemon/log b/napi/.tsimp/daemon/log new file mode 100644 index 00000000..5fc4628c --- /dev/null +++ b/napi/.tsimp/daemon/log @@ -0,0 +1,34 @@ +/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:21622 + let moduleResolution = compilerOptions.moduleResolution; + ^ + +TypeError: Cannot read properties of undefined (reading 'moduleResolution') + at computeValue (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:21622:46) + at importSyntaxAffectsModuleResolution (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:21599:28) + at getDefaultResolutionModeForFileWorker (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:127780:10) + at Object.getMode (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:124407:85) + at Object.resolveTypeReferenceDirectiveReferences (file:///Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/tsimp@2.0.11_typescript@5.6.2/node_modules/tsimp/dist/esm/service/resolve-type-reference-directive-references.js:24:45) + at resolveTypeReferenceDirectiveNamesWorker (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:125232:20) + at resolveNamesReusingOldState (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:125354:14) + at resolveTypeReferenceDirectiveNamesReusingOldState (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:125325:12) + at processTypeReferenceDirectives (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:126706:156) + at findSourceFileWorker (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:126595:9) + +Node.js v21.7.0 +/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:21622 + let moduleResolution = compilerOptions.moduleResolution; + ^ + +TypeError: Cannot read properties of undefined (reading 'moduleResolution') + at computeValue (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:21622:46) + at importSyntaxAffectsModuleResolution (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:21599:28) + at getDefaultResolutionModeForFileWorker (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:127780:10) + at Object.getMode (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:124407:85) + at Object.resolveTypeReferenceDirectiveReferences (file:///Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/tsimp@2.0.11_typescript@5.6.2/node_modules/tsimp/dist/esm/service/resolve-type-reference-directive-references.js:24:45) + at resolveTypeReferenceDirectiveNamesWorker (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:125232:20) + at resolveNamesReusingOldState (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:125354:14) + at resolveTypeReferenceDirectiveNamesReusingOldState (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:125325:12) + at processTypeReferenceDirectives (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:126706:156) + at findSourceFileWorker (/Users/rigidity/Desktop/wallet-sdk/napi/node_modules/.pnpm/typescript@5.6.2/node_modules/typescript/lib/typescript.js:126595:9) + +Node.js v21.7.0 diff --git a/napi/.tsimp/daemon/mtime b/napi/.tsimp/daemon/mtime new file mode 100644 index 00000000..a15c3ee8 --- /dev/null +++ b/napi/.tsimp/daemon/mtime @@ -0,0 +1 @@ +1727156457864 diff --git a/napi/__test__/index.spec.mjs b/napi/__test__/index.spec.mjs deleted file mode 100644 index 1ade4caf..00000000 --- a/napi/__test__/index.spec.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import test from 'ava' - -import { sum } from '../index.js' - -test('sum from native', (t) => { - t.is(sum(1, 2), 3) -}) diff --git a/napi/__test__/index.spec.ts b/napi/__test__/index.spec.ts new file mode 100644 index 00000000..558e2da1 --- /dev/null +++ b/napi/__test__/index.spec.ts @@ -0,0 +1,25 @@ +import test from "ava"; + +import { toCoinId } from "../index.js"; + +test("calculate coin id", (t) => { + const coinId = toCoinId({ + parentCoinInfo: Buffer.from( + "4bf5122f344554c53bde2ebb8cd2b7e3d1600ad631c385a5d7cce23c7785459a", + "hex" + ), + puzzleHash: Buffer.from( + "dbc1b4c900ffe48d575b5da5c638040125f65db0fe3e24494b76ea986457d986", + "hex" + ), + amount: 100n, + }); + t.true( + Buffer.from(coinId).equals( + Buffer.from( + "fd3e669c27be9d634fe79f1f7d7d8aaacc3597b855cffea1d708f4642f1d542a", + "hex" + ) + ) + ); +}); diff --git a/napi/package.json b/napi/package.json index 77b56ec9..ad9a6f67 100644 --- a/napi/package.json +++ b/napi/package.json @@ -28,9 +28,17 @@ }, "devDependencies": { "@napi-rs/cli": "^2.18.4", - "ava": "^6.0.1" + "@types/node": "^22.6.1", + "ava": "^6.0.1", + "ts-node": "^10.9.2" }, "ava": { - "timeout": "3m" + "timeout": "3m", + "extensions": [ + "ts" + ], + "require": [ + "ts-node/register" + ] } } diff --git a/napi/pnpm-lock.yaml b/napi/pnpm-lock.yaml index 37dc0fdc..2adc1af8 100644 --- a/napi/pnpm-lock.yaml +++ b/napi/pnpm-lock.yaml @@ -11,12 +11,32 @@ importers: '@napi-rs/cli': specifier: ^2.18.4 version: 2.18.4 + '@types/node': + specifier: ^22.6.1 + version: 22.6.1 ava: specifier: ^6.0.1 version: 6.1.3 + ts-node: + specifier: ^10.9.2 + version: 10.9.2(@types/node@22.6.1)(typescript@5.6.2) packages: + '@cspotcode/source-map-support@0.8.1': + resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} + engines: {node: '>=12'} + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.5.0': + resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} + + '@jridgewell/trace-mapping@0.3.9': + resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + '@mapbox/node-pre-gyp@1.0.11': resolution: {integrity: sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==} hasBin: true @@ -46,6 +66,21 @@ packages: resolution: {integrity: sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==} engines: {node: '>=18'} + '@tsconfig/node10@1.0.11': + resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} + + '@tsconfig/node12@1.0.11': + resolution: {integrity: sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==} + + '@tsconfig/node14@1.0.3': + resolution: {integrity: sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==} + + '@tsconfig/node16@1.0.4': + resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} + + '@types/node@22.6.1': + resolution: {integrity: sha512-V48tCfcKb/e6cVUigLAaJDAILdMP0fUW6BidkPK4GpGjXcfbnoHasCZDwz3N3yVt5we2RHm4XTQCpv0KJz9zqw==} + '@vercel/nft@0.26.5': resolution: {integrity: sha512-NHxohEqad6Ra/r4lGknO52uc/GrWILXAMs1BB4401GTqww0fw1bAqzpG1XHuDO+dprg4GvsD9ZLLSsdo78p9hQ==} engines: {node: '>=16'} @@ -96,6 +131,9 @@ packages: engines: {node: '>=10'} deprecated: This package is no longer supported. + arg@4.1.3: + resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} + argparse@1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} @@ -206,6 +244,9 @@ packages: resolution: {integrity: sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + create-require@1.1.1: + resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + currently-unhandled@0.4.1: resolution: {integrity: sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng==} engines: {node: '>=0.10.0'} @@ -230,6 +271,10 @@ packages: resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} engines: {node: '>=8'} + diff@4.0.2: + resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} + engines: {node: '>=0.3.1'} + emittery@1.0.3: resolution: {integrity: sha512-tJdCJitoy2lrC2ldJcqN4vkqJ00lT+tOWNT1hBJjO/3FDMJa5TTIiYGCKGkn/WfCyOzUMObeohbVTj00fhiLiA==} engines: {node: '>=14.16'} @@ -408,6 +453,9 @@ packages: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} + make-error@1.3.6: + resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + matcher@5.0.0: resolution: {integrity: sha512-s2EMBOWtXFc8dgqvoAzKJXxNHibcdJMV0gwqKUaw9E2JBJuGUK7DrNKrA6g/i+v72TT16+6sVm5mS3thaMLQUw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -638,10 +686,32 @@ packages: tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + ts-node@10.9.2: + resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + type-fest@0.13.1: resolution: {integrity: sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==} engines: {node: '>=10'} + typescript@5.6.2: + resolution: {integrity: sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==} + engines: {node: '>=14.17'} + hasBin: true + + undici-types@6.19.8: + resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==} + unicorn-magic@0.1.0: resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} engines: {node: '>=18'} @@ -649,6 +719,9 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + v8-compile-cache-lib@3.0.1: + resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} + webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} @@ -688,8 +761,25 @@ packages: resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} engines: {node: '>=12'} + yn@3.1.1: + resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} + engines: {node: '>=6'} + snapshots: + '@cspotcode/source-map-support@0.8.1': + dependencies: + '@jridgewell/trace-mapping': 0.3.9 + + '@jridgewell/resolve-uri@3.1.2': {} + + '@jridgewell/sourcemap-codec@1.5.0': {} + + '@jridgewell/trace-mapping@0.3.9': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.5.0 + '@mapbox/node-pre-gyp@1.0.11': dependencies: detect-libc: 2.0.3 @@ -726,6 +816,18 @@ snapshots: '@sindresorhus/merge-streams@2.3.0': {} + '@tsconfig/node10@1.0.11': {} + + '@tsconfig/node12@1.0.11': {} + + '@tsconfig/node14@1.0.3': {} + + '@tsconfig/node16@1.0.4': {} + + '@types/node@22.6.1': + dependencies: + undici-types: 6.19.8 + '@vercel/nft@0.26.5': dependencies: '@mapbox/node-pre-gyp': 1.0.11 @@ -779,6 +881,8 @@ snapshots: delegates: 1.0.0 readable-stream: 3.6.2 + arg@4.1.3: {} + argparse@1.0.10: dependencies: sprintf-js: 1.0.3 @@ -912,6 +1016,8 @@ snapshots: convert-to-spaces@2.0.1: {} + create-require@1.1.1: {} + currently-unhandled@0.4.1: dependencies: array-find-index: 1.0.2 @@ -928,6 +1034,8 @@ snapshots: detect-libc@2.0.3: {} + diff@4.0.2: {} + emittery@1.0.3: {} emoji-regex@10.4.0: {} @@ -1077,6 +1185,8 @@ snapshots: dependencies: semver: 6.3.1 + make-error@1.3.6: {} + matcher@5.0.0: dependencies: escape-string-regexp: 5.0.0 @@ -1272,12 +1382,36 @@ snapshots: tr46@0.0.3: {} + ts-node@10.9.2(@types/node@22.6.1)(typescript@5.6.2): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.11 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 22.6.1 + acorn: 8.12.1 + acorn-walk: 8.3.4 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.6.2 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + type-fest@0.13.1: {} + typescript@5.6.2: {} + + undici-types@6.19.8: {} + unicorn-magic@0.1.0: {} util-deprecate@1.0.2: {} + v8-compile-cache-lib@3.0.1: {} + webidl-conversions@3.0.1: {} well-known-symbols@2.0.0: {} @@ -1319,3 +1453,5 @@ snapshots: string-width: 4.2.3 y18n: 5.0.8 yargs-parser: 21.1.1 + + yn@3.1.1: {} diff --git a/napi/tsconfig.json b/napi/tsconfig.json new file mode 100644 index 00000000..e49edfe1 --- /dev/null +++ b/napi/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "types": ["node"], + "target": "ESNext", + "module": "NodeNext", + "moduleResolution": "NodeNext" + } +}