Skip to content

Commit 4a049be

Browse files
committed
test: add case for missing fill order
1 parent fc37502 commit 4a049be

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

packages/sdk/tests/orders.test.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,30 @@ beforeEach(() => {
8686
}
8787
});
8888
}
89+
if (tokenId === 'tmltk16yw5sdh3x3ryxu83w50jzs462ttp4au0j2tff6vztt0nyfve892q7ggcsg') {
90+
return JSON.stringify({
91+
"authority": "tmt1q9w0srpalrz5t3ep54tjq774cf09p6683sqtqsxl",
92+
"circulating_supply": {
93+
"atoms": "10000000000",
94+
"decimal": "10000"
95+
},
96+
"frozen": false,
97+
"is_locked": false,
98+
"is_token_freezable": true,
99+
"is_token_unfreezable": null,
100+
"metadata_uri": {
101+
"hex": "697066733a2f2f6261666b726569636f6166727062627077643265353235677a6d776972706a796a6c6961626e776b61766832627a65746e6f6f7373666377767534",
102+
"string": "ipfs://bafkreicoafrpbbpwd2e525gzmwirpjyjliabnwkavh2bzetnoossfcwvu4"
103+
},
104+
"next_nonce": 1,
105+
"number_of_decimals": 6,
106+
"token_ticker": {
107+
"hex": "4a757374546f6b656e",
108+
"string": "JustToken"
109+
},
110+
"total_supply": "Unlimited"
111+
});
112+
}
89113
return JSON.stringify({ a: 'b' });
90114
}
91115

@@ -124,6 +148,39 @@ beforeEach(() => {
124148
}),
125149
};
126150
}
151+
152+
if (orderId === 'tordr1fkrac7mpjc4sgseufyasm472fgfgxl2c775ap20y5779vf8u40yqqq2dlf') {
153+
return {
154+
body: JSON.stringify({
155+
"ask_balance": {
156+
"atoms": "10000000000",
157+
"decimal": "0.1"
158+
},
159+
"ask_currency": {
160+
"type": "Coin"
161+
},
162+
"conclude_destination": "tmt1q9w0srpalrz5t3ep54tjq774cf09p6683sqtqsxl",
163+
"give_balance": {
164+
"atoms": "100000000",
165+
"decimal": "100"
166+
},
167+
"give_currency": {
168+
"token_id": "tmltk16yw5sdh3x3ryxu83w50jzs462ttp4au0j2tff6vztt0nyfve892q7ggcsg",
169+
"type": "Token"
170+
},
171+
"initially_asked": {
172+
"atoms": "10000000000",
173+
"decimal": "0.1"
174+
},
175+
"initially_given": {
176+
"atoms": "100000000",
177+
"decimal": "100"
178+
},
179+
"nonce": 0,
180+
"order_id": "tordr1fkrac7mpjc4sgseufyasm472fgfgxl2c775ap20y5779vf8u40yqqq2dlf"
181+
}),
182+
};
183+
}
127184
}
128185

129186
if(url.endsWith('/account')) {
@@ -241,6 +298,21 @@ test('fill order', async () => {
241298
})
242299
});
243300

301+
test('fill order that fail on call', async () => {
302+
const client = await Client.create({ network: 'testnet', autoRestore: false });
303+
304+
await client.connect();
305+
306+
await client.fillOrder({
307+
order_id: 'tordr1fkrac7mpjc4sgseufyasm472fgfgxl2c775ap20y5779vf8u40yqqq2dlf',
308+
amount: 0.01,
309+
destination: 'tmt1q9l0g4kd3s6x5rmesaznegz06pw9hxu6qvqu3pa7',
310+
});
311+
312+
const result = await spy.mock.results[0]?.value;
313+
expect(result.JSONRepresentation.fee.decimal).toBe('0.399');
314+
});
315+
244316
// replay similar tx: https://lovelace.explorer.mintlayer.org/tx/a3a822f5e9099075e07234f435a2cda80cb6e88836331238b882da785973d7ac
245317
test('conclude order - snapshot', async () => {
246318
const client = await Client.create({ network: 'testnet', autoRestore: false });

0 commit comments

Comments
 (0)