Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
findolor committed Jan 13, 2025
1 parent 1038e59 commit b541be1
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion packages/orderbook/test/js_api/gui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ deployments:
scenario: some-scenario
order: some-order
---
#test-binding !
#calculate-io
_ _: 0 0;
#handle-io
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit b541be1

Please sign in to comment.