From adfa91556003d45f3a1840bcacfe063ddbce441b Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 18 Aug 2025 14:23:56 -0700 Subject: [PATCH] Fix sweep account index check and test assertion. --- src/lib/tools.ts | 13 ++++++------- test/test.tools.mjs | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/lib/tools.ts b/src/lib/tools.ts index f9b08e9..f457018 100644 --- a/src/lib/tools.ts +++ b/src/lib/tools.ts @@ -147,19 +147,18 @@ export async function sweep ( throw new TypeError('RPC must be a valid node') } const blockQueue: Promise[] = [] - const results: { status: 'success' | 'error', address: string, message: string }[] = [] + const results: SweepResult[] = [] const recipientAccount = Account.load(recipient) const accounts = await wallet.refresh(rpc, from, to) for (const account of accounts) { - if (account.representative?.address && account.frontier && account.index) { - const block = new Block(account).send(recipientAccount, account.balance ?? 0n) - await Promise.all([ - block.pow(), - block.sign(wallet, account.index) - ]) + if (account.representative?.address && account.frontier && account.index != null) { + const block = await new Block(account) + .send(recipientAccount, account.balance ?? 0n) + .sign(wallet, account.index) const blockRequest: Promise = new Promise(async (resolve) => { try { + await block.pow() const hash = await block.process(rpc) results.push({ status: 'success', address: block.account.address, message: hash }) } catch (err: any) { diff --git a/test/test.tools.mjs b/test/test.tools.mjs index 31c7d47..20ae465 100644 --- a/test/test.tools.mjs +++ b/test/test.tools.mjs @@ -182,7 +182,7 @@ await Promise.all([ await wallet.unlock(NANO_TEST_VECTORS.PASSWORD) const results = await Tools.sweep(rpc, wallet, NANO_TEST_VECTORS.ADDRESS_1) - assert.ok(results) + assert.exists(results) assert.equal(results.length, 1) await assert.resolves(wallet.destroy()) -- 2.47.3