@@ -17,15 +17,15 @@ import {
1717 OwnableMock__factory ,
1818} from '../../../typechain' ;
1919import {
20- TAG_ALL_TEE_FRAMEWORKS ,
20+ ALL_TEE_TAGS ,
2121 TAG_BIT_2 ,
2222 TAG_BIT_4 ,
2323 TAG_BIT_4_AND_TEE ,
24+ TAG_NAMES ,
2425 TAG_STANDARD ,
2526 TAG_TEE ,
2627 TAG_TEE_GRAMINE ,
2728 TAG_TEE_SCONE ,
28- TAG_TEE_TDX ,
2929} from '../../../utils/constants' ;
3030import {
3131 IexecOrders ,
@@ -637,41 +637,26 @@ describe('IexecPoco1', () => {
637637 ) ;
638638 } ) ;
639639
640- [
641- {
642- datasetTag : TAG_TEE_SCONE ,
643- workerpoolTag : TAG_TEE_TDX ,
644- description : 'Scone tag (0x3) and workerpool has TDX tag (0x9)' ,
645- } ,
646- {
647- datasetTag : TAG_TEE_GRAMINE ,
648- workerpoolTag : TAG_TEE_TDX ,
649- description : 'Gramine tag (0x5) and workerpool has TDX tag (0x9)' ,
650- } ,
651- {
652- datasetTag : TAG_TEE_TDX ,
653- workerpoolTag : TAG_TEE_SCONE ,
654- description : 'TDX tag (0x9) and workerpool has Scone tag (0x3)' ,
655- } ,
656- {
657- datasetTag : TAG_ALL_TEE_FRAMEWORKS ,
658- workerpoolTag : TAG_TEE ,
659- description : 'all TEE framework bits (0xF) and workerpool has TEE only (0x1)' ,
660- } ,
661- ] . forEach ( ( { datasetTag, workerpoolTag, description } ) => {
662- it ( `Should match orders when dataset has ${ description } ` , async ( ) => {
663- orders . dataset . tag = datasetTag ;
664- orders . workerpool . tag = workerpoolTag ;
665- orders . app . tag = TAG_TEE ;
666- orders . requester . tag = TAG_TEE ;
667-
668- await depositForRequesterAndSchedulerWithDefaultPrices ( volume ) ;
669- await signOrders ( iexecWrapper . getDomain ( ) , orders , ordersActors ) ;
670-
671- await expect ( iexecPocoAsRequester . matchOrders ( ...orders . toArray ( ) ) ) . to . emit (
672- iexecPoco ,
673- 'OrdersMatched' ,
674- ) ;
640+ /**
641+ * Successful match orders with all combinations of TEE tags in dataset and workerpool orders.
642+ * Validates ignored dataset tag bits.
643+ */
644+ ALL_TEE_TAGS . forEach ( ( datasetTag ) => {
645+ ALL_TEE_TAGS . forEach ( ( workerpoolTag ) => {
646+ it ( `Should match orders with compatible TEE tags [dataset:${ TAG_NAMES [ datasetTag ] } , workerpool:${ TAG_NAMES [ workerpoolTag ] } ]` , async ( ) => {
647+ orders . dataset . tag = datasetTag ;
648+ orders . workerpool . tag = workerpoolTag ;
649+ orders . app . tag = TAG_TEE ;
650+ orders . requester . tag = TAG_TEE ;
651+
652+ await depositForRequesterAndSchedulerWithDefaultPrices ( volume ) ;
653+ await signOrders ( iexecWrapper . getDomain ( ) , orders , ordersActors ) ;
654+
655+ await expect ( iexecPocoAsRequester . matchOrders ( ...orders . toArray ( ) ) ) . to . emit (
656+ iexecPoco ,
657+ 'OrdersMatched' ,
658+ ) ;
659+ } ) ;
675660 } ) ;
676661 } ) ;
677662
@@ -1163,6 +1148,46 @@ describe('IexecPoco1', () => {
11631148 ) . to . not . be . reverted ;
11641149 } ) ;
11651150
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 ( 'app-salt' ) ;
1168+ newDealOrders . workerpool . salt = ethers . id ( 'workerpool-salt' ) ;
1169+ newDealOrders . requester . salt = ethers . id ( 'requester-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 ( 'dataset-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+
11661191 it ( 'Should revert when the dataset order is revoked or fully consumed' , async ( ) => {
11671192 await signOrder ( iexecWrapper . getDomain ( ) , compatibleDatasetOrder , datasetProvider ) ;
11681193 // Revoke order on-chain.
@@ -1318,64 +1343,6 @@ describe('IexecPoco1', () => {
13181343 . withArgs ( 'Tag compatibility not satisfied' ) ;
13191344 } ) ;
13201345
1321- // TODO: Add more test cases for tag compatibility
1322- [
1323- {
1324- datasetTag : TAG_TEE_SCONE ,
1325- dealTag : TAG_TEE_TDX ,
1326- description : 'Scone tag (0x3) and deal has TDX tag (0x9)' ,
1327- saltPrefix : 'scone-tdx' ,
1328- } ,
1329- {
1330- datasetTag : TAG_TEE_GRAMINE ,
1331- dealTag : TAG_TEE_TDX ,
1332- description : 'Gramine tag (0x5) and deal has TDX tag (0x9)' ,
1333- saltPrefix : 'gramine-tdx' ,
1334- } ,
1335- {
1336- datasetTag : TAG_TEE_TDX ,
1337- dealTag : TAG_TEE_SCONE ,
1338- description : 'TDX tag (0x9) and deal has Scone tag (0x3)' ,
1339- saltPrefix : 'tdx-scone' ,
1340- } ,
1341- {
1342- datasetTag : TAG_ALL_TEE_FRAMEWORKS ,
1343- dealTag : TAG_TEE ,
1344- description : 'all TEE framework bits (0xF) and deal has TEE only (0x1)' ,
1345- saltPrefix : 'all-frameworks-tee' ,
1346- } ,
1347- ] . forEach ( ( { datasetTag, dealTag, description, saltPrefix } ) => {
1348- it ( `Should not revert when dataset has ${ description } ` , async ( ) => {
1349- // Create a deal with the specified tag
1350- const dealOrders = buildOrders ( {
1351- assets : { ...ordersAssets , dataset : ZeroAddress } ,
1352- prices : ordersPrices ,
1353- requester : requester . address ,
1354- tag : dealTag ,
1355- volume : volume ,
1356- } ) ;
1357- dealOrders . app . salt = ethers . id ( `${ saltPrefix } -app-salt` ) ;
1358- dealOrders . workerpool . salt = ethers . id ( `${ saltPrefix } -workerpool-salt` ) ;
1359- dealOrders . requester . salt = ethers . id ( `${ saltPrefix } -requester-salt` ) ;
1360- await depositForRequesterAndSchedulerWithDefaultPrices ( volume ) ;
1361- await signOrders ( iexecWrapper . getDomain ( ) , dealOrders , ordersActors ) ;
1362- const dealId = getDealId ( iexecWrapper . getDomain ( ) , dealOrders . requester ) ;
1363- await iexecPocoAsRequester . matchOrders ( ...dealOrders . toArray ( ) ) ;
1364-
1365- // Create dataset order with the specified tag
1366- const datasetOrder = {
1367- ...compatibleDatasetOrder ,
1368- tag : datasetTag ,
1369- salt : ethers . id ( `${ saltPrefix } -dataset-salt` ) ,
1370- } ;
1371- await signOrder ( iexecWrapper . getDomain ( ) , datasetOrder , datasetProvider ) ;
1372-
1373- // Should not revert because bits 1-3 of dataset tag are ignored
1374- await expect ( iexecPoco . assertDatasetDealCompatibility ( datasetOrder , dealId ) ) . to . not
1375- . be . reverted ;
1376- } ) ;
1377- } ) ;
1378-
13791346 it ( 'Should revert when dataset has bit 4 set (not masked) and deal does not' , async ( ) => {
13801347 // Create a deal with TEE only (0b0001 = 0x1)
13811348 const teeOnlyOrders = buildOrders ( {
0 commit comments