Skip to content

Commit

Permalink
chore(hd-wallet): Separated test config for Chainweaver to avoid long… (
Browse files Browse the repository at this point in the history
#2170)

* chore(hd-wallet): Separated test config for Chainweaver to avoid long timeout for all newly developed functions.

* chore(hd-wallet): format
  • Loading branch information
javadkh2 committed May 24, 2024
1 parent 92ba597 commit 4b8c2bc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-knives-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kadena/hd-wallet": patch
---

Separated test config for Chainweaver to avoid long timeout for all newly developed functions.
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
# 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

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

Expand Down
4 changes: 3 additions & 1 deletion packages/libs/hd-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:*",
Expand Down
12 changes: 12 additions & 0 deletions packages/libs/hd-wallet/vitest.chainweaver.config.ts
Original file line number Diff line number Diff line change
@@ -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',
},
});
7 changes: 6 additions & 1 deletion packages/libs/hd-wallet/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -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',
},
Expand Down

0 comments on commit 4b8c2bc

Please sign in to comment.