1818
1919import com .iexec .common .result .ComputedFile ;
2020import com .iexec .commons .poco .chain .*;
21+ import com .iexec .commons .poco .order .OrderTag ;
2122import com .iexec .commons .poco .security .Signature ;
2223import com .iexec .commons .poco .task .TaskDescription ;
24+ import com .iexec .commons .poco .tee .TeeUtils ;
2325import com .iexec .commons .poco .utils .BytesUtils ;
2426import com .iexec .commons .poco .utils .HashUtils ;
2527import com .iexec .commons .poco .utils .SignatureUtils ;
@@ -71,10 +73,13 @@ class ContributionServiceTests {
7173 .contributors (List .of ())
7274 .build ();
7375
74- private final TaskDescription taskDescription = TaskDescription .builder ()
75- .chainTaskId (chainTask .getChainTaskId ())
76- .trust (BigInteger .ONE )
77- .build ();
76+ TaskDescription getTaskDescription (final OrderTag tag ) {
77+ return TaskDescription .builder ()
78+ .chainTaskId (chainTask .getChainTaskId ())
79+ .trust (BigInteger .ONE )
80+ .teeFramework (TeeUtils .getTeeFramework (tag .getValue ()))
81+ .build ();
82+ }
7883
7984 @ BeforeEach
8085 void beforeEach () {
@@ -101,14 +106,9 @@ void shouldChainTaskNotBeInitialized() {
101106 @ Test
102107 void getCannotContributeStatusCauseShouldReturnWorkerpoolAuthorizationNotFound () {
103108 final String chainTaskId = chainTask .getChainTaskId ();
104- final TaskDescription contributeAndFinalizeTaskDescription = TaskDescription .builder ()
105- .chainTaskId (chainTaskId )
106- .trust (BigInteger .ONE )
107- .isTeeTask (true )
108- .build ();
109109
110110 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId )).thenReturn (null );
111- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (contributeAndFinalizeTaskDescription );
111+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . TEE_SCONE ) );
112112 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (chainTask ));
113113
114114 assertThat (contributionService .getCannotContributeStatusCause (chainTaskId ))
@@ -122,7 +122,7 @@ void getCannotContributeStatusShouldReturnChainUnreachable() {
122122 final String chainTaskId = "chainTaskId" ;
123123 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId ))
124124 .thenReturn (getTeeWorkerpoolAuth ());
125- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
125+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
126126 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .empty ());
127127
128128 assertThat (contributionService .getCannotContributeStatusCause (chainTaskId ))
@@ -137,7 +137,7 @@ void getCannotContributeStatusShouldReturnStakeTooLow() {
137137
138138 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId ))
139139 .thenReturn (getTeeWorkerpoolAuth ());
140- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
140+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
141141 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (chainTask ));
142142 when (iexecHubService .getChainAccount ()).thenReturn (Optional .of (ChainAccount .builder ().deposit (0 ).build ()));
143143 when (iexecHubService .getChainDeal (CHAIN_DEAL_ID )).thenReturn (Optional .of (ChainDeal .builder ().workerStake (BigInteger .valueOf (5 )).build ()));
@@ -163,7 +163,7 @@ void getCannotContributeStatusShouldReturnTaskNotActive() {
163163
164164 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId ))
165165 .thenReturn (getTeeWorkerpoolAuth ());
166- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
166+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
167167 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (inactiveTask ));
168168 when (iexecHubService .getChainAccount ()).thenReturn (Optional .of (ChainAccount .builder ().deposit (1000 ).build ()));
169169 when (iexecHubService .getChainDeal (CHAIN_DEAL_ID )).thenReturn (Optional .of (ChainDeal .builder ().workerStake (BigInteger .valueOf (5 )).build ()));
@@ -188,7 +188,7 @@ void getCannotContributeStatusShouldReturnAfterDeadline() {
188188
189189 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId ))
190190 .thenReturn (getTeeWorkerpoolAuth ());
191- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
191+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
192192 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (timedOutChainTask ));
193193 when (iexecHubService .getChainAccount ())
194194 .thenReturn (Optional .of (ChainAccount .builder ().deposit (1000 ).build ()));
@@ -216,7 +216,7 @@ void getCannotContributeStatusShouldReturnContributionAlreadySet() {
216216
217217 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId ))
218218 .thenReturn (getTeeWorkerpoolAuth ());
219- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
219+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
220220 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (alreadyContributedChainTask ));
221221 when (iexecHubService .getChainAccount ())
222222 .thenReturn (Optional .of (ChainAccount .builder ().deposit (1000 ).build ()));
@@ -237,7 +237,7 @@ void getCannotContributeStatusCauseShouldReturnEmpty() {
237237
238238 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId ))
239239 .thenReturn (getTeeWorkerpoolAuth ());
240- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
240+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
241241 when (iexecHubService .getChainTask (chainTaskId ))
242242 .thenReturn (Optional .of (chainTask ));
243243 when (iexecHubService .getChainAccount ())
@@ -256,14 +256,10 @@ void getCannotContributeStatusCauseShouldReturnEmpty() {
256256 @ Test
257257 void getCannotContributeStatusShouldReturnEmptyForContributeAndFinalizeFlow () {
258258 final String chainTaskId = chainTask .getChainTaskId ();
259- final TaskDescription contributeAndFinalizeTaskDescription = TaskDescription .builder ()
260- .trust (BigInteger .ONE )
261- .isTeeTask (true )
262- .build ();
263259
264260 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId ))
265261 .thenReturn (getTeeWorkerpoolAuth ());
266- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (contributeAndFinalizeTaskDescription );
262+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . TEE_SCONE ) );
267263 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (chainTask ));
268264
269265 assertThat (contributionService .getCannotContributeStatusCause (chainTaskId )).isEmpty ();
@@ -286,7 +282,7 @@ void getCannotContributeStatusShouldReturnMultipleErrors() {
286282
287283 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId ))
288284 .thenReturn (getTeeWorkerpoolAuth ());
289- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
285+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
290286 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (problematicChainTask ));
291287 when (iexecHubService .getChainAccount ())
292288 .thenReturn (Optional .of (ChainAccount .builder ().deposit (0 ).build ())); // Also stake too low
@@ -310,7 +306,7 @@ void getCannotContributeStatusShouldReturnAuthAndChainUnreachableErrors() {
310306 final String chainTaskId = chainTask .getChainTaskId ();
311307
312308 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId )).thenReturn (null );
313- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
309+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
314310 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .empty ());
315311
316312 assertThat (contributionService .getCannotContributeStatusCause (chainTaskId ))
@@ -342,7 +338,7 @@ void getCannotContributeAndFinalizeStatusCauseShouldReturnTrustNotOne() {
342338 void getCannotContributeAndFinalizeStatusCauseShouldReturnChainUnreachable () {
343339 final String chainTaskId = chainTask .getChainTaskId ();
344340
345- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
341+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
346342 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .empty ());
347343
348344 assertThat (contributionService .getCannotContributeAndFinalizeStatusCause (chainTaskId ))
@@ -362,7 +358,7 @@ void getCannotContributeAndFinalizeStatusCauseShouldReturnTaskAlreadyContributed
362358
363359 final String chainTaskId = chainTaskWithContribution .getChainTaskId ();
364360
365- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
361+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
366362 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (chainTaskWithContribution ));
367363
368364 assertThat (contributionService .getCannotContributeAndFinalizeStatusCause (chainTaskId ))
@@ -373,7 +369,7 @@ void getCannotContributeAndFinalizeStatusCauseShouldReturnTaskAlreadyContributed
373369 void getCannotContributeAndFinalizeStatusCauseShouldReturnEmpty () {
374370 final String chainTaskId = chainTask .getChainTaskId ();
375371
376- when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (taskDescription );
372+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
377373 when (iexecHubService .getChainTask (chainTaskId )).thenReturn (Optional .of (chainTask ));
378374
379375 assertThat (contributionService .getCannotContributeAndFinalizeStatusCause (chainTaskId )).isEmpty ();
@@ -433,7 +429,7 @@ void getContribution() {
433429
434430 final WorkerpoolAuthorization teeWorkerpoolAuth = getTeeWorkerpoolAuth ();
435431 when (workerpoolAuthorizationService .getWorkerpoolAuthorization (chainTaskId )).thenReturn (teeWorkerpoolAuth );
436- when (iexecHubService .isTeeTask (chainTaskId )).thenReturn (false );
432+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . STANDARD ) );
437433
438434 final ComputedFile computedFile = ComputedFile .builder ()
439435 .taskId (chainTaskId )
@@ -469,7 +465,7 @@ void getContributionWithTee() {
469465 when (enclaveAuthorizationService .
470466 isVerifiedEnclaveSignature (anyString (), anyString (), anyString (), anyString (), anyString ()))
471467 .thenReturn (true );
472- when (iexecHubService .isTeeTask (chainTaskId )).thenReturn (true );
468+ when (iexecHubService .getTaskDescription (chainTaskId )).thenReturn (getTaskDescription ( OrderTag . TEE_SCONE ) );
473469
474470 final ComputedFile computedFile = ComputedFile .builder ()
475471 .taskId (chainTaskId )
0 commit comments