]> git.codecow.com Git - libnemo.git/commitdiff
Fix pow test.
authorChris Duncan <chris@zoso.dev>
Fri, 8 Aug 2025 19:41:37 +0000 (12:41 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 8 Aug 2025 19:41:37 +0000 (12:41 -0700)
src/types.d.ts
test/test.calculate-pow.mjs

index 33b38cd2a252ea0f435c02d4f29f7f2e05e10a64..1d74a678a4c51cb20440f8a316bcb42451641045 100644 (file)
@@ -236,7 +236,7 @@ export declare class Block {
        subtype?: 'send' | 'receive' | 'change'
        account: Account
        balance: bigint
-       previous: string
+       previous: Uint8Array<ArrayBuffer>
        representative?: Account
        link?: Uint8Array<ArrayBuffer>
        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
index c67cd8d1e6e2c3cfadef614d4dc653173246bc8d..b4ed09bb48adb2d3c27d02823b4c00fc6d2b7d84 100644 (file)
@@ -28,7 +28,7 @@ await Promise.all([
                                .send(NANO_TEST_VECTORS.SEND_BLOCK.link, '0')\r
                                .pow()\r
 \r
-                       assert.equal(block.previous.length, 64)\r
+                       assert.equal(block.previous.byteLength, 32)\r
                        assert.equal(block.work?.length, 16)\r
 \r
                        const work = block.work\r
@@ -36,12 +36,8 @@ await Promise.all([
                                ?.map(hex => parseInt(hex, 16))\r
                                .reverse()\r
                        if (work == null) throw new Error('Work invalid')\r
-                       const previous = block.previous\r
-                               ?.match(/.{2}/g)\r
-                               ?.map(hex => parseInt(hex, 16))\r
-                       if (previous == null) throw new Error('Previous block hash invalid')\r
 \r
-                       const bytes = new Uint8Array([...work, ...previous])\r
+                       const bytes = new Uint8Array([...work, ...block.previous])\r
                        assert.equal(bytes.byteLength, 40)\r
 \r
                        const hash = new Blake2b(8)\r