@@ -1075,6 +1075,173 @@ describe('IexecPoco1', () => {
10751075 } ) ;
10761076 } ) ;
10771077
1078+ describe ( 'isDatasetCompatibleWithDeal' , ( ) => {
1079+ let dealIdWithoutDataset : string ;
1080+ let compatibleDatasetOrder : IexecLibOrders_v5 . DatasetOrderStruct ;
1081+ let incompatibleDatasetOrder : IexecLibOrders_v5 . DatasetOrderStruct ;
1082+
1083+ beforeEach ( 'Create a deal without dataset and dataset orders' , async ( ) => {
1084+ // Create a deal without dataset
1085+ const ordersWithoutDataset = buildOrders ( {
1086+ assets : { ...ordersAssets , dataset : ZeroAddress } ,
1087+ prices : ordersPrices ,
1088+ requester : requester . address ,
1089+ tag : teeDealTag ,
1090+ volume : volume ,
1091+ } ) ;
1092+ await depositForRequesterAndSchedulerWithDefaultPrices ( volume ) ;
1093+ await signOrders ( iexecWrapper . getDomain ( ) , ordersWithoutDataset , ordersActors ) ;
1094+ dealIdWithoutDataset = getDealId (
1095+ iexecWrapper . getDomain ( ) ,
1096+ ordersWithoutDataset . requester ,
1097+ ) ;
1098+ await iexecPocoAsRequester . matchOrders ( ...ordersWithoutDataset . toArray ( ) ) ;
1099+
1100+ // Create a compatible dataset order (same restrictions as the deal)
1101+ compatibleDatasetOrder = {
1102+ dataset : datasetAddress ,
1103+ datasetprice : datasetPrice ,
1104+ volume : volume ,
1105+ tag : teeDealTag ,
1106+ apprestrict : ordersWithoutDataset . app . app ,
1107+ workerpoolrestrict : ordersWithoutDataset . workerpool . workerpool ,
1108+ requesterrestrict : ordersWithoutDataset . requester . requester ,
1109+ salt : ethers . keccak256 ( ethers . toUtf8Bytes ( 'compatible-salt' ) ) ,
1110+ sign : '0x' ,
1111+ } ;
1112+ await signOrder ( iexecWrapper . getDomain ( ) , compatibleDatasetOrder , datasetProvider ) ;
1113+
1114+ // Create an incompatible dataset order (different restrictions)
1115+ incompatibleDatasetOrder = {
1116+ dataset : datasetAddress ,
1117+ datasetprice : datasetPrice ,
1118+ volume : volume ,
1119+ tag : teeDealTag ,
1120+ apprestrict : randomAddress , // Different app restriction
1121+ workerpoolrestrict : ordersWithoutDataset . workerpool . workerpool ,
1122+ requesterrestrict : ordersWithoutDataset . requester . requester ,
1123+ salt : ethers . keccak256 ( ethers . toUtf8Bytes ( 'incompatible-salt' ) ) ,
1124+ sign : '0x' ,
1125+ } ;
1126+ await signOrder ( iexecWrapper . getDomain ( ) , incompatibleDatasetOrder , datasetProvider ) ;
1127+ } ) ;
1128+
1129+ it ( 'Should return true for compatible dataset order' , async ( ) => {
1130+ expect (
1131+ await iexecPocoAsSponsor . isDatasetCompatibleWithDeal (
1132+ compatibleDatasetOrder ,
1133+ dealIdWithoutDataset ,
1134+ ) ,
1135+ ) . to . be . true ;
1136+ } ) ;
1137+
1138+ it ( 'Should return false for incompatible dataset order (app restriction)' , async ( ) => {
1139+ expect (
1140+ await iexecPocoAsSponsor . isDatasetCompatibleWithDeal (
1141+ incompatibleDatasetOrder ,
1142+ dealIdWithoutDataset ,
1143+ ) ,
1144+ ) . to . be . false ;
1145+ } ) ;
1146+
1147+ it ( 'Should return false for non-existent deal' , async ( ) => {
1148+ const nonExistentDealId = ethers . keccak256 ( ethers . toUtf8Bytes ( 'non-existent-deal' ) ) ;
1149+ expect (
1150+ await iexecPocoAsSponsor . isDatasetCompatibleWithDeal (
1151+ compatibleDatasetOrder ,
1152+ nonExistentDealId ,
1153+ ) ,
1154+ ) . to . be . false ;
1155+ } ) ;
1156+
1157+ it ( 'Should return false for dataset order with invalid signature' , async ( ) => {
1158+ // Create dataset order with invalid signature
1159+ const invalidSignatureDatasetOrder = {
1160+ ...compatibleDatasetOrder ,
1161+ sign : randomSignature , // Invalid signature
1162+ } ;
1163+
1164+ expect (
1165+ await iexecPocoAsSponsor . isDatasetCompatibleWithDeal (
1166+ invalidSignatureDatasetOrder ,
1167+ dealIdWithoutDataset ,
1168+ ) ,
1169+ ) . to . be . false ;
1170+ } ) ;
1171+
1172+ it ( 'Should return false for fully consumed dataset order' , async ( ) => {
1173+ // Create dataset order with volume 0 (fully consumed)
1174+ const consumedDatasetOrder = {
1175+ ...compatibleDatasetOrder ,
1176+ volume : 0n ,
1177+ } ;
1178+ await signOrder ( iexecWrapper . getDomain ( ) , consumedDatasetOrder , datasetProvider ) ;
1179+
1180+ expect (
1181+ await iexecPocoAsSponsor . isDatasetCompatibleWithDeal (
1182+ consumedDatasetOrder ,
1183+ dealIdWithoutDataset ,
1184+ ) ,
1185+ ) . to . be . false ;
1186+ } ) ;
1187+
1188+ it ( 'Should return false for dataset order with incompatible tag' , async ( ) => {
1189+ // Create dataset order with incompatible tag
1190+ const incompatibleTagDatasetOrder = {
1191+ ...compatibleDatasetOrder ,
1192+ tag : '0x0000000000000000000000000000000000000000000000000000000000000002' , // Different tag
1193+ } ;
1194+ await signOrder ( iexecWrapper . getDomain ( ) , incompatibleTagDatasetOrder , datasetProvider ) ;
1195+
1196+ expect (
1197+ await iexecPocoAsSponsor . isDatasetCompatibleWithDeal (
1198+ incompatibleTagDatasetOrder ,
1199+ dealIdWithoutDataset ,
1200+ ) ,
1201+ ) . to . be . false ;
1202+ } ) ;
1203+
1204+ it ( 'Should return false for dataset order with incompatible workerpool restriction' , async ( ) => {
1205+ // Create dataset order with incompatible workerpool restriction
1206+ const incompatibleWorkerpoolDatasetOrder = {
1207+ ...compatibleDatasetOrder ,
1208+ workerpoolrestrict : randomAddress , // Different workerpool restriction
1209+ } ;
1210+ await signOrder (
1211+ iexecWrapper . getDomain ( ) ,
1212+ incompatibleWorkerpoolDatasetOrder ,
1213+ datasetProvider ,
1214+ ) ;
1215+
1216+ expect (
1217+ await iexecPocoAsSponsor . isDatasetCompatibleWithDeal (
1218+ incompatibleWorkerpoolDatasetOrder ,
1219+ dealIdWithoutDataset ,
1220+ ) ,
1221+ ) . to . be . false ;
1222+ } ) ;
1223+
1224+ it ( 'Should return false for dataset order with incompatible requester restriction' , async ( ) => {
1225+ // Create dataset order with incompatible requester restriction
1226+ const incompatibleRequesterDatasetOrder = {
1227+ ...compatibleDatasetOrder ,
1228+ requesterrestrict : randomAddress , // Different requester restriction
1229+ } ;
1230+ await signOrder (
1231+ iexecWrapper . getDomain ( ) ,
1232+ incompatibleRequesterDatasetOrder ,
1233+ datasetProvider ,
1234+ ) ;
1235+
1236+ expect (
1237+ await iexecPocoAsSponsor . isDatasetCompatibleWithDeal (
1238+ incompatibleRequesterDatasetOrder ,
1239+ dealIdWithoutDataset ,
1240+ ) ,
1241+ ) . to . be . false ;
1242+ } ) ;
1243+ } ) ;
1244+
10781245 /**
10791246 * Helper function to deposit requester and scheduler stakes with
10801247 * default prices for tests that do not rely on custom prices.
0 commit comments