Skip to content

Commit

Permalink
fix: markUtxosAsVoided should not throw when inputs are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
andreabadesso committed Jul 30, 2024
1 parent 946e9c0 commit b67edfc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/daemon/__tests__/db/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ describe('tx output methods', () => {
expect(countAfterDelete).toStrictEqual(0);
});

test('markUtxosAsVoided should not throw when utxos list is empty', async () => {
expect.hasAssertions();

await expect(markUtxosAsVoided(mysql, [])).resolves.not.toThrow();
});

test('getTxOutputsFromTx, getTxOutputs, getTxOutput', async () => {
expect.hasAssertions();

Expand Down
4 changes: 4 additions & 0 deletions packages/daemon/src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,10 @@ export const markUtxosAsVoided = async (
): Promise<void> => {
const txIds = utxos.map((tx) => tx.txId);

if (txIds.length === 0) {
return;
}

await mysql.query(`
UPDATE \`tx_output\`
SET \`voided\` = TRUE
Expand Down

0 comments on commit b67edfc

Please sign in to comment.