diff --git a/packages/sdk/src/utils/validators.ts b/packages/sdk/src/utils/validators.ts index 52fac66f2..494e6991b 100644 --- a/packages/sdk/src/utils/validators.ts +++ b/packages/sdk/src/utils/validators.ts @@ -115,9 +115,6 @@ export const secretsSchema = () => ({ label }) => `${label} must be an object with numeric keys and string values`, (value) => { - if (!value || typeof value !== 'object') { - return false; - } for (const key in value) { const val = value[key]; if (typeof Number(key) !== 'number' || typeof val !== 'string') { diff --git a/packages/sdk/tests/e2e/dataProtectorCore/processProtectedData.test.ts b/packages/sdk/tests/e2e/dataProtectorCore/processProtectedData.test.ts index 1e27491f1..9900e9cc1 100644 --- a/packages/sdk/tests/e2e/dataProtectorCore/processProtectedData.test.ts +++ b/packages/sdk/tests/e2e/dataProtectorCore/processProtectedData.test.ts @@ -58,6 +58,7 @@ describe('dataProtectorCore.processProtectedData()', () => { authorizedApp: appAddress, protectedData: protectedData.address, authorizedUser: wallet.address, + numberOfAccess: 1000, }); }, 2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME); it( @@ -77,4 +78,16 @@ describe('dataProtectorCore.processProtectedData()', () => { }, 2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME ); + it( + 'should successfully process a protected data with the minimum parameters', + async () => { + const taskId = await dataProtectorCore.processProtectedData({ + protectedData: protectedData.address, + app: appAddress, + workerpool: workerpoolAddress, // needs to be specified for the test + }); + expect(taskId).toBeDefined(); + }, + 2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME + ); }); diff --git a/packages/sdk/tests/unit/dataProtectorCore/processProtectedData.test.ts b/packages/sdk/tests/unit/dataProtectorCore/processProtectedData.test.ts index f0c38a9f8..86882352a 100644 --- a/packages/sdk/tests/unit/dataProtectorCore/processProtectedData.test.ts +++ b/packages/sdk/tests/unit/dataProtectorCore/processProtectedData.test.ts @@ -156,4 +156,27 @@ describe('processProtectedData', () => { workerpoolorder: MOCK_WORKERPOOL_ORDER.orders[0]?.order, }); }); + it( + 'should throw WorkflowError for invalid secret type', + async () => { + mockFetchDatasetOrderbook = jest.fn().mockImplementationOnce(() => { + return Promise.resolve({}); + }); + iexec.orderbook.fetchDatasetOrderbook = mockFetchDatasetOrderbook; + const secretsValue = 'invalid value'; + await expect( + processProtectedData({ + iexec, + protectedData: protectedData.address, + app: '0x4605e8af487897faaef16f0709391ef1be828591', + secrets: secretsValue, + }) + ).rejects.toThrow( + new WorkflowError( + `secrets must be a \`object\` type, but the final value was: \`\"${secretsValue}\"\`.` + ) + ); + }, + 2 * MAX_EXPECTED_BLOCKTIME + MAX_EXPECTED_WEB2_SERVICES_TIME + ); });