11/*
2- * Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
2+ * Copyright 2020-2025 IEXEC BLOCKCHAIN TECH
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2828import com .iexec .commons .poco .chain .DealParams ;
2929import com .iexec .commons .poco .task .TaskDescription ;
3030import com .iexec .commons .poco .tee .TeeEnclaveConfiguration ;
31+ import com .iexec .commons .poco .utils .BytesUtils ;
3132import com .iexec .sms .api .TeeSessionGenerationResponse ;
3233import com .iexec .worker .config .WorkerConfigurationService ;
3334import com .iexec .worker .docker .DockerService ;
4445import org .mockito .junit .jupiter .MockitoExtension ;
4546
4647import java .time .Duration ;
47- import java .util .ArrayList ;
48- import java .util .Arrays ;
49- import java .util .Collections ;
5048import java .util .List ;
5149
5250import static org .mockito .ArgumentMatchers .any ;
5553@ ExtendWith (MockitoExtension .class )
5654class AppComputeServiceTests {
5755
56+ private static final String CHAIN_DEAL_ID = "CHAIN_DEAL_ID" ;
5857 private static final String CHAIN_TASK_ID = "CHAIN_TASK_ID" ;
59- private static final String DATASET_URI = "DATASET_URI" ;
6058 private static final String APP_URI = "APP_URI" ;
6159 private static final String WORKER_NAME = "WORKER_NAME" ;
6260 private static final TeeSessionGenerationResponse SECURE_SESSION = mock (TeeSessionGenerationResponse .class );
@@ -66,13 +64,17 @@ class AppComputeServiceTests {
6664 public static final long HEAP_SIZE = 1024 ;
6765
6866 private final DealParams dealParams = DealParams .builder ()
69- .iexecInputFiles (Arrays . asList ("file0" , "file1" ))
67+ .iexecInputFiles (List . of ("file0" , "file1" ))
7068 .build ();
7169
7270 private final TaskDescription .TaskDescriptionBuilder taskDescriptionBuilder = TaskDescription .builder ()
71+ .chainDealId (CHAIN_DEAL_ID )
7372 .chainTaskId (CHAIN_TASK_ID )
73+ .botIndex (0 )
74+ .botSize (1 )
75+ .botFirstIndex (0 )
7476 .appUri (APP_URI )
75- .datasetUri ( DATASET_URI )
77+ .datasetAddress ( BytesUtils . EMPTY_ADDRESS )
7678 .maxExecutionTime (MAX_EXECUTION_TIME )
7779 .dealParams (dealParams )
7880 .isTeeTask (true );
@@ -103,16 +105,14 @@ void shouldRunCompute() {
103105 String iexecOutBind = IEXEC_OUT + ":" + IexecFileHelper .SLASH_IEXEC_OUT ;
104106 when (dockerService .getIexecOutBind (CHAIN_TASK_ID )).thenReturn (iexecOutBind );
105107 when (workerConfigService .getWorkerName ()).thenReturn (WORKER_NAME );
106- DockerRunResponse expectedDockerRunResponse = DockerRunResponse
107- .builder ()
108+ DockerRunResponse expectedDockerRunResponse = DockerRunResponse .builder ()
108109 .finalStatus (DockerRunFinalStatus .SUCCESS )
109110 .executionDuration (Duration .ofSeconds (10 ))
110111 .build ();
111112 when (dockerService .run (any ())).thenReturn (expectedDockerRunResponse );
112113
113- AppComputeResponse appComputeResponse =
114- appComputeService .runCompute (taskDescription ,
115- SECURE_SESSION );
114+ final AppComputeResponse appComputeResponse =
115+ appComputeService .runCompute (taskDescription , SECURE_SESSION );
116116
117117 Assertions .assertThat (appComputeResponse .isSuccessful ()).isTrue ();
118118 verify (dockerService ).run (any ());
@@ -123,7 +123,7 @@ void shouldRunCompute() {
123123 argumentCaptor .getAllValues ().get (0 );
124124 HostConfig hostConfig = HostConfig .newHostConfig ()
125125 .withBinds (Bind .parse (inputBind ), Bind .parse (iexecOutBind ))
126- .withDevices (new ArrayList <> ());
126+ .withDevices (List . of ());
127127 Assertions .assertThat (dockerRunRequest ).isEqualTo (
128128 DockerRunRequest .builder ()
129129 .hostConfig (hostConfig )
@@ -145,10 +145,8 @@ void shouldRunComputeWithTeeAndConnectAppToLas() {
145145 .build ();
146146 when (teeServicesManager .getTeeService (any ())).thenReturn (teeMockedService );
147147 when (teeMockedService .buildComputeDockerEnv (taskDescription , SECURE_SESSION ))
148- .thenReturn (Arrays .asList ("var0" , "var1" ));
149- List <String > env = new ArrayList <>(Arrays .asList ("var0" , "var1" ));
150- env .addAll (IexecEnvUtils .getComputeStageEnvList (taskDescription ));
151- Collections .sort (env );
148+ .thenReturn (List .of ("var0" , "var1" ));
149+ final List <String > env = List .of ("var0" , "var1" );
152150 String inputBind = INPUT + ":" + IexecFileHelper .SLASH_IEXEC_IN ;
153151 when (dockerService .getInputBind (CHAIN_TASK_ID )).thenReturn (inputBind );
154152 String iexecOutBind = IEXEC_OUT + ":" + IexecFileHelper .SLASH_IEXEC_OUT ;
@@ -176,7 +174,6 @@ void shouldRunComputeWithTeeAndConnectAppToLas() {
176174 verify (dockerService ).run (argumentCaptor .capture ());
177175 DockerRunRequest dockerRunRequest =
178176 argumentCaptor .getAllValues ().get (0 );
179- Collections .sort (dockerRunRequest .getEnv ());
180177 HostConfig hostConfig = HostConfig .newHostConfig ()
181178 .withBinds (Bind .parse (inputBind ), Bind .parse (iexecOutBind ))
182179 .withDevices (devices )
0 commit comments