From 67a03702c021f2a1dd9be3a549ada97cb90a2b7d Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Fri, 8 Aug 2025 12:41:37 -0700 Subject: [PATCH] Fix pow test. --- src/types.d.ts | 8 ++++---- test/test.calculate-pow.mjs | 8 ++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/types.d.ts b/src/types.d.ts index 33b38cd..1d74a67 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -236,7 +236,7 @@ export declare class Block { subtype?: 'send' | 'receive' | 'change' account: Account balance: bigint - previous: string + previous: Uint8Array representative?: Account link?: Uint8Array signature?: string @@ -250,7 +250,7 @@ export declare class Block { * the other parameters instead of passing them into the constructor. * * @param {(string|Account)} account - Target of the transaction; can include `balance`, `frontier`, `representative` - * @param {(bigint|number|string)} [balance] - Current balance of the target account + * @param {(bigint|number|string)} [balance] - Current balance of the target account in raw * @param {string} [previous] - Current frontier block hash of the target account * @param {(string|Account)} [representative] - Current representative of the target account */ @@ -299,7 +299,7 @@ export declare class Block { * * @param {(string|Block)} sendBlock - Corresponding send block or its hash * @param {(bigint|number|string)} amount - Amount to be received from sender - * @param {string} [unit] - Unit of measure for amount. Default: "NANO" (10³⁰ RAW) + * @param {string} [unit] - Unit of measure for amount (e.g. 'NANO' = 10³⁰ RAW). Default: "RAW" * @returns {Block} This block with balance, link, and subtype configured */ receive (sendBlock: string | Block, amount: bigint | number | string, unit?: string): Block @@ -308,7 +308,7 @@ export declare class Block { * * @param {(string|Account)} account - Account to target or its address or public key * @param {(bigint|number|string)} amount - Amount to send to recipient - * @param {string} [unit] - Unit of measure for amount. Default: "NANO" (10³⁰ RAW) + * @param {string} [unit] - Unit of measure for amount (e.g. 'NANO' = 10³⁰ RAW). Default: "RAW" * @returns {Block} This block with balance, link, and subtype configured */ send (account: string | Account, amount: bigint | number | string, unit?: string): Block diff --git a/test/test.calculate-pow.mjs b/test/test.calculate-pow.mjs index c67cd8d..b4ed09b 100644 --- a/test/test.calculate-pow.mjs +++ b/test/test.calculate-pow.mjs @@ -28,7 +28,7 @@ await Promise.all([ .send(NANO_TEST_VECTORS.SEND_BLOCK.link, '0') .pow() - assert.equal(block.previous.length, 64) + assert.equal(block.previous.byteLength, 32) assert.equal(block.work?.length, 16) const work = block.work @@ -36,12 +36,8 @@ await Promise.all([ ?.map(hex => parseInt(hex, 16)) .reverse() if (work == null) throw new Error('Work invalid') - const previous = block.previous - ?.match(/.{2}/g) - ?.map(hex => parseInt(hex, 16)) - if (previous == null) throw new Error('Previous block hash invalid') - const bytes = new Uint8Array([...work, ...previous]) + const bytes = new Uint8Array([...work, ...block.previous]) assert.equal(bytes.byteLength, 40) const hash = new Blake2b(8) -- 2.47.3