Skip to content

Commit e4be8fa

Browse files
niconiconiclaude
andcommitted
test(ops): update prepareWithdraw test to expect requestedAmount as burn_amount
The test expected withdraw_amount = burnAmount (total UTXO deduction), but the correct value is requestedAmount (net recipient amount). Update assertions to reflect the fix in ops.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d6068ac commit e4be8fa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/opsPrepare.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,10 @@ describe('Ops.prepareTransfer / Ops.prepareWithdraw', () => {
378378

379379
expect(planner.plan).toHaveBeenCalled();
380380
expect(merkle.getProofByCids).toHaveBeenCalledWith({ chainId, cids: [10], totalElements: 5n });
381-
expect(zkp.proveWithdraw).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ recipient, withdraw_amount: burnAmount }));
381+
// withdraw_amount in the proof context must be the net recipient amount (requestedAmount),
382+
// NOT burnAmount. The contract computes amountWithFee = inp.amount + protocolFee + relayerFee,
383+
// which equals burnAmount only when inp.amount = requestedAmount (net).
384+
expect(zkp.proveWithdraw).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({ recipient, withdraw_amount: plan.requestedAmount }));
382385

383386
expect(res.meta.arrayHashIndex).toBe(4);
384387
expect(res.meta.merkleRootIndex).toBe(1);
@@ -388,7 +391,7 @@ describe('Ops.prepareTransfer / Ops.prepareWithdraw', () => {
388391
expect(res.witness.asset_policy.viewer_pk).toMatchObject({ EncryptionKey: { Key: { X: 1n, Y: 2n } } });
389392
expect(res.witness.asset_policy.freezer_pk).toMatchObject({ Point: { X: 3n, Y: 4n } });
390393
expect(res.request.path).toBe('/api/v1/burn');
391-
expect((res.request.body as any).burn_amount).toBe(burnAmount.toString());
394+
expect((res.request.body as any).burn_amount).toBe(plan.requestedAmount.toString());
392395
expect((res.request.body as any).gas_drop_value).toBe(gasDropValue.toString());
393396
expect((res.request.body as any).relayer_fee).toBe(relayerFee.toString());
394397
});

0 commit comments

Comments
 (0)