diff --git a/.changeset/spicy-knives-swim.md b/.changeset/spicy-knives-swim.md new file mode 100644 index 0000000000..bc0dff7c63 --- /dev/null +++ b/.changeset/spicy-knives-swim.md @@ -0,0 +1,5 @@ +--- +"@kadena/hd-wallet": patch +--- + +Separated test config for Chainweaver to avoid long timeout for all newly developed functions. diff --git a/packages/libs/hd-wallet/docs/decisions/0002-support-chainweaver-key-derivation.md b/packages/libs/hd-wallet/docs/decisions/0002-support-chainweaver-key-derivation.md index 08d5f4f5a0..338ebd40aa 100644 --- a/packages/libs/hd-wallet/docs/decisions/0002-support-chainweaver-key-derivation.md +++ b/packages/libs/hd-wallet/docs/decisions/0002-support-chainweaver-key-derivation.md @@ -1,13 +1,19 @@ -# Supporting Chainweaver Key Derivation +# ADR: Supporting Chainweaver Key Derivation (Updated 2024-05-22) **Date**: 2023-10-31 **Status**: Accepted +## Change Log: + +- **2024-05-22**: Separated test config for Chainweaver to avoid long timeout + for all newly developed functions. + ## Context -We need to support chainweaver users. Discussions have revolved around -supporting keypair import or key derivation from a seed. +We need to support Chainweaver users. Discussions have revolved around +supporting keypair import or key derivation from a seed. Some of the Chainweaver +helpers are slow. ## Decision @@ -15,25 +21,30 @@ We have chosen to use the bundle file from the [kadena-io/cardano-crypto][1] repository. This choice is driven by the following factors: 1. **Custom Algorithm**: The bundle file contains a custom key derivation - algorithm based on BIP32. that we cant find an alternative library for that. - + algorithm based on BIP32, which we can't find an alternative library for. 2. **Lack of Documentation**: The library lacks comprehensive documentation, making maintenance and understanding of its design challenging. To mitigate potential issues stemming from this lack of documentation, we have opted to use the bundle as-is. - 3. **Dependency Considerations**: The library relies on a C library through WebAssembly (WASM), introducing specific dependencies during the build process. To maintain a streamlined monorepo, we have decided against including these dependencies. +4. **Separated Test Configs**: Since the Chainweaver helpers are slow, we need + to use a long timeout of `30000` for the tests. However, we need to avoid + this long timeout for SLIP10 and other newly developed functions. Therefore, + we separated the test configurations and reduced the timeout to `5000` for + these specific tests. ## Consequences This decision has the following implications: -- The bundle file must be included in the git repository. +- The bundle file must be included in the Git repository. - We may need to find ways to let users use the library for BIP44 without requiring its inclusion in output files. +- Chainweaver utilities are slow and should be used with caution in a server + environment to avoid potential DDoS or performance issues. ## Resources diff --git a/packages/libs/hd-wallet/package.json b/packages/libs/hd-wallet/package.json index a23ee3aa5d..40a3ae6904 100644 --- a/packages/libs/hd-wallet/package.json +++ b/packages/libs/hd-wallet/package.json @@ -47,7 +47,9 @@ "lint:pkg": "lint-package", "lint:src": "eslint src --ext .js,.ts", "start": "ts-node --transpile-only src/index.ts", - "test": "vitest run" + "test": "pnpm run /^test:.*/", + "test:chainweaver": "vitest run -c ./vitest.chainweaver.config.js", + "test:hd-wallet": "vitest run" }, "dependencies": { "@kadena/cryptography-utils": "workspace:*", diff --git a/packages/libs/hd-wallet/vitest.chainweaver.config.ts b/packages/libs/hd-wallet/vitest.chainweaver.config.ts new file mode 100644 index 0000000000..b75fc2b291 --- /dev/null +++ b/packages/libs/hd-wallet/vitest.chainweaver.config.ts @@ -0,0 +1,12 @@ +/** + * Test configuration for Chainweaver; read ADR-0002 for more information. + */ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + testTimeout: 30000, // TODO: this should be investigated and reduced + include: ['src/chainweaver/**/*.test.ts'], + setupFiles: './vitest.setup.js', + }, +}); diff --git a/packages/libs/hd-wallet/vitest.config.ts b/packages/libs/hd-wallet/vitest.config.ts index 9e19d1462f..dea99b8b85 100644 --- a/packages/libs/hd-wallet/vitest.config.ts +++ b/packages/libs/hd-wallet/vitest.config.ts @@ -1,8 +1,13 @@ +/** + * Test configuration for hd-wallet; read ADR-0002 for more information. + */ import { defineConfig } from 'vitest/config'; export default defineConfig({ test: { - testTimeout: 30000, //TODO: this should be investigated and reduced + // we exclude the chainweaver tests since there is another config for it + exclude: ['src/chainweaver/**/*.test.ts'], + testTimeout: 5000, include: ['src/**/*.test.ts'], setupFiles: './vitest.setup.js', },