1919import com .iexec .blockchain .api .BlockchainAdapterApiClient ;
2020import com .iexec .blockchain .api .BlockchainAdapterApiClientBuilder ;
2121import com .iexec .blockchain .broker .BrokerService ;
22- import com .iexec .blockchain .tool .ChainConfig ;
23- import com .iexec .blockchain .tool .IexecHubService ;
22+ import com .iexec .blockchain .chain .ChainConfig ;
23+ import com .iexec .blockchain .chain .IexecHubService ;
2424import com .iexec .common .chain .adapter .args .TaskFinalizeArgs ;
2525import com .iexec .common .sdk .broker .BrokerOrder ;
2626import com .iexec .commons .poco .chain .*;
3636import feign .Logger ;
3737import lombok .extern .slf4j .Slf4j ;
3838import org .apache .commons .lang3 .RandomStringUtils ;
39- import org .apache .commons .lang3 .StringUtils ;
40- import org .awaitility .Awaitility ;
4139import org .junit .jupiter .api .Assertions ;
4240import org .junit .jupiter .api .BeforeEach ;
4341import org .junit .jupiter .api .Test ;
6866import static com .iexec .commons .poco .chain .ChainTaskStatus .ACTIVE ;
6967import static com .iexec .commons .poco .chain .ChainTaskStatus .UNSET ;
7068import static org .assertj .core .api .Assertions .assertThat ;
69+ import static org .awaitility .Awaitility .await ;
7170
7271@ Slf4j
7372@ Testcontainers
@@ -78,7 +77,7 @@ class IntegrationTests {
7877 private static final String CHAIN_SVC_NAME = "ibaa-chain" ;
7978 private static final int CHAIN_SVC_PORT = 8545 ;
8079 private static final String MONGO_SVC_NAME = "ibaa-blockchain-adapter-mongo" ;
81- private static final int MONGO_SVC_PORT = 13012 ;
80+ private static final int MONGO_SVC_PORT = 27017 ;
8281
8382 public static final String USER = "admin" ;
8483 public static final String PASSWORD = "whatever" ;
@@ -90,14 +89,14 @@ class IntegrationTests {
9089
9190 @ Container
9291 static ComposeContainer environment = new ComposeContainer (new File ("docker-compose.yml" ))
93- .withPull (true )
9492 .withExposedService (CHAIN_SVC_NAME , CHAIN_SVC_PORT , Wait .forListeningPort ())
95- .withExposedService (MONGO_SVC_NAME , MONGO_SVC_PORT , Wait .forListeningPort ());
93+ .withExposedService (MONGO_SVC_NAME , MONGO_SVC_PORT , Wait .forListeningPort ())
94+ .withPull (true );
9695
9796 @ DynamicPropertySource
9897 static void registerProperties (DynamicPropertyRegistry registry ) {
9998 registry .add ("chain.id" , () -> "65535" );
100- registry .add ("chain.hubAddress" , () -> "0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca " );
99+ registry .add ("chain.hubAddress" , () -> "0xc4b11f41746D3Ad8504da5B383E1aB9aa969AbC7 " );
101100 registry .add ("chain.nodeAddress" , () -> getServiceUrl (
102101 environment .getServiceHost (CHAIN_SVC_NAME , CHAIN_SVC_PORT ),
103102 environment .getServicePort (CHAIN_SVC_NAME , CHAIN_SVC_PORT )));
@@ -138,18 +137,18 @@ private static String getServiceUrl(String serviceHost, int servicePort) {
138137 @ Test
139138 void shouldBeFinalized () throws Exception {
140139 TransactionReceipt receipt ;
141- String dealId = triggerDeal (1 );
140+ final String dealId = triggerDeal (1 );
142141
143- String chainTaskId = appClient .requestInitializeTask (dealId , 0 );
144- Assertions . assertTrue ( StringUtils .isNotEmpty (chainTaskId ) );
142+ final String chainTaskId = appClient .requestInitializeTask (dealId , 0 );
143+ assertThat ( chainTaskId ) .isNotEmpty ();
145144 log .info ("Requested task initialize: {}" , chainTaskId );
146145 //should wait since returned taskID is computed, initialize is not mined yet
147146 waitStatus (chainTaskId , ACTIVE , MAX_POLLING_ATTEMPTS );
148147
149- String someBytes32Payload = TeeUtils .TEE_SCONE_ONLY_TAG ; //any would be fine
150- String enclaveChallenge = BytesUtils .EMPTY_ADDRESS ;
151- String enclaveSignature = BytesUtils .bytesToString (new byte [65 ]);
152- WorkerpoolAuthorization workerpoolAuthorization =
148+ final String someBytes32Payload = TeeUtils .TEE_SCONE_ONLY_TAG ; //any would be fine
149+ final String enclaveChallenge = BytesUtils .EMPTY_ADDRESS ;
150+ final String enclaveSignature = BytesUtils .bytesToString (new byte [65 ]);
151+ final WorkerpoolAuthorization workerpoolAuthorization =
153152 mockAuthorization (chainTaskId , enclaveChallenge );
154153 receipt = iexecHubService .contribute (
155154 chainTaskId ,
@@ -165,9 +164,9 @@ void shouldBeFinalized() throws Exception {
165164 log .info ("reveal {}" , receipt );
166165
167166 waitBeforeFinalizing (chainTaskId );
168- TaskFinalizeArgs taskFinalizeArgs = new TaskFinalizeArgs ();
169- String finalizeResponseBody = appClient .requestFinalizeTask (chainTaskId , taskFinalizeArgs );
170- Assertions . assertTrue ( StringUtils .isNotEmpty (finalizeResponseBody ) );
167+ final TaskFinalizeArgs taskFinalizeArgs = new TaskFinalizeArgs ("" , "" );
168+ final String finalizeResponseBody = appClient .requestFinalizeTask (chainTaskId , taskFinalizeArgs );
169+ assertThat ( finalizeResponseBody ) .isNotEmpty ();
171170 log .info ("Requested task finalize: {}" , finalizeResponseBody );
172171 waitStatus (chainTaskId , ChainTaskStatus .COMPLETED ,
173172 MAX_POLLING_ATTEMPTS );
@@ -176,14 +175,14 @@ void shouldBeFinalized() throws Exception {
176175 @ Test
177176 void shouldBurstTransactionsWithAverageOfOneTxPerBlock () {
178177 int taskVolume = 10 ;//small volume ensures reasonable execution time on CI/CD
179- String dealId = triggerDeal (taskVolume );
180- List <CompletableFuture <Void >> txCompletionWatchers = new ArrayList <>();
178+ final String dealId = triggerDeal (taskVolume );
179+ final List <CompletableFuture <Void >> txCompletionWatchers = new ArrayList <>();
181180
182181 IntStream .range (0 , taskVolume )
183182 .forEach (taskIndex -> {
184183 //burst transactions (fast sequence) (send "initialize" tx examples for simplicity)
185184 String chainTaskId = appClient .requestInitializeTask (dealId , taskIndex );
186- Assertions . assertTrue ( StringUtils .isNotEmpty (chainTaskId ) );
185+ assertThat ( chainTaskId ) .isNotEmpty ();
187186 log .info ("Requested task initialize [index:{}, chainTaskId:{}]" ,
188187 taskIndex , chainTaskId );
189188 //wait tx completion outside
@@ -205,30 +204,30 @@ void shouldBurstTransactionsWithAverageOfOneTxPerBlock() {
205204 }
206205
207206 private String triggerDeal (int taskVolume ) {
208- int secondsPollingInterval = POLLING_INTERVAL_MS / 1000 ;
209- int secondsTimeout = secondsPollingInterval * MAX_POLLING_ATTEMPTS ;
210- String appAddress = iexecHubService .createApp (buildRandomName ("app" ),
207+ final int secondsPollingInterval = POLLING_INTERVAL_MS / 1000 ;
208+ final int secondsTimeout = secondsPollingInterval * MAX_POLLING_ATTEMPTS ;
209+ final String appAddress = iexecHubService .createApp (buildRandomName ("app" ),
211210 "docker.io/repo/name:1.0.0" ,
212211 "DOCKER" ,
213212 BytesUtils .EMPTY_HEX_STRING_32 ,
214213 "" ,
215214 secondsTimeout , secondsPollingInterval );
216215 log .info ("Created app: {}" , appAddress );
217- String workerpool = iexecHubService .createWorkerpool (buildRandomName ("pool" ),
216+ final String workerpool = iexecHubService .createWorkerpool (buildRandomName ("pool" ),
218217 secondsTimeout , secondsPollingInterval );
219218 log .info ("Created workerpool: {}" , workerpool );
220- String datasetAddress = iexecHubService .createDataset (buildRandomName ("data" ),
219+ final String datasetAddress = iexecHubService .createDataset (buildRandomName ("data" ),
221220 "https://abc.com/def.jpeg" ,
222221 BytesUtils .EMPTY_HEX_STRING_32 ,
223222 secondsTimeout , secondsPollingInterval );
224223 log .info ("Created datasetAddress: {}" , datasetAddress );
225224
226- OrderSigner orderSigner = new OrderSigner (
225+ final OrderSigner orderSigner = new OrderSigner (
227226 chainConfig .getId (), chainConfig .getHubAddress (), signerService .getCredentials ().getEcKeyPair ());
228- AppOrder signedAppOrder = orderSigner .signAppOrder (buildAppOrder (appAddress , taskVolume ));
229- WorkerpoolOrder signedWorkerpoolOrder = orderSigner .signWorkerpoolOrder (buildWorkerpoolOrder (workerpool , taskVolume ));
230- DatasetOrder signedDatasetOrder = orderSigner .signDatasetOrder (buildDatasetOrder (datasetAddress , taskVolume ));
231- RequestOrder signedRequestOrder = orderSigner .signRequestOrder (buildRequestOrder (signedAppOrder ,
227+ final AppOrder signedAppOrder = orderSigner .signAppOrder (buildAppOrder (appAddress , taskVolume ));
228+ final WorkerpoolOrder signedWorkerpoolOrder = orderSigner .signWorkerpoolOrder (buildWorkerpoolOrder (workerpool , taskVolume ));
229+ final DatasetOrder signedDatasetOrder = orderSigner .signDatasetOrder (buildDatasetOrder (datasetAddress , taskVolume ));
230+ final RequestOrder signedRequestOrder = orderSigner .signRequestOrder (buildRequestOrder (signedAppOrder ,
232231 signedWorkerpoolOrder ,
233232 signedDatasetOrder ,
234233 signerService .getAddress (),
@@ -237,18 +236,18 @@ private String triggerDeal(int taskVolume) {
237236 .iexecResultStorageProvider ("ipfs" )
238237 .iexecResultStorageProxy ("https://v6.result.goerli.iex.ec" )
239238 .build ()));
240- BrokerOrder brokerOrder = BrokerOrder .builder ()
239+ final BrokerOrder brokerOrder = BrokerOrder .builder ()
241240 .appOrder (signedAppOrder )
242241 .workerpoolOrder (signedWorkerpoolOrder )
243242 .requestOrder (signedRequestOrder )
244243 .datasetOrder (signedDatasetOrder )
245244 .build ();
246245
247- String dealId = brokerService .matchOrders (brokerOrder );
248- Assertions . assertTrue ( StringUtils .isNotEmpty (dealId ) );
246+ final String dealId = brokerService .matchOrders (brokerOrder );
247+ assertThat ( dealId ) .isNotEmpty ();
249248 log .info ("Created deal: {}" , dealId );
250249 // no need to wait since broker is synchronous, just checking deal existence
251- Optional <ChainDeal > chainDeal = iexecHubService .getChainDeal (dealId );
250+ final Optional <ChainDeal > chainDeal = iexecHubService .getChainDeal (dealId );
252251 assertThat (chainDeal ).isPresent ();
253252 return dealId ;
254253 }
@@ -334,7 +333,7 @@ private RequestOrder buildRequestOrder(
334333
335334 private void waitStatus (String chainTaskId , ChainTaskStatus statusToWait , int maxAttempts ) {
336335 final AtomicInteger attempts = new AtomicInteger ();
337- Awaitility . await ()
336+ await ()
338337 .pollInterval (POLLING_INTERVAL_MS , TimeUnit .MILLISECONDS )
339338 .timeout ((long ) maxAttempts * POLLING_INTERVAL_MS , TimeUnit .MILLISECONDS )
340339 .until (() -> {
@@ -358,7 +357,7 @@ private void waitBeforeFinalizing(String chainTaskId) {
358357 log .info ("{} {}" , POLLING_INTERVAL_MS , MAX_POLLING_ATTEMPTS );
359358
360359 final AtomicInteger attempts = new AtomicInteger ();
361- Awaitility . await ()
360+ await ()
362361 .pollInterval (POLLING_INTERVAL_MS , TimeUnit .MILLISECONDS )
363362 .timeout ((long ) MAX_POLLING_ATTEMPTS * POLLING_INTERVAL_MS , TimeUnit .MILLISECONDS )
364363 .until (() -> {
0 commit comments