2727import org .junit .jupiter .api .BeforeEach ;
2828import org .junit .jupiter .api .Tag ;
2929import org .junit .jupiter .api .Test ;
30+ import org .junit .jupiter .params .ParameterizedTest ;
31+ import org .junit .jupiter .params .provider .Arguments ;
32+ import org .junit .jupiter .params .provider .MethodSource ;
3033import org .testcontainers .containers .ComposeContainer ;
3134import org .testcontainers .junit .jupiter .Container ;
3235import org .testcontainers .junit .jupiter .Testcontainers ;
4548import java .util .List ;
4649import java .util .Map ;
4750import java .util .concurrent .TimeUnit ;
51+ import java .util .stream .Stream ;
4852
4953import static com .iexec .commons .poco .encoding .MatchOrdersDataEncoder .encodeAssertDatasetDealCompatibility ;
5054import static com .iexec .commons .poco .itest .ChainTests .SERVICE_NAME ;
5155import static com .iexec .commons .poco .itest .ChainTests .SERVICE_PORT ;
5256import static com .iexec .commons .poco .itest .IexecHubTestService .*;
5357import static com .iexec .commons .poco .itest .Web3jTestService .MINING_TIMEOUT ;
54- import static org .assertj .core .api .Assertions .assertThat ;
55- import static org .assertj .core .api .Assertions .assertThatThrownBy ;
58+ import static org .assertj .core .api .Assertions .*;
5659import static org .awaitility .Awaitility .await ;
5760
5861@ Slf4j
@@ -237,6 +240,51 @@ void shouldMatchOrdersWithoutDataset() throws IOException {
237240 }
238241 }
239242
243+ @ ParameterizedTest
244+ @ MethodSource ("provideValidTags" )
245+ void shouldMatchOrdersWithValidTags (final String appTag , final String datasetTag , final String requestTag , final String workerpoolTag ) throws IOException {
246+ final Map <String , String > deployedAddresses = iexecHubService .deployAssets ();
247+ final AppOrder signedAppOrder = ordersService .buildSignedAppOrder (deployedAddresses .get ("app" ), appTag );
248+ final DatasetOrder signedDatasetOrder = ordersService .buildSignedDatasetOrder (deployedAddresses .get ("dataset" ), datasetTag );
249+ final WorkerpoolOrder signedWorkerpoolOrder = ordersService .buildSignedWorkerpoolOrder (deployedAddresses .get ("workerpool" ), BigInteger .ONE , workerpoolTag );
250+ final RequestOrder signedRequestOrder = ordersService .buildSignedRequestOrder (
251+ signedAppOrder , signedDatasetOrder , signedWorkerpoolOrder , BigInteger .ONE , requestTag );
252+
253+ final String matchOrdersTxData = MatchOrdersDataEncoder .encode (signedAppOrder , signedDatasetOrder , signedWorkerpoolOrder , signedRequestOrder );
254+ assertThatNoException ().isThrownBy (() -> signerService .estimateGas (IEXEC_HUB_ADDRESS , matchOrdersTxData ));
255+ }
256+
257+ static Stream <Arguments > provideValidTags () {
258+ return Stream .of (
259+ Arguments .of ("0x1" , "0x1" , "0x1" , "0x1" ),
260+ Arguments .of ("0x1" , "0x1" , "0x0" , "0x1" ),
261+ Arguments .of ("0x1" , "0x0" , "0x1" , "0x1" ),
262+ Arguments .of ("0x1" , "0x0" , "0x0" , "0x1" ),
263+ Arguments .of ("0x0" , "0x0" , "0x0" , "0x1" ));
264+ }
265+
266+ @ ParameterizedTest
267+ @ MethodSource ("provideInvalidTags" )
268+ void shouldNotMatchOrdersWithInvalidTags (final String appTag , final String datasetTag , final String requestTag , final String workerpoolTag ) throws IOException {
269+ final Map <String , String > deployedAddresses = iexecHubService .deployAssets ();
270+ final AppOrder signedAppOrder = ordersService .buildSignedAppOrder (deployedAddresses .get ("app" ), appTag );
271+ final DatasetOrder signedDatasetOrder = ordersService .buildSignedDatasetOrder (deployedAddresses .get ("dataset" ), datasetTag );
272+ final WorkerpoolOrder signedWorkerpoolOrder = ordersService .buildSignedWorkerpoolOrder (deployedAddresses .get ("workerpool" ), BigInteger .ONE , workerpoolTag );
273+ final RequestOrder signedRequestOrder = ordersService .buildSignedRequestOrder (
274+ signedAppOrder , signedDatasetOrder , signedWorkerpoolOrder , BigInteger .ONE , requestTag );
275+
276+ final String matchOrdersTxData = MatchOrdersDataEncoder .encode (signedAppOrder , signedDatasetOrder , signedWorkerpoolOrder , signedRequestOrder );
277+ assertThatThrownBy (() -> signerService .estimateGas (IEXEC_HUB_ADDRESS , matchOrdersTxData ))
278+ .isInstanceOf (JsonRpcError .class )
279+ .hasMessage ("iExecV5-matchOrders-0x07" );
280+ }
281+
282+ static Stream <Arguments > provideInvalidTags () {
283+ return Stream .of (
284+ Arguments .of ("0x0" , "0x0" , "0x1" , "0x1" ),
285+ Arguments .of ("0x0" , "0x1" , "0x0" , "0x1" ));
286+ }
287+
240288 // region utils
241289 private DatasetOrder .DatasetOrderBuilder getValidOrderBuilder (final String datasetAddress ) {
242290 return DatasetOrder .builder ()
@@ -257,8 +305,7 @@ private Map<DatasetOrder, String> getInvalidOrders(final String datasetAddress)
257305 Map .entry (getValidOrderBuilder (datasetAddress ).apprestrict (IEXEC_HUB_ADDRESS ).build (), "App restriction not satisfied" ),
258306 Map .entry (getValidOrderBuilder (datasetAddress ).workerpoolrestrict (IEXEC_HUB_ADDRESS ).build (), "Workerpool restriction not satisfied" ),
259307 Map .entry (getValidOrderBuilder (datasetAddress ).requesterrestrict (IEXEC_HUB_ADDRESS ).build (), "Requester restriction not satisfied" ),
260- Map .entry (getValidOrderBuilder (datasetAddress ).tag (OrderTag .TEE_GRAMINE .getValue ()).build (), "Tag compatibility not satisfied" ),
261- Map .entry (getValidOrderBuilder (datasetAddress ).tag (OrderTag .TEE_TDX .getValue ()).build (), "Tag compatibility not satisfied" )
308+ Map .entry (getValidOrderBuilder (datasetAddress ).tag ("0xFF" ).build (), "Tag compatibility not satisfied" )
262309 );
263310 }
264311
0 commit comments