Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/deploy-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ on:

jobs:
deploy:
runs-on: ubuntu-latest
runs-on:
group: Azure_runners
labels: [ self-hosted, Linux, X64 ]
Comment on lines +8 to +10
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need runner connected to iexec infra to make deployment

strategy:
matrix:
include:
subgraph:
- target: staging
subgraph_name: 'bellecour/staging-dataprotector-v2'
env_name: staging
Expand Down
3 changes: 2 additions & 1 deletion packages/sdk/tests/e2e/constructor.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { describe, it, expect } from '@jest/globals';
import { IExecDataProtector } from '../../src/index.js';
import { getTestConfig } from '../test-utils.js';

describe('When instantiating SDK without a signer', () => {
describe('When calling a read method', () => {
it('should work as expected', async () => {
// --- GIVEN
const dataProtector = new IExecDataProtector();
const dataProtector = new IExecDataProtector(...getTestConfig());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was connected to the production subgraph, causing the test to fail.


// --- WHEN/THEN
await expect(
Expand Down
29 changes: 29 additions & 0 deletions packages/sdk/tests/e2e/dataProtectorCore/getProtectedData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,35 @@ describe('dataProtectorCore.getProtectedData()', () => {
);
});

describe('When calling getProtectedData for a ProtectedData that contains nested empty JSON objects', () => {
it('should return the protectedData without the field corresponding to the nested empty JSON objects', async () => {
// --- GIVEN
const createdProtectedData = await dataProtectorCore.protectData({
data: {
email: 'example@example.com',
tag: { size: 10, emptyObject: {} },
},
name: 'test getProtectedData',
});
await waitForSubgraphIndexing();

// --- WHEN
const result = await dataProtectorCore.getProtectedData({
protectedDataAddress: createdProtectedData.address,
});

// --- THEN
expect(result.length).toEqual(1);
expect(result[0].name).toEqual('test getProtectedData');
expect(result[0].schema).toEqual({
email: 'string',
tag: {
size: 'f64',
},
});
});
});

describe('When calling getProtectedData with a specific owner', () => {
it(
"should return only this owner's protectedData",
Expand Down
6 changes: 4 additions & 2 deletions packages/sdk/tests/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ export const getTestIExecOption = () => ({
});

export const getTestConfig = (
privateKey: string
privateKey?: string
): [Web3SignerProvider, DataProtectorConfigOptions] => {
const ethProvider = getTestWeb3SignerProvider(privateKey);
const ethProvider = privateKey
? getTestWeb3SignerProvider(privateKey)
: undefined;
const options = {
iexecOptions: getTestIExecOption(),
ipfsGateway: process.env.DRONE
Expand Down
3 changes: 2 additions & 1 deletion packages/subgraph/src/dataProtector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ function recursiveParse(

if (entry.value.kind == JSONValueKind.OBJECT) {
const object = entry.value.toObject();
for (let i = 0; i < object.entries.length; i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This for loop is a mistake. We shouldn’t keep it, I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I don't have the history of this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Le-Caignec do you remember why was it added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no i think it's an issue

// Check that the object is not empty before recursion
if (object.entries.length > 0) {
accumulator = accumulator.concat(recursiveParse(object, path));
}
} else if (entry.value.kind == JSONValueKind.STRING) {
Expand Down