@@ -1112,22 +1112,25 @@ describe('IexecPoco1', () => {
11121112 } ) ;
11131113
11141114 it ( 'Should return true for compatible dataset order' , async ( ) => {
1115- expect (
1116- await iexecPoco . isDatasetCompatibleWithDeal (
1117- compatibleDatasetOrder ,
1118- dealIdWithoutDataset ,
1119- ) ,
1120- ) . to . be . true ;
1115+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1116+ compatibleDatasetOrder ,
1117+ dealIdWithoutDataset ,
1118+ ) ;
1119+ expect ( result ) . to . be . true ;
1120+ expect ( reason ) . to . equal ( '' ) ;
11211121 } ) ;
11221122
1123- it ( 'Should revert with status for non-existent deal' , async ( ) => {
1123+ it ( 'Should return false with reason for non-existent deal' , async ( ) => {
11241124 const nonExistentDealId = ethers . keccak256 ( ethers . toUtf8Bytes ( 'non-existent-deal' ) ) ;
1125- await expect (
1126- iexecPoco . isDatasetCompatibleWithDeal ( compatibleDatasetOrder , nonExistentDealId ) ,
1127- ) . to . be . revertedWith ( 'DatasetCompatibilityCheck: 0-1-1-1-0-0-0-0' ) ;
1125+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1126+ compatibleDatasetOrder ,
1127+ nonExistentDealId ,
1128+ ) ;
1129+ expect ( result ) . to . be . false ;
1130+ expect ( reason ) . to . equal ( 'Deal does not exist' ) ;
11281131 } ) ;
11291132
1130- it ( 'Should revert with status for deal with a dataset' , async ( ) => {
1133+ it ( 'Should return false with reason for deal with a dataset' , async ( ) => {
11311134 // Use the original orders that include a dataset to create a deal with dataset
11321135 const ordersWithDataset = buildOrders ( {
11331136 assets : ordersAssets , // This includes the dataset
@@ -1157,56 +1160,62 @@ describe('IexecPoco1', () => {
11571160 ) ;
11581161 await iexecPocoAsRequester . matchOrders ( ...ordersWithDataset . toArray ( ) ) ;
11591162
1160- await expect (
1161- iexecPoco . isDatasetCompatibleWithDeal ( compatibleDatasetOrder , dealIdWithDataset ) ,
1162- ) . to . be . revertedWith ( 'DatasetCompatibilityCheck: 1-0-1-1-1-1-1-1' ) ;
1163+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1164+ compatibleDatasetOrder ,
1165+ dealIdWithDataset ,
1166+ ) ;
1167+ expect ( result ) . to . be . false ;
1168+ expect ( reason ) . to . equal ( 'Deal already has a dataset' ) ;
11631169 } ) ;
11641170
1165- it ( 'Should revert with status for dataset order with invalid signature' , async ( ) => {
1171+ it ( 'Should return false with reason for dataset order with invalid signature' , async ( ) => {
11661172 // Create dataset order with invalid signature
11671173 const invalidSignatureDatasetOrder = {
11681174 ...compatibleDatasetOrder ,
11691175 sign : randomSignature , // Invalid signature
11701176 } ;
11711177
1172- await expect (
1173- iexecPoco . isDatasetCompatibleWithDeal (
1174- invalidSignatureDatasetOrder ,
1175- dealIdWithoutDataset ,
1176- ) ,
1177- ) . to . be . revertedWith ( 'DatasetCompatibilityCheck: 1-1-0-1-1-1-1-1 ') ;
1178+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1179+ invalidSignatureDatasetOrder ,
1180+ dealIdWithoutDataset ,
1181+ ) ;
1182+ expect ( result ) . to . be . false ;
1183+ expect ( reason ) . to . equal ( 'Invalid dataset order signature ') ;
11781184 } ) ;
11791185
1180- it ( 'Should revert with status for fully consumed dataset order' , async ( ) => {
1186+ it ( 'Should return false with reason for fully consumed dataset order' , async ( ) => {
11811187 // Create dataset order with volume 0 (fully consumed)
11821188 const consumedDatasetOrder = {
11831189 ...compatibleDatasetOrder ,
11841190 volume : 0n ,
11851191 } ;
11861192 await signOrder ( iexecWrapper . getDomain ( ) , consumedDatasetOrder , datasetProvider ) ;
11871193
1188- await expect (
1189- iexecPoco . isDatasetCompatibleWithDeal ( consumedDatasetOrder , dealIdWithoutDataset ) ,
1190- ) . to . be . revertedWith ( 'DatasetCompatibilityCheck: 1-1-1-0-1-1-1-1' ) ;
1194+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1195+ consumedDatasetOrder ,
1196+ dealIdWithoutDataset ,
1197+ ) ;
1198+ expect ( result ) . to . be . false ;
1199+ expect ( reason ) . to . equal ( 'Dataset order is fully consumed' ) ;
11911200 } ) ;
11921201
1193- it ( 'Should revert with status for dataset order with incompatible app restriction' , async ( ) => {
1202+ it ( 'Should return false with reason for dataset order with incompatible app restriction' , async ( ) => {
11941203 // Create dataset order with incompatible app restriction
11951204 const incompatibleAppDatasetOrder = {
11961205 ...compatibleDatasetOrder ,
11971206 apprestrict : randomAddress , // Different app restriction
11981207 } ;
11991208 await signOrder ( iexecWrapper . getDomain ( ) , incompatibleAppDatasetOrder , datasetProvider ) ;
12001209
1201- await expect (
1202- iexecPoco . isDatasetCompatibleWithDeal (
1203- incompatibleAppDatasetOrder ,
1204- dealIdWithoutDataset ,
1205- ) ,
1206- ) . to . be . revertedWith ( 'DatasetCompatibilityCheck: 1-1-1-1-0-1-1-1 ') ;
1210+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1211+ incompatibleAppDatasetOrder ,
1212+ dealIdWithoutDataset ,
1213+ ) ;
1214+ expect ( result ) . to . be . false ;
1215+ expect ( reason ) . to . equal ( 'App restriction not satisfied ') ;
12071216 } ) ;
12081217
1209- it ( 'Should revert with status for dataset order with incompatible workerpool restriction' , async ( ) => {
1218+ it ( 'Should return false with reason for dataset order with incompatible workerpool restriction' , async ( ) => {
12101219 // Create dataset order with incompatible workerpool restriction
12111220 const incompatibleWorkerpoolDatasetOrder = {
12121221 ...compatibleDatasetOrder ,
@@ -1218,15 +1227,15 @@ describe('IexecPoco1', () => {
12181227 datasetProvider ,
12191228 ) ;
12201229
1221- await expect (
1222- iexecPoco . isDatasetCompatibleWithDeal (
1223- incompatibleWorkerpoolDatasetOrder ,
1224- dealIdWithoutDataset ,
1225- ) ,
1226- ) . to . be . revertedWith ( 'DatasetCompatibilityCheck: 1-1-1-1-1-0-1-1 ') ;
1230+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1231+ incompatibleWorkerpoolDatasetOrder ,
1232+ dealIdWithoutDataset ,
1233+ ) ;
1234+ expect ( result ) . to . be . false ;
1235+ expect ( reason ) . to . equal ( 'Workerpool restriction not satisfied ') ;
12271236 } ) ;
12281237
1229- it ( 'Should revert with status for dataset order with incompatible requester restriction' , async ( ) => {
1238+ it ( 'Should return false with reason for dataset order with incompatible requester restriction' , async ( ) => {
12301239 // Create dataset order with incompatible requester restriction
12311240 const incompatibleRequesterDatasetOrder = {
12321241 ...compatibleDatasetOrder ,
@@ -1238,28 +1247,28 @@ describe('IexecPoco1', () => {
12381247 datasetProvider ,
12391248 ) ;
12401249
1241- await expect (
1242- iexecPoco . isDatasetCompatibleWithDeal (
1243- incompatibleRequesterDatasetOrder ,
1244- dealIdWithoutDataset ,
1245- ) ,
1246- ) . to . be . revertedWith ( 'DatasetCompatibilityCheck: 1-1-1-1-1-1-0-1 ') ;
1250+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1251+ incompatibleRequesterDatasetOrder ,
1252+ dealIdWithoutDataset ,
1253+ ) ;
1254+ expect ( result ) . to . be . false ;
1255+ expect ( reason ) . to . equal ( 'Requester restriction not satisfied ') ;
12471256 } ) ;
12481257
1249- it ( 'Should revert with status for dataset order with incompatible tag' , async ( ) => {
1258+ it ( 'Should return false with reason for dataset order with incompatible tag' , async ( ) => {
12501259 // Create dataset order with incompatible tag
12511260 const incompatibleTagDatasetOrder = {
12521261 ...compatibleDatasetOrder ,
12531262 tag : '0x0000000000000000000000000000000000000000000000000000000000000002' , // Different tag
12541263 } ;
12551264 await signOrder ( iexecWrapper . getDomain ( ) , incompatibleTagDatasetOrder , datasetProvider ) ;
12561265
1257- await expect (
1258- iexecPoco . isDatasetCompatibleWithDeal (
1259- incompatibleTagDatasetOrder ,
1260- dealIdWithoutDataset ,
1261- ) ,
1262- ) . to . be . revertedWith ( 'DatasetCompatibilityCheck: 1-1-1-1-1-1-1-0 ') ;
1266+ const [ result , reason ] = await iexecPoco . isDatasetCompatibleWithDeal (
1267+ incompatibleTagDatasetOrder ,
1268+ dealIdWithoutDataset ,
1269+ ) ;
1270+ expect ( result ) . to . be . false ;
1271+ expect ( reason ) . to . equal ( 'Tag compatibility not satisfied ') ;
12631272 } ) ;
12641273 } ) ;
12651274
0 commit comments