Skip to content

Commit 28a1cc9

Browse files
fix unit tests
1 parent 776e485 commit 28a1cc9

File tree

2 files changed

+40
-27
lines changed

2 files changed

+40
-27
lines changed

packages/sdk/tests/unit/dataProtectorCore/processProtectedData/processProtectedData.test.ts

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, it, jest } from '@jest/globals';
22
import { ZeroAddress } from 'ethers';
3-
import { Address } from 'iexec';
3+
import { Address, IExec } from 'iexec';
44
import { ValidationError } from 'yup';
55
import { SCONE_TAG } from '../../../../src/config/config.js';
66
import { type ProcessProtectedData } from '../../../../src/lib/dataProtectorCore/processProtectedData.js';
@@ -69,9 +69,9 @@ describe('processProtectedData', () => {
6969
await expect(
7070
// --- WHEN
7171
processProtectedData({
72-
// @ts-expect-error No need for iexec here
73-
iexec: {},
72+
iexec: new IExec({ ethProvider: 'bellecour' }),
7473
protectedData: missingProtectedDataAddress,
74+
app: '',
7575
})
7676
// --- THEN
7777
).rejects.toThrow(
@@ -88,8 +88,7 @@ describe('processProtectedData', () => {
8888
await expect(
8989
// --- WHEN
9090
processProtectedData({
91-
// @ts-expect-error No need for iexec here
92-
iexec: {},
91+
iexec: new IExec({ ethProvider: 'bellecour' }),
9392
protectedData: invalidProtectedDataAddress,
9493
app: getRandomAddress(),
9594
})
@@ -110,8 +109,7 @@ describe('processProtectedData', () => {
110109
await expect(
111110
// --- WHEN
112111
processProtectedData({
113-
// @ts-expect-error No need for iexec here
114-
iexec: {},
112+
iexec: new IExec({ ethProvider: 'bellecour' }),
115113
protectedData: getRandomAddress(),
116114
app: missingAppAddress,
117115
})
@@ -130,8 +128,7 @@ describe('processProtectedData', () => {
130128
await expect(
131129
// --- WHEN
132130
processProtectedData({
133-
// @ts-expect-error No need for iexec here
134-
iexec: {},
131+
iexec: new IExec({ ethProvider: 'bellecour' }),
135132
protectedData: getRandomAddress(),
136133
app: invalidAppAddress,
137134
})
@@ -152,8 +149,7 @@ describe('processProtectedData', () => {
152149
await expect(
153150
// --- WHEN
154151
processProtectedData({
155-
// @ts-expect-error No need for iexec here
156-
iexec: {},
152+
iexec: new IExec({ ethProvider: 'bellecour' }),
157153
protectedData: getRandomAddress(),
158154
app: getRandomAddress(),
159155
userWhitelist: invalidUserWhitelist,
@@ -173,8 +169,7 @@ describe('processProtectedData', () => {
173169
await expect(
174170
// --- WHEN
175171
processProtectedData({
176-
// @ts-expect-error No need for iexec here
177-
iexec: {},
172+
iexec: new IExec({ ethProvider: 'bellecour' }),
178173
protectedData: getRandomAddress(),
179174
app: getRandomAddress(),
180175
// @ts-expect-error Type 'number' is not assignable to type 'string'
@@ -193,8 +188,7 @@ describe('processProtectedData', () => {
193188
await expect(
194189
// --- WHEN
195190
processProtectedData({
196-
// @ts-expect-error No need for iexec here
197-
iexec: {},
191+
iexec: new IExec({ ethProvider: 'bellecour' }),
198192
protectedData: getRandomAddress(),
199193
app: getRandomAddress(),
200194
dataMaxPrice: invalidDataMaxPrice,
@@ -214,8 +208,7 @@ describe('processProtectedData', () => {
214208
await expect(
215209
// --- WHEN
216210
processProtectedData({
217-
// @ts-expect-error No need for iexec here
218-
iexec: {},
211+
iexec: new IExec({ ethProvider: 'bellecour' }),
219212
protectedData: getRandomAddress(),
220213
app: getRandomAddress(),
221214
workerpoolMaxPrice: invalidWorkerpoolMaxPrice,
@@ -237,8 +230,7 @@ describe('processProtectedData', () => {
237230
await expect(
238231
// --- WHEN
239232
processProtectedData({
240-
// @ts-expect-error No need for iexec here
241-
iexec: {},
233+
iexec: new IExec({ ethProvider: 'bellecour' }),
242234
protectedData: getRandomAddress(),
243235
app: getRandomAddress(),
244236
appMaxPrice: invalidAppMaxPrice,
@@ -258,8 +250,7 @@ describe('processProtectedData', () => {
258250
await expect(
259251
// --- WHEN
260252
processProtectedData({
261-
// @ts-expect-error No need for iexec here
262-
iexec: {},
253+
iexec: new IExec({ ethProvider: 'bellecour' }),
263254
protectedData: getRandomAddress(),
264255
app: getRandomAddress(),
265256
// @ts-expect-error This is intended to actually test yup runtime validation
@@ -278,8 +269,7 @@ describe('processProtectedData', () => {
278269
await expect(
279270
// --- WHEN
280271
processProtectedData({
281-
// @ts-expect-error No need for iexec here
282-
iexec: {},
272+
iexec: new IExec({ ethProvider: 'bellecour' }),
283273
protectedData: getRandomAddress(),
284274
app: getRandomAddress(),
285275
inputFiles: invalidInputFiles,
@@ -297,8 +287,7 @@ describe('processProtectedData', () => {
297287
await expect(
298288
// --- WHEN
299289
processProtectedData({
300-
// @ts-expect-error No need for iexec here
301-
iexec: {},
290+
iexec: new IExec({ ethProvider: 'bellecour' }),
302291
protectedData: getRandomAddress(),
303292
app: getRandomAddress(),
304293
// @ts-expect-error This is intended to actually test yup runtime validation
@@ -321,8 +310,7 @@ describe('processProtectedData', () => {
321310
await expect(
322311
// --- WHEN
323312
processProtectedData({
324-
// @ts-expect-error No need for iexec here
325-
iexec: {},
313+
iexec: new IExec({ ethProvider: 'bellecour' }),
326314
protectedData: getRandomAddress(),
327315
app: getRandomAddress(),
328316
workerpool: invalidWorkerpool,
@@ -347,6 +335,11 @@ describe('processProtectedData', () => {
347335
.fn<() => Promise<Address>>()
348336
.mockResolvedValue(getRandomAddress()),
349337
},
338+
network: {
339+
getNetwork: jest
340+
.fn<() => Promise<any>>()
341+
.mockResolvedValue({ chainId: 134 }),
342+
},
350343
};
351344

352345
// Say that given whitelist is NOT valid
@@ -396,6 +389,11 @@ describe('processProtectedData', () => {
396389
.fn<() => Promise<any>>()
397390
.mockResolvedValue(mockWorkerpoolOrderbook),
398391
},
392+
network: {
393+
getNetwork: jest
394+
.fn<() => Promise<any>>()
395+
.mockResolvedValue({ chainId: 134 }),
396+
},
399397
};
400398

401399
await expect(
@@ -434,6 +432,11 @@ describe('processProtectedData', () => {
434432
.fn<() => Promise<any>>()
435433
.mockResolvedValue(mockWorkerpoolOrderbook),
436434
},
435+
network: {
436+
getNetwork: jest
437+
.fn<() => Promise<any>>()
438+
.mockResolvedValue({ chainId: 134 }),
439+
},
437440
};
438441

439442
await expect(
@@ -596,6 +599,11 @@ describe('processProtectedData', () => {
596599
.fn<() => Promise<{ orders: []; count: 0 }>>()
597600
.mockResolvedValue(resolveWithNoOrder()), // <-- NO workerpool order
598601
},
602+
network: {
603+
getNetwork: jest
604+
.fn<() => Promise<any>>()
605+
.mockResolvedValue({ chainId: 134 }),
606+
},
599607
};
600608

601609
await expect(

packages/sdk/tests/utils/mockAllForProcessProtectedData.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,10 @@ export function mockAllForProcessProtectedData({
7777
dealid: randomDealId,
7878
}),
7979
},
80+
network: {
81+
getNetwork: jest
82+
.fn<() => Promise<any>>()
83+
.mockResolvedValue({ chainId: 134 }),
84+
},
8085
};
8186
}

0 commit comments

Comments
 (0)