Skip to content

Commit 0f0480d

Browse files
committed
test: Update assertDatasetDealCompatibility tests
1 parent 36b9e32 commit 0f0480d

File tree

1 file changed

+40
-60
lines changed

1 file changed

+40
-60
lines changed

test/byContract/IexecPoco/IexecPoco1.test.ts

Lines changed: 40 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
} from '../../../typechain';
1919
import {
2020
ALL_TEE_TAGS,
21-
TAG_ALL_TEE_FRAMEWORKS,
2221
TAG_BIT_2,
2322
TAG_BIT_4,
2423
TAG_BIT_4_AND_TEE,
@@ -27,7 +26,6 @@ import {
2726
TAG_TEE,
2827
TAG_TEE_GRAMINE,
2928
TAG_TEE_SCONE,
30-
TAG_TEE_TDX,
3129
} from '../../../utils/constants';
3230
import {
3331
IexecOrders,
@@ -1150,6 +1148,46 @@ describe('IexecPoco1', () => {
11501148
).to.not.be.reverted;
11511149
});
11521150

1151+
/**
1152+
* Successful compatibility check with all combinations of TEE tags in deal and dataset order.
1153+
* Validates ignored dataset tag bits.
1154+
*/
1155+
ALL_TEE_TAGS.forEach((datasetTag) => {
1156+
ALL_TEE_TAGS.forEach((dealTag) => {
1157+
it(`Should not revert with compatible TEE tags [dataset:${TAG_NAMES[datasetTag]}, deal:${TAG_NAMES[dealTag]}]`, async () => {
1158+
// Create a new deal with the specified tag, don't reuse the one from beforeEach.
1159+
const newDealOrders = buildOrders({
1160+
assets: { ...ordersAssets, dataset: ZeroAddress },
1161+
prices: ordersPrices,
1162+
requester: requester.address,
1163+
tag: dealTag,
1164+
volume: volume,
1165+
});
1166+
// Override salts to avoid order consumption conflicts.
1167+
newDealOrders.app.salt = ethers.id('some-salt');
1168+
newDealOrders.workerpool.salt = ethers.id('some-salt');
1169+
newDealOrders.requester.salt = ethers.id('some-salt');
1170+
await depositForRequesterAndSchedulerWithDefaultPrices(volume);
1171+
await signOrders(iexecWrapper.getDomain(), newDealOrders, ordersActors);
1172+
const dealId = getDealId(iexecWrapper.getDomain(), newDealOrders.requester);
1173+
await iexecPocoAsRequester
1174+
.matchOrders(...newDealOrders.toArray())
1175+
.then((tx) => tx.wait());
1176+
// Create dataset order with the specified tag
1177+
const datasetOrder = {
1178+
...compatibleDatasetOrder,
1179+
tag: datasetTag,
1180+
salt: ethers.id('some-salt'),
1181+
};
1182+
await signOrder(iexecWrapper.getDomain(), datasetOrder, datasetProvider);
1183+
1184+
// Should not revert because bits in positions 1 to 3 of the dataset order tag are ignored.
1185+
await expect(iexecPoco.assertDatasetDealCompatibility(datasetOrder, dealId)).to
1186+
.not.be.reverted;
1187+
});
1188+
});
1189+
});
1190+
11531191
it('Should revert when the dataset order is revoked or fully consumed', async () => {
11541192
await signOrder(iexecWrapper.getDomain(), compatibleDatasetOrder, datasetProvider);
11551193
// Revoke order on-chain.
@@ -1305,64 +1343,6 @@ describe('IexecPoco1', () => {
13051343
.withArgs('Tag compatibility not satisfied');
13061344
});
13071345

1308-
// TODO: Add more test cases for tag compatibility
1309-
[
1310-
{
1311-
datasetTag: TAG_TEE_SCONE,
1312-
dealTag: TAG_TEE_TDX,
1313-
description: 'Scone tag (0x3) and deal has TDX tag (0x9)',
1314-
saltPrefix: 'scone-tdx',
1315-
},
1316-
{
1317-
datasetTag: TAG_TEE_GRAMINE,
1318-
dealTag: TAG_TEE_TDX,
1319-
description: 'Gramine tag (0x5) and deal has TDX tag (0x9)',
1320-
saltPrefix: 'gramine-tdx',
1321-
},
1322-
{
1323-
datasetTag: TAG_TEE_TDX,
1324-
dealTag: TAG_TEE_SCONE,
1325-
description: 'TDX tag (0x9) and deal has Scone tag (0x3)',
1326-
saltPrefix: 'tdx-scone',
1327-
},
1328-
{
1329-
datasetTag: TAG_ALL_TEE_FRAMEWORKS,
1330-
dealTag: TAG_TEE,
1331-
description: 'all TEE framework bits (0xF) and deal has TEE only (0x1)',
1332-
saltPrefix: 'all-frameworks-tee',
1333-
},
1334-
].forEach(({ datasetTag, dealTag, description, saltPrefix }) => {
1335-
it(`Should not revert when dataset has ${description}`, async () => {
1336-
// Create a deal with the specified tag
1337-
const dealOrders = buildOrders({
1338-
assets: { ...ordersAssets, dataset: ZeroAddress },
1339-
prices: ordersPrices,
1340-
requester: requester.address,
1341-
tag: dealTag,
1342-
volume: volume,
1343-
});
1344-
dealOrders.app.salt = ethers.id(`${saltPrefix}-app-salt`);
1345-
dealOrders.workerpool.salt = ethers.id(`${saltPrefix}-workerpool-salt`);
1346-
dealOrders.requester.salt = ethers.id(`${saltPrefix}-requester-salt`);
1347-
await depositForRequesterAndSchedulerWithDefaultPrices(volume);
1348-
await signOrders(iexecWrapper.getDomain(), dealOrders, ordersActors);
1349-
const dealId = getDealId(iexecWrapper.getDomain(), dealOrders.requester);
1350-
await iexecPocoAsRequester.matchOrders(...dealOrders.toArray());
1351-
1352-
// Create dataset order with the specified tag
1353-
const datasetOrder = {
1354-
...compatibleDatasetOrder,
1355-
tag: datasetTag,
1356-
salt: ethers.id(`${saltPrefix}-dataset-salt`),
1357-
};
1358-
await signOrder(iexecWrapper.getDomain(), datasetOrder, datasetProvider);
1359-
1360-
// Should not revert because bits 1-3 of dataset tag are ignored
1361-
await expect(iexecPoco.assertDatasetDealCompatibility(datasetOrder, dealId)).to.not
1362-
.be.reverted;
1363-
});
1364-
});
1365-
13661346
it('Should revert when dataset has bit 4 set (not masked) and deal does not', async () => {
13671347
// Create a deal with TEE only (0b0001 = 0x1)
13681348
const teeOnlyOrders = buildOrders({

0 commit comments

Comments
 (0)