Skip to content

Commit c69f3cf

Browse files
fix: add dealId to sendTelegram response to allow tracking uninitialized tasks by dealId
1 parent 56f8337 commit c69f3cf

File tree

3 files changed

+40
-53
lines changed

3 files changed

+40
-53
lines changed

src/web3telegram/sendTelegram.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export const sendTelegram = async ({
279279
const requestorder = await iexec.order.signRequestorder(requestorderToSign);
280280

281281
// Match orders and compute task ID
282-
const { dealid } = await iexec.order.matchOrders(
282+
const { dealid: dealId } = await iexec.order.matchOrders(
283283
{
284284
apporder: apporder,
285285
datasetorder: datasetorder,
@@ -288,8 +288,9 @@ export const sendTelegram = async ({
288288
},
289289
{ useVoucher: vUseVoucher }
290290
);
291-
const taskId = await iexec.deal.computeTaskId(dealid, 0);
291+
const taskId = await iexec.deal.computeTaskId(dealId, 0);
292292
return {
293+
dealId,
293294
taskId,
294295
};
295296
} catch (error) {

src/web3telegram/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export type SendTelegramParams = {
6565

6666
export type SendTelegramResponse = {
6767
taskId: string;
68+
dealId: string;
6869
};
6970

7071
export type PrepareTelegramCampaignParams = {

tests/e2e/sendTelegram.test.ts

Lines changed: 36 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,10 @@ describe('web3telegram.sendTelegram()', () => {
174174
protectedData: validProtectedData.address,
175175
workerpoolMaxPrice: prodWorkerpoolPublicPrice,
176176
});
177-
expect('taskId' in sendTelegramResponse).toBe(true);
178-
expect(
179-
'taskId' in sendTelegramResponse
180-
? sendTelegramResponse.taskId
181-
: undefined
182-
).toBeDefined();
177+
expect(sendTelegramResponse).toStrictEqual({
178+
dealId: expect.any(String),
179+
taskId: expect.any(String),
180+
});
183181
},
184182
2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME
185183
);
@@ -290,12 +288,10 @@ describe('web3telegram.sendTelegram()', () => {
290288
protectedData: validProtectedData.address,
291289
workerpoolAddressOrEns: learnProdWorkerpoolAddress,
292290
});
293-
expect('taskId' in sendTelegramResponse).toBe(true);
294-
expect(
295-
'taskId' in sendTelegramResponse
296-
? sendTelegramResponse.taskId
297-
: undefined
298-
).toBeDefined();
291+
expect(sendTelegramResponse).toStrictEqual({
292+
dealId: expect.any(String),
293+
taskId: expect.any(String),
294+
});
299295
},
300296
2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME
301297
);
@@ -323,11 +319,10 @@ describe('web3telegram.sendTelegram()', () => {
323319
workerpoolAddressOrEns: learnProdWorkerpoolAddress,
324320
});
325321
expect('taskId' in sendTelegramResponse).toBe(true);
326-
expect(
327-
'taskId' in sendTelegramResponse
328-
? sendTelegramResponse.taskId
329-
: undefined
330-
).toBeDefined();
322+
expect(sendTelegramResponse).toStrictEqual({
323+
dealId: expect.any(String),
324+
taskId: expect.any(String),
325+
});
331326
},
332327
2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME
333328
);
@@ -344,11 +339,10 @@ describe('web3telegram.sendTelegram()', () => {
344339
workerpoolAddressOrEns: learnProdWorkerpoolAddress,
345340
});
346341
expect('taskId' in sendTelegramResponse).toBe(true);
347-
expect(
348-
'taskId' in sendTelegramResponse
349-
? sendTelegramResponse.taskId
350-
: undefined
351-
).toBeDefined();
342+
expect(sendTelegramResponse).toStrictEqual({
343+
dealId: expect.any(String),
344+
taskId: expect.any(String),
345+
});
352346
},
353347
2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME
354348
);
@@ -365,11 +359,10 @@ describe('web3telegram.sendTelegram()', () => {
365359
});
366360
expect(sendTelegramResponse).toBeDefined();
367361
expect('taskId' in sendTelegramResponse).toBe(true);
368-
expect(
369-
'taskId' in sendTelegramResponse
370-
? sendTelegramResponse.taskId
371-
: undefined
372-
).toBeDefined();
362+
expect(sendTelegramResponse).toStrictEqual({
363+
dealId: expect.any(String),
364+
taskId: expect.any(String),
365+
});
373366
},
374367
2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME
375368
);
@@ -387,12 +380,10 @@ describe('web3telegram.sendTelegram()', () => {
387380
senderName: 'Product Team',
388381
workerpoolAddressOrEns: learnProdWorkerpoolAddress,
389382
});
390-
expect('taskId' in sendTelegramResponse).toBe(true);
391-
expect(
392-
'taskId' in sendTelegramResponse
393-
? sendTelegramResponse.taskId
394-
: undefined
395-
).toBeDefined();
383+
expect(sendTelegramResponse).toStrictEqual({
384+
dealId: expect.any(String),
385+
taskId: expect.any(String),
386+
});
396387
},
397388
2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME
398389
);
@@ -406,12 +397,10 @@ describe('web3telegram.sendTelegram()', () => {
406397
workerpoolAddressOrEns: learnProdWorkerpoolAddress,
407398
label: 'ID1234678',
408399
});
409-
expect('taskId' in sendTelegramResponse).toBe(true);
410-
expect(
411-
'taskId' in sendTelegramResponse
412-
? sendTelegramResponse.taskId
413-
: undefined
414-
).toBeDefined();
400+
expect(sendTelegramResponse).toStrictEqual({
401+
dealId: expect.any(String),
402+
taskId: expect.any(String),
403+
});
415404
// TODO check label in created deal
416405
},
417406
2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME
@@ -500,12 +489,10 @@ describe('web3telegram.sendTelegram()', () => {
500489
// workerpoolAddressOrEns: prodWorkerpoolAddress, // default
501490
useVoucher: true,
502491
});
503-
expect('taskId' in sendTelegramResponse).toBe(true);
504-
expect(
505-
'taskId' in sendTelegramResponse
506-
? sendTelegramResponse.taskId
507-
: undefined
508-
).toBeDefined();
492+
expect(sendTelegramResponse).toStrictEqual({
493+
dealId: expect.any(String),
494+
taskId: expect.any(String),
495+
});
509496
},
510497
2 * MAX_EXPECTED_BLOCKTIME +
511498
MAX_EXPECTED_WEB2_SERVICES_TIME +
@@ -561,12 +548,10 @@ describe('web3telegram.sendTelegram()', () => {
561548
workerpoolMaxPrice: nonSponsoredAmount,
562549
useVoucher: true,
563550
});
564-
expect('taskId' in sendTelegramResponse).toBe(true);
565-
expect(
566-
'taskId' in sendTelegramResponse
567-
? sendTelegramResponse.taskId
568-
: undefined
569-
).toBeDefined();
551+
expect(sendTelegramResponse).toStrictEqual({
552+
dealId: expect.any(String),
553+
taskId: expect.any(String),
554+
});
570555
},
571556
2 * MAX_EXPECTED_BLOCKTIME +
572557
MAX_EXPECTED_WEB2_SERVICES_TIME +

0 commit comments

Comments
 (0)