Skip to content

Commit bd3c9a1

Browse files
Merge pull request #81 from iExecBlockchainComputing/hotfix/8.0.1
Run integration tests on `[email protected]`
2 parents 8e4a1ce + 4a39748 commit bd3c9a1

File tree

7 files changed

+48
-29
lines changed

7 files changed

+48
-29
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [[8.0.1]](https://github.com/iExecBlockchainComputing/iexec-blockchain-adapter-api/releases/tag/v8.0.1) 2023-04-06
6+
7+
### Quality
8+
* Run integration tests on `[email protected]`. (#81)
9+
* Connect by default to iExec Bellecour blockchain. (#81)
10+
511
## [[8.0.0]](https://github.com/iExecBlockchainComputing/iexec-blockchain-adapter-api/releases/tag/v8.0.0) 2023-03-03
612

713
### New Features

docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ networks:
77
services:
88

99
ibaa-chain:
10-
image: docker-regis.iex.ec/poco-chain:token-v5.1.0
10+
image: docker-regis.iex.ec/poco-chain:native-v5.4.2-5s
1111
container_name: ibaa-chain
1212
ports:
1313
- 28545:8545
@@ -19,7 +19,7 @@ services:
1919
container_name: ibaa-broker
2020
environment:
2121
- CHAIN=http://ibaa-chain:8545
22-
- PROXY=0xBF6B2B07e47326B7c8bfCb4A5460bef9f0Fd2002
22+
- PROXY=0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca
2323
- MNEMONIC=${BROKER_PRIVATE_KEY} #must use an other wallet for the broker, like wallet-abc
2424
- PORT=3000
2525
ports:
@@ -28,6 +28,7 @@ services:
2828
- ibaa-chain
2929
networks:
3030
- iexec-blockchain-adapter-api-net
31+
restart: unless-stopped
3132

3233
ibaa-blockchain-adapter-mongo:
3334
image: library/mongo:4.4

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=8.0.0
1+
version=8.0.1
22
iexecCommonVersion=7.0.0
33

44
nexusUser

src/itest/java/com/iexec/blockchain/IntegrationTests.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,17 @@
4646

4747
@Slf4j
4848
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
49-
@ActiveProfiles("test")
49+
@ActiveProfiles("itest")
5050
class IntegrationTests {
5151

5252
public static final String USER = "admin";
5353
public static final String PASSWORD = "whatever";
54-
public static final int BLOCK_TIME_MS = 1000;
54+
public static final int BLOCK_TIME_MS = 5000;
55+
public static final int MAX_BLOCK_TO_WAIT = 3;
56+
public static final int POLLING_PER_BLOCK = 2;
57+
public static final int POLLING_INTERVAL_MS = BLOCK_TIME_MS / POLLING_PER_BLOCK;
58+
public static final int MAX_POLLING_ATTEMPTS = MAX_BLOCK_TO_WAIT
59+
* POLLING_PER_BLOCK;
5560

5661
@LocalServerPort
5762
private int randomServerPort;
@@ -83,7 +88,7 @@ public void shouldBeFinalized() throws Exception {
8388
Assertions.assertTrue(StringUtils.isNotEmpty(chainTaskId));
8489
log.info("Requested task initialize: {}", chainTaskId);
8590
//should wait since returned taskID is computed, initialize is not mined yet
86-
waitStatus(chainTaskId, ACTIVE, 1000, 10);
91+
waitStatus(chainTaskId, ACTIVE, POLLING_INTERVAL_MS, MAX_POLLING_ATTEMPTS);
8792

8893
String someBytes32Payload = TeeUtils.TEE_SCONE_ONLY_TAG; //any would be fine
8994
String enclaveChallenge = BytesUtils.EMPTY_ADDRESS;
@@ -98,7 +103,8 @@ public void shouldBeFinalized() throws Exception {
98103
String contributeResponseBody = appClient.requestContributeTask(chainTaskId, contributeArgs);
99104
Assertions.assertTrue(StringUtils.isNotEmpty(contributeResponseBody));
100105
log.info("Requested task contribute: {}", contributeResponseBody);
101-
waitStatus(chainTaskId, ChainTaskStatus.REVEALING, 1000, 10);
106+
waitStatus(chainTaskId, ChainTaskStatus.REVEALING, POLLING_INTERVAL_MS,
107+
MAX_POLLING_ATTEMPTS);
102108

103109
TaskRevealArgs taskRevealArgs = new TaskRevealArgs(someBytes32Payload);
104110
String revealResponseBody = appClient.requestRevealTask(chainTaskId, taskRevealArgs);
@@ -110,7 +116,8 @@ public void shouldBeFinalized() throws Exception {
110116
String finalizeResponseBody = appClient.requestFinalizeTask(chainTaskId, taskFinalizeArgs);
111117
Assertions.assertTrue(StringUtils.isNotEmpty(finalizeResponseBody));
112118
log.info("Requested task finalize: {}", finalizeResponseBody);
113-
waitStatus(chainTaskId, ChainTaskStatus.COMPLETED, 1000, 10);
119+
waitStatus(chainTaskId, ChainTaskStatus.COMPLETED, POLLING_INTERVAL_MS,
120+
MAX_POLLING_ATTEMPTS);
114121
}
115122

116123
@Test
@@ -131,7 +138,8 @@ public void shouldBurstTransactionsWithAverageOfOneTxPerBlock(){
131138
try {
132139
//maximum waiting time equals nb of submitted txs
133140
//1 tx/block means N txs / N blocks
134-
waitStatus(chainTaskId, ACTIVE, BLOCK_TIME_MS, taskVolume + 2);
141+
waitStatus(chainTaskId, ACTIVE, POLLING_INTERVAL_MS,
142+
(taskVolume + 2) * MAX_POLLING_ATTEMPTS);
135143
//no need to wait for propagation update in db
136144
Assertions.assertTrue(true);
137145
} catch (Exception e) {
@@ -144,20 +152,22 @@ public void shouldBurstTransactionsWithAverageOfOneTxPerBlock(){
144152
}
145153

146154
private String triggerDeal(int taskVolume) {
155+
int secondsPollingInterval = POLLING_INTERVAL_MS / 1000;
156+
int secondsTimeout = secondsPollingInterval * MAX_POLLING_ATTEMPTS;
147157
String appAddress = iexecHubService.createApp(buildRandomName("app"),
148158
"docker.io/repo/name:1.0.0",
149159
"DOCKER",
150160
BytesUtils.EMPTY_HEX_STRING_32,
151161
"",
152-
30, 1);
162+
secondsTimeout, secondsPollingInterval);
153163
log.info("Created app: {}", appAddress);
154164
String workerpool = iexecHubService.createWorkerpool(buildRandomName("pool"),
155-
30, 1);
165+
secondsTimeout, secondsPollingInterval);
156166
log.info("Created workerpool: {}", workerpool);
157167
String datasetAddress = iexecHubService.createDataset(buildRandomName("data"),
158168
"https://abc.com/def.jpeg",
159169
BytesUtils.EMPTY_HEX_STRING_32,
160-
30, 1);
170+
secondsTimeout, secondsPollingInterval);
161171
log.info("Created datasetAddress: {}", datasetAddress);
162172

163173
AppOrder signedAppOrder = signerService.signAppOrder(buildAppOrder(appAddress, taskVolume));
@@ -268,8 +278,9 @@ private RequestOrder buildRequestOrder(
268278
.build();
269279
}
270280

281+
//TODO: Use `Awaitility` in `waitStatus` & `waitBeforeFinalizing` methods
271282
/**
272-
*
283+
*
273284
* @param pollingTimeMs recommended value is block time
274285
*/
275286
private void waitStatus(String chainTaskId, ChainTaskStatus statusToWait, int pollingTimeMs, int maxAttempts) throws Exception {
@@ -300,16 +311,15 @@ private void waitBeforeFinalizing(String chainTaskId) throws Exception {
300311
ChainTask chainTask = oChainTask.get();
301312
int winnerCounter = chainTask.getWinnerCounter();
302313
int revealCounter = chainTask.getRevealCounter();
303-
int maxAttempts = 20;
304314
int attempts = 0;
305315
while (revealCounter != winnerCounter) {
306316
log.info("Waiting for reveals ({}/{})", revealCounter, winnerCounter);
307-
Thread.sleep(100);
317+
Thread.sleep(POLLING_INTERVAL_MS);
308318
revealCounter = iexecHubService.getChainTask(chainTaskId)
309319
.map(ChainTask::getRevealCounter)
310320
.orElse(0);
311321
attempts++;
312-
if (attempts == maxAttempts) {
322+
if (attempts == MAX_POLLING_ATTEMPTS) {
313323
throw new Exception("Too long to wait for reveal: " + chainTaskId);
314324
}
315325
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
spring:
2+
data:
3+
mongodb:
4+
port: 23012
5+
6+
chain:
7+
id: 65535
8+
node-address: http://localhost:28545
9+
hub-address: "0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca"
10+
broker-url: http://localhost:23000

src/main/resources/application.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ spring:
1313
port: ${IEXEC_BLOCKCHAIN_ADAPTER_API_MONGO_PORT:13012}
1414

1515
chain:
16-
id: ${IEXEC_BLOCKCHAIN_ADAPTER_API_CHAIN_ID:65535}
17-
node-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_NODE_ADDRESS:http://localhost:8545} #https://viviani.iex.ec/
18-
block-time: ${IEXEC_BLOCKCHAIN_ADAPTER_API_BLOCK_TIME:1} #in seconds, use 15 for mainnet
19-
hub-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_HUB_ADDRESS:0xBF6B2B07e47326B7c8bfCb4A5460bef9f0Fd2002} #0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f
20-
is-sidechain: ${IEXEC_BLOCKCHAIN_ADAPTER_API_IS_SIDECHAIN:false}
16+
id: ${IEXEC_BLOCKCHAIN_ADAPTER_API_CHAIN_ID:134}
17+
node-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_NODE_ADDRESS:https://bellecour.iex.ec}
18+
block-time: ${IEXEC_BLOCKCHAIN_ADAPTER_API_BLOCK_TIME:5} #in seconds
19+
hub-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_HUB_ADDRESS:0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f}
20+
is-sidechain: ${IEXEC_BLOCKCHAIN_ADAPTER_API_IS_SIDECHAIN:true}
2121
gas-price-multiplier: ${IEXEC_BLOCKCHAIN_ADAPTER_API_GAS_PRICE_MULTIPLIER:1.0} # txs will be sent with networkGasPrice*gasPriceMultiplier, 4.0 means super fast
2222
gas-price-cap: ${IEXEC_BLOCKCHAIN_ADAPTER_API_GAS_PRICE_CAP:22000000000} #in Wei, will be used for txs if networkGasPrice*gasPriceMultiplier > gasPriceCap
2323
broker-url: ${IEXEC_BLOCKCHAIN_ADAPTER_API_BROKER_URL:http://localhost:3000}
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
spring:
2-
data:
3-
mongodb:
4-
port: 23012
5-
6-
chain:
7-
node-address: http://localhost:28545
8-
broker-url: http://localhost:23000

0 commit comments

Comments
 (0)