Skip to content

Commit 9622976

Browse files
test(e2e): update all e2e tests for multichain config
1 parent af97aab commit 9622976

File tree

4 files changed

+38
-37
lines changed

4 files changed

+38
-37
lines changed

tests/e2e/constructor.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
// needed to access and assert IExecDataProtector's private properties
33
import { describe, expect, it } from '@jest/globals';
44
import { Wallet } from 'ethers';
5-
import {
6-
DATAPROTECTOR_SUBGRAPH_ENDPOINT,
7-
DEFAULT_IPFS_GATEWAY,
8-
} from '../../src/config/config.js';
95
import { IExecWeb3telegram } from '../../src/index.js';
106
import {
117
getTestWeb3SignerProvider,
128
MAX_EXPECTED_WEB2_SERVICES_TIME,
139
} from '../test-utils.js';
10+
import { CHAIN_CONFIG, CHAIN_IDS } from '../../src/config/config.js';
1411

1512
describe('IExecWeb3telegram()', () => {
1613
it('instantiates with a valid ethProvider', async () => {
@@ -26,8 +23,9 @@ describe('IExecWeb3telegram()', () => {
2623
const web3telegram = new IExecWeb3telegram(
2724
getTestWeb3SignerProvider(wallet.privateKey)
2825
);
26+
await web3telegram.init();
2927
const ipfsGateway = web3telegram['ipfsGateway'];
30-
expect(ipfsGateway).toStrictEqual(DEFAULT_IPFS_GATEWAY);
28+
expect(ipfsGateway).toStrictEqual(CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].ipfsGateway);
3129
});
3230

3331
it('should use provided ipfs gateway url when ipfsGateway is provided', async () => {
@@ -39,6 +37,7 @@ describe('IExecWeb3telegram()', () => {
3937
ipfsGateway: customIpfsGateway,
4038
}
4139
);
40+
await web3telegram.init();
4241
const ipfsGateway = web3telegram['ipfsGateway'];
4342
expect(ipfsGateway).toStrictEqual(customIpfsGateway);
4443
});
@@ -48,8 +47,9 @@ describe('IExecWeb3telegram()', () => {
4847
const web3telegram = new IExecWeb3telegram(
4948
getTestWeb3SignerProvider(wallet.privateKey)
5049
);
50+
await web3telegram.init();
5151
const graphQLClientUrl = web3telegram['graphQLClient'];
52-
expect(graphQLClientUrl['url']).toBe(DATAPROTECTOR_SUBGRAPH_ENDPOINT);
52+
expect(graphQLClientUrl['url']).toBe(CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dataProtectorSubgraph);
5353
});
5454

5555
it('should use provided data Protector Subgraph URL when subgraphUrl is provided', async () => {
@@ -61,6 +61,7 @@ describe('IExecWeb3telegram()', () => {
6161
dataProtectorSubgraph: customSubgraphUrl,
6262
}
6363
);
64+
await web3telegram.init();
6465
const graphQLClient = web3telegram['graphQLClient'];
6566
expect(graphQLClient['url']).toBe(customSubgraphUrl);
6667
});
@@ -89,6 +90,7 @@ describe('IExecWeb3telegram()', () => {
8990
dappWhitelistAddress: customDappWhitelistAddress,
9091
}
9192
);
93+
await web3telegram.init();
9294
const graphQLClient = web3telegram['graphQLClient'];
9395
const ipfsNode = web3telegram['ipfsNode'];
9496
const ipfsGateway = web3telegram['ipfsGateway'];
@@ -100,7 +102,7 @@ describe('IExecWeb3telegram()', () => {
100102
expect(ipfsNode).toStrictEqual(customIpfsNode);
101103
expect(ipfsGateway).toStrictEqual(customIpfsGateway);
102104
expect(dappAddressOrENS).toStrictEqual(customDapp);
103-
expect(whitelistAddress).toStrictEqual(customDappWhitelistAddress);
105+
expect(whitelistAddress).toStrictEqual(customDappWhitelistAddress.toLowerCase());
104106
expect(await iexec.config.resolveSmsURL()).toBe(smsURL);
105107
expect(await iexec.config.resolveIexecGatewayURL()).toBe(iexecGatewayURL);
106108
});

tests/e2e/fetchMyContacts.test.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
import { describe, expect, it } from '@jest/globals';
12
import { IExecDataProtector } from '@iexec/dataprotector';
2-
import { beforeAll, describe, expect, it } from '@jest/globals';
3+
import { IExecWeb3telegram } from '../../src/index.js';
4+
import { CHAIN_CONFIG, CHAIN_IDS } from '../../src/config/config.js';
5+
import {
6+
getTestConfig,
7+
waitSubgraphIndexing,
8+
} from '../test-utils.js';
39
import { HDNodeWallet, Wallet } from 'ethers';
410
import { NULL_ADDRESS } from 'iexec/utils';
5-
import { WEB3TELEGRAM_DAPP_ADDRESS } from '../../src/config/config.js';
6-
import { IExecWeb3telegram } from '../../src/index.js';
711
import {
812
MAX_EXPECTED_BLOCKTIME,
913
MAX_EXPECTED_WEB2_SERVICES_TIME,
1014
deployRandomDataset,
11-
getTestConfig,
1215
getTestWeb3SignerProvider,
1316
getTestIExecOption,
14-
waitSubgraphIndexing,
1517
} from '../test-utils.js';
1618
import IExec from 'iexec/IExec';
1719

@@ -36,7 +38,7 @@ describe('web3telegram.fetchMyContacts()', () => {
3638
'pass with a granted access for a specific requester',
3739
async () => {
3840
await dataProtector.core.grantAccess({
39-
authorizedApp: WEB3TELEGRAM_DAPP_ADDRESS,
41+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress,
4042
protectedData: protectedData.address,
4143
authorizedUser: wallet.address,
4244
});
@@ -46,11 +48,11 @@ describe('web3telegram.fetchMyContacts()', () => {
4648
});
4749
expect(
4850
foundContactForASpecificRequester &&
49-
foundContactForASpecificRequester.address
51+
foundContactForASpecificRequester.address
5052
).toBeDefined();
5153
expect(
5254
foundContactForASpecificRequester &&
53-
foundContactForASpecificRequester.address
55+
foundContactForASpecificRequester.address
5456
).toBe(protectedData.address.toLocaleLowerCase());
5557
},
5658
MAX_EXPECTED_WEB2_SERVICES_TIME
@@ -61,7 +63,7 @@ describe('web3telegram.fetchMyContacts()', () => {
6163
async () => {
6264
const grantedAccessForAnyRequester = await dataProtector.core.grantAccess(
6365
{
64-
authorizedApp: WEB3TELEGRAM_DAPP_ADDRESS,
66+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress,
6567
protectedData: protectedData.address,
6668
authorizedUser: NULL_ADDRESS,
6769
}
@@ -101,7 +103,7 @@ describe('web3telegram.fetchMyContacts()', () => {
101103
const encryptionKey = await iexec.dataset.generateEncryptionKey();
102104
await iexec.dataset.pushDatasetSecret(dataset.address, encryptionKey);
103105
await dataProtector.core.grantAccess({
104-
authorizedApp: WEB3TELEGRAM_DAPP_ADDRESS,
106+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress,
105107
protectedData: dataset.address,
106108
authorizedUser: wallet.address,
107109
});
@@ -123,7 +125,7 @@ describe('web3telegram.fetchMyContacts()', () => {
123125
await waitSubgraphIndexing();
124126

125127
await dataProtector.core.grantAccess({
126-
authorizedApp: WEB3TELEGRAM_DAPP_ADDRESS,
128+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress,
127129
protectedData: notValidProtectedData.address,
128130
authorizedUser: wallet.address,
129131
});

tests/e2e/fetchUserContacts.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from '@iexec/dataprotector';
55
import { beforeAll, describe, expect, it } from '@jest/globals';
66
import { HDNodeWallet, Wallet } from 'ethers';
7-
import { WEB3TELEGRAM_DAPP_ADDRESS } from '../../src/config/config.js';
7+
import { CHAIN_CONFIG, CHAIN_IDS } from '../../src/config/config.js';
88
import { IExecWeb3telegram, WorkflowError } from '../../src/index.js';
99
import {
1010
MAX_EXPECTED_BLOCKTIME,
@@ -45,13 +45,13 @@ describe('web3telegram.fetchMyContacts()', () => {
4545
const user1 = Wallet.createRandom().address;
4646
const user2 = Wallet.createRandom().address;
4747
await dataProtector.grantAccess({
48-
authorizedApp: WEB3TELEGRAM_DAPP_ADDRESS,
48+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress,
4949
protectedData: protectedData1.address,
5050
authorizedUser: user1,
5151
});
5252

5353
await dataProtector.grantAccess({
54-
authorizedApp: WEB3TELEGRAM_DAPP_ADDRESS,
54+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress,
5555
protectedData: protectedData2.address,
5656
authorizedUser: user2,
5757
});
@@ -72,7 +72,7 @@ describe('web3telegram.fetchMyContacts()', () => {
7272
async () => {
7373
const userWithAccess = Wallet.createRandom().address;
7474
await dataProtector.grantAccess({
75-
authorizedApp: WEB3TELEGRAM_DAPP_ADDRESS,
75+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress,
7676
protectedData: protectedData1.address,
7777
authorizedUser: userWithAccess,
7878
});

tests/e2e/sendTelegram.test.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import {
44
} from '@iexec/dataprotector';
55
import { beforeAll, describe, expect, it } from '@jest/globals';
66
import { HDNodeWallet } from 'ethers';
7-
import {
8-
WEB3TELEGRAM_DAPP_ADDRESS,
9-
WHITELIST_SMART_CONTRACT_ADDRESS,
10-
} from '../../src/config/config.js';
7+
import { CHAIN_CONFIG, CHAIN_IDS } from '../../src/config/config.js';
118
import { IExecWeb3telegram, WorkflowError } from '../../src/index.js';
129
import {
1310
MAX_EXPECTED_BLOCKTIME,
@@ -67,7 +64,7 @@ describe('web3telegram.sendTelegram()', () => {
6764
const resourceProvider = new IExec({ ethProvider }, iexecOptions);
6865
await createAndPublishAppOrders(
6966
resourceProvider,
70-
WEB3TELEGRAM_DAPP_ADDRESS
67+
CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress
7168
);
7269

7370
learnProdWorkerpoolAddress = await resourceProvider.ens.resolveName(
@@ -104,7 +101,7 @@ describe('web3telegram.sendTelegram()', () => {
104101
iexecOptions
105102
);
106103
await dataProtector.grantAccess({
107-
authorizedApp: WEB3TELEGRAM_DAPP_ADDRESS,
104+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].dappAddress,
108105
protectedData: validProtectedData.address,
109106
authorizedUser: consumerWallet.address, // consumer wallet
110107
numberOfAccess: 1000,
@@ -297,7 +294,7 @@ describe('web3telegram.sendTelegram()', () => {
297294

298295
//grant access to whitelist
299296
await dataProtector.grantAccess({
300-
authorizedApp: WHITELIST_SMART_CONTRACT_ADDRESS, //whitelist address
297+
authorizedApp: CHAIN_CONFIG[CHAIN_IDS.BELLECOUR].whitelistSmartContract, //whitelist address
301298
protectedData: protectedDataForWhitelist.address,
302299
authorizedUser: consumerWallet.address, // consumer wallet
303300
numberOfAccess: 1000,
@@ -462,8 +459,8 @@ describe('web3telegram.sendTelegram()', () => {
462459
expect(sendTelegramResponse.taskId).toBeDefined();
463460
},
464461
2 * MAX_EXPECTED_BLOCKTIME +
465-
MAX_EXPECTED_WEB2_SERVICES_TIME +
466-
MAX_EXPECTED_SUBGRAPH_INDEXING_TIME
462+
MAX_EXPECTED_WEB2_SERVICES_TIME +
463+
MAX_EXPECTED_SUBGRAPH_INDEXING_TIME
467464
);
468465
});
469466

@@ -519,8 +516,8 @@ describe('web3telegram.sendTelegram()', () => {
519516
);
520517
},
521518
2 * MAX_EXPECTED_BLOCKTIME +
522-
MAX_EXPECTED_WEB2_SERVICES_TIME +
523-
MAX_EXPECTED_SUBGRAPH_INDEXING_TIME
519+
MAX_EXPECTED_WEB2_SERVICES_TIME +
520+
MAX_EXPECTED_SUBGRAPH_INDEXING_TIME
524521
);
525522
it(
526523
'should create task if user approves the non sponsored amount',
@@ -570,8 +567,8 @@ describe('web3telegram.sendTelegram()', () => {
570567
expect(sendTelegramResponse.taskId).toBeDefined();
571568
},
572569
2 * MAX_EXPECTED_BLOCKTIME +
573-
MAX_EXPECTED_WEB2_SERVICES_TIME +
574-
MAX_EXPECTED_SUBGRAPH_INDEXING_TIME
570+
MAX_EXPECTED_WEB2_SERVICES_TIME +
571+
MAX_EXPECTED_SUBGRAPH_INDEXING_TIME
575572
);
576573
});
577574
describe('and workerpoolMaxPrice does NOT covers the non sponsored amount', () => {
@@ -623,8 +620,8 @@ describe('web3telegram.sendTelegram()', () => {
623620
);
624621
},
625622
2 * MAX_EXPECTED_BLOCKTIME +
626-
MAX_EXPECTED_WEB2_SERVICES_TIME +
627-
MAX_EXPECTED_SUBGRAPH_INDEXING_TIME
623+
MAX_EXPECTED_WEB2_SERVICES_TIME +
624+
MAX_EXPECTED_SUBGRAPH_INDEXING_TIME
628625
);
629626
});
630627
});

0 commit comments

Comments
 (0)