Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 1 addition & 17 deletions .github/workflows/wasm-sdk-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ jobs:
"https://github.com/protocolbuffers/protobuf/releases/download/v32.0/protoc-32.0-linux-x86_64.zip"
unzip -o /tmp/protoc.zip -d "$PROTOC_DIR"

- name: Save cached protoc v32.0
if: steps.cache-protoc.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
${{ env.HOME }}/.local/protoc-32.0/bin
${{ env.HOME }}/.local/protoc-32.0/include
key: protoc/32.0/${{ runner.os }}/x86_64

- name: Export protoc v32.0 to PATH
run: |
echo "${HOME}/.local/protoc-32.0/bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -125,13 +116,6 @@ jobs:
tar -xzf /tmp/binaryen.tar.gz -C "${HOME}/.cache/binaryen"
mv "${HOME}/.cache/binaryen/binaryen-version_121" "${HOME}/.cache/binaryen/version_121"

- name: Save cached wasm-opt
if: steps.cache-binaryen.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.HOME }}/.cache/binaryen/version_121
key: binaryen/version_121/${{ runner.os }}/x86_64

- name: Export wasm-opt to PATH
run: |
echo "${HOME}/.cache/binaryen/version_121/bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -222,7 +206,7 @@ jobs:
working-directory: packages/wasm-sdk
run: |
echo "Running WASM SDK comprehensive test suite..."
node test/run-all-tests.mjs | tee test-output.log
set -o pipefail && node test/run-all-tests.mjs | tee test-output.log

- name: Generate job summary
if: always()
Expand Down
49 changes: 40 additions & 9 deletions packages/wasm-sdk/test/key-generation.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -358,26 +358,57 @@ await test('derivation_path_dip13_testnet', () => {
if (result.path !== "m/9'/1'/0'") throw new Error('Invalid DIP13 testnet path');
});

// Child Key Derivation Tests (expected to fail for now)
// Child Key Derivation Tests
describe('Child Key Derivation');

await test('derive_child_public_key - not implemented', () => {
await test('derive_child_public_key - basic functionality', () => {
// Generate a master extended key to get a valid xpub
const masterResult = wasmSdk.derive_key_from_seed_with_extended_path(TEST_MNEMONIC, null, "m/44'/5'/0'", "mainnet");
const parentXpub = masterResult.xpub;

// Derive child public key
const childXpub = wasmSdk.derive_child_public_key(parentXpub, 0, false);

if (!childXpub) throw new Error('No child xpub returned');
if (typeof childXpub !== 'string') throw new Error('Child xpub should be string');
if (childXpub === parentXpub) throw new Error('Child xpub should differ from parent');

// Test different indices produce different results
const childXpub1 = wasmSdk.derive_child_public_key(parentXpub, 1, false);
if (childXpub1 === childXpub) throw new Error('Different indices should produce different xpubs');
});

await test('xprv_to_xpub - basic functionality', () => {
// Generate a master extended key to get a valid xprv
const masterResult = wasmSdk.derive_key_from_seed_with_extended_path(TEST_MNEMONIC, null, "m/44'/5'/0'", "mainnet");
const xprv = masterResult.xprv;
const expectedXpub = masterResult.xpub;

// Convert xprv to xpub
const derivedXpub = wasmSdk.xprv_to_xpub(xprv);

if (!derivedXpub) throw new Error('No xpub returned');
if (typeof derivedXpub !== 'string') throw new Error('Derived xpub should be string');
if (derivedXpub !== expectedXpub) throw new Error('Derived xpub should match expected xpub');
});

await test('derive_child_public_key - error handling', () => {
try {
wasmSdk.derive_child_public_key("xpub...", 0, false);
throw new Error('Should have thrown not implemented error');
wasmSdk.derive_child_public_key("invalid_xpub", 0, false);
throw new Error('Should have thrown error for invalid xpub');
} catch (error) {
if (!error.message.includes('not yet implemented')) {
if (!error.message.includes('Invalid extended public key')) {
throw error;
}
}
});

await test('xprv_to_xpub - not implemented', () => {
await test('xprv_to_xpub - error handling', () => {
try {
wasmSdk.xprv_to_xpub("xprv...");
throw new Error('Should have thrown not implemented error');
wasmSdk.xprv_to_xpub("invalid_xprv");
throw new Error('Should have thrown error for invalid xprv');
} catch (error) {
if (!error.message.includes('not yet implemented')) {
if (!error.message.includes('Invalid extended private key')) {
throw error;
}
}
Expand Down
2 changes: 0 additions & 2 deletions packages/wasm-sdk/test/voting-contested-resources.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ await test('get_contested_resources - fetch contested domain names', async () =>
'domain', // document_type_name
DPNS_CONTRACT, // data_contract_id
'parentNameAndLabel', // index_name
'documents', // result_type
null, // allow_include_locked_and_abstaining_vote_tally
null, // start_at_value
100, // limit
null, // offset
Expand Down
Loading