Skip to content

Commit

Permalink
Revert "fix addToCollection function"
Browse files Browse the repository at this point in the history
This reverts commit e500882.
  • Loading branch information
Le-Caignec committed May 3, 2024
1 parent 00fb960 commit d19d2ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 57 deletions.
17 changes: 7 additions & 10 deletions packages/sdk/src/lib/dataProtectorSharing/addToCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,13 @@ export const addToCollection = async ({
protectedData: vProtectedData,
sharingContractAddress,
});

if (!approveTx) {
vOnStatusUpdate({
title: 'APPROVE_COLLECTION_CONTRACT',
isDone: true,
payload: {
approveTxHash: approveTx?.hash,
},
});
}
vOnStatusUpdate({
title: 'APPROVE_COLLECTION_CONTRACT',
isDone: true,
payload: {
approveTxHash: approveTx.hash,
},
});

try {
vOnStatusUpdate({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { beforeAll, describe, expect, it, jest } from '@jest/globals';
import { Wallet, type HDNodeWallet } from 'ethers';
import { IExecDataProtector } from '../../../src/index.js';
import { getTestConfig, timeouts } from '../../test-utils.js';
import { approveCollectionContract } from '../../../src/lib/dataProtectorSharing/smartContract/approveCollectionContract.js';
import { IExec } from 'iexec';
import { DEFAULT_SHARING_CONTRACT_ADDRESS } from '../../../src/config/config.js';

describe('dataProtector.addToCollection()', () => {
let dataProtector: IExecDataProtector;
Expand Down Expand Up @@ -53,50 +50,6 @@ describe('dataProtector.addToCollection()', () => {
timeouts.createCollection +
timeouts.addToCollection
);

it.only(
'should work, if the protectedData has already been approved to the ProtectedDataSharing Contract',
async () => {
// --- GIVEN
const { address: protectedData } = await dataProtector.core.protectData(
{
data: { doNotUse: 'test' },
name: 'test addToCollection',
}
);

const { collectionId } = await dataProtector.sharing.createCollection();

const onStatusUpdateMock = jest.fn();
const [ethProvider, options] = getTestConfig(wallet.privateKey);
const iexec = new IExec(
{ ethProvider },
{ ipfsGatewayURL: options.ipfsGateway, ...options?.iexecOptions }
);
await approveCollectionContract({
iexec,
protectedData,
sharingContractAddress: DEFAULT_SHARING_CONTRACT_ADDRESS,
});

// --- WHEN
await dataProtector.sharing.addToCollection({
collectionId,
addOnlyAppWhitelist,
protectedData,
onStatusUpdate: onStatusUpdateMock,
});

// --- THEN
expect(onStatusUpdateMock).toHaveBeenCalledWith({
title: 'ADD_PROTECTED_DATA_TO_COLLECTION',
isDone: true,
});
},
timeouts.protectData +
timeouts.createCollection +
timeouts.addToCollection
);
});

describe('When the given protected data does NOT exist', () => {
Expand Down

0 comments on commit d19d2ef

Please sign in to comment.