diff --git a/packages/orderbook/test/js_api/gui.test.ts b/packages/orderbook/test/js_api/gui.test.ts index 51b893852..9115eb9e6 100644 --- a/packages/orderbook/test/js_api/gui.test.ts +++ b/packages/orderbook/test/js_api/gui.test.ts @@ -265,6 +265,7 @@ deployments: scenario: some-scenario order: some-order --- +#test-binding ! #calculate-io _ _: 0 0; #handle-io @@ -833,7 +834,7 @@ describe('Rain Orderbook JS API Package Bindgen Tests - Gui', async function () ); }); - it('should generate multicalldata for deposit and add order', async () => { + it('should generate multicalldata for deposit and add order with existing vault ids', async () => { await mockServer .forPost('/rpc-url') .withBodyIncluding('0xf0cfdd37') @@ -878,6 +879,65 @@ describe('Rain Orderbook JS API Package Bindgen Tests - Gui', async function () ); }); + it('should generate multicalldata for deposit and add order with without vault ids', async () => { + await mockServer + .forPost('/rpc-url') + .once() + .withBodyIncluding('0x82ad56cb') + .thenSendJsonRpcResult( + '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000007546f6b656e203100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000025431000000000000000000000000000000000000000000000000000000000000' + ); + await mockServer + .forPost('/rpc-url') + .once() + .withBodyIncluding('0x82ad56cb') + .thenSendJsonRpcResult( + '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000754656b656e203200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000025432000000000000000000000000000000000000000000000000000000000000' + ); + + let testDotrain = `${guiConfig2} + +${dotrainWithoutVaultIds}`; + let gui = await DotrainOrderGui.chooseDeployment(testDotrain, 'other-deployment'); + + await mockServer + .forPost('/rpc-url') + .withBodyIncluding('0xf0cfdd37') + .thenSendJsonRpcResult(`0x${'0'.repeat(24) + '1'.repeat(40)}`); + await mockServer + .forPost('/rpc-url') + .withBodyIncluding('0xc19423bc') + .thenSendJsonRpcResult(`0x${'0'.repeat(24) + '2'.repeat(40)}`); + await mockServer + .forPost('/rpc-url') + .withBodyIncluding('0x24376855') + .thenSendJsonRpcResult(`0x${'0'.repeat(24) + '3'.repeat(40)}`); + await mockServer + .forPost('/rpc-url') + .withBodyIncluding('0xa3869e14') + // 0x1234 encoded bytes + .thenSendJsonRpcResult( + '0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000' + ); + + gui.saveDeposit('token2', '5000'); + + gui.saveFieldValue('test-binding', { + isPreset: true, + value: '0' + }); + + const calldata: DepositAndAddOrderCalldataResult = + await gui.generateDepositAndAddOrderCalldatas(); + assert.equal(calldata.length, 3146); + + const currentDeployment: GuiDeployment = gui.getCurrentDeployment(); + assert.equal( + currentDeployment.deployment.order.inputs[0].vaultId, + currentDeployment.deployment.order.outputs[0].vaultId + ); + }); + it('should throw error on order operations without selecting required tokens', async () => { let testDotrain = ` ${guiConfig3}