Skip to content

Commit

Permalink
Merge pull request #81 from iExecBlockchainComputing/hotfix/8.0.1
Browse files Browse the repository at this point in the history
Run integration tests on `[email protected]`
  • Loading branch information
jeremyjams authored Apr 6, 2023
2 parents 8e4a1ce + 4a39748 commit bd3c9a1
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 29 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [[8.0.1]](https://github.com/iExecBlockchainComputing/iexec-blockchain-adapter-api/releases/tag/v8.0.1) 2023-04-06

### Quality
* Run integration tests on `[email protected]`. (#81)
* Connect by default to iExec Bellecour blockchain. (#81)

## [[8.0.0]](https://github.com/iExecBlockchainComputing/iexec-blockchain-adapter-api/releases/tag/v8.0.0) 2023-03-03

### New Features
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ networks:
services:

ibaa-chain:
image: docker-regis.iex.ec/poco-chain:token-v5.1.0
image: docker-regis.iex.ec/poco-chain:native-v5.4.2-5s
container_name: ibaa-chain
ports:
- 28545:8545
Expand All @@ -19,7 +19,7 @@ services:
container_name: ibaa-broker
environment:
- CHAIN=http://ibaa-chain:8545
- PROXY=0xBF6B2B07e47326B7c8bfCb4A5460bef9f0Fd2002
- PROXY=0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca
- MNEMONIC=${BROKER_PRIVATE_KEY} #must use an other wallet for the broker, like wallet-abc
- PORT=3000
ports:
Expand All @@ -28,6 +28,7 @@ services:
- ibaa-chain
networks:
- iexec-blockchain-adapter-api-net
restart: unless-stopped

ibaa-blockchain-adapter-mongo:
image: library/mongo:4.4
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=8.0.0
version=8.0.1
iexecCommonVersion=7.0.0

nexusUser
Expand Down
36 changes: 23 additions & 13 deletions src/itest/java/com/iexec/blockchain/IntegrationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@

@Slf4j
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@ActiveProfiles("itest")
class IntegrationTests {

public static final String USER = "admin";
public static final String PASSWORD = "whatever";
public static final int BLOCK_TIME_MS = 1000;
public static final int BLOCK_TIME_MS = 5000;
public static final int MAX_BLOCK_TO_WAIT = 3;
public static final int POLLING_PER_BLOCK = 2;
public static final int POLLING_INTERVAL_MS = BLOCK_TIME_MS / POLLING_PER_BLOCK;
public static final int MAX_POLLING_ATTEMPTS = MAX_BLOCK_TO_WAIT
* POLLING_PER_BLOCK;

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

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

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

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

private String triggerDeal(int taskVolume) {
int secondsPollingInterval = POLLING_INTERVAL_MS / 1000;
int secondsTimeout = secondsPollingInterval * MAX_POLLING_ATTEMPTS;
String appAddress = iexecHubService.createApp(buildRandomName("app"),
"docker.io/repo/name:1.0.0",
"DOCKER",
BytesUtils.EMPTY_HEX_STRING_32,
"",
30, 1);
secondsTimeout, secondsPollingInterval);
log.info("Created app: {}", appAddress);
String workerpool = iexecHubService.createWorkerpool(buildRandomName("pool"),
30, 1);
secondsTimeout, secondsPollingInterval);
log.info("Created workerpool: {}", workerpool);
String datasetAddress = iexecHubService.createDataset(buildRandomName("data"),
"https://abc.com/def.jpeg",
BytesUtils.EMPTY_HEX_STRING_32,
30, 1);
secondsTimeout, secondsPollingInterval);
log.info("Created datasetAddress: {}", datasetAddress);

AppOrder signedAppOrder = signerService.signAppOrder(buildAppOrder(appAddress, taskVolume));
Expand Down Expand Up @@ -268,8 +278,9 @@ private RequestOrder buildRequestOrder(
.build();
}

//TODO: Use `Awaitility` in `waitStatus` & `waitBeforeFinalizing` methods
/**
*
*
* @param pollingTimeMs recommended value is block time
*/
private void waitStatus(String chainTaskId, ChainTaskStatus statusToWait, int pollingTimeMs, int maxAttempts) throws Exception {
Expand Down Expand Up @@ -300,16 +311,15 @@ private void waitBeforeFinalizing(String chainTaskId) throws Exception {
ChainTask chainTask = oChainTask.get();
int winnerCounter = chainTask.getWinnerCounter();
int revealCounter = chainTask.getRevealCounter();
int maxAttempts = 20;
int attempts = 0;
while (revealCounter != winnerCounter) {
log.info("Waiting for reveals ({}/{})", revealCounter, winnerCounter);
Thread.sleep(100);
Thread.sleep(POLLING_INTERVAL_MS);
revealCounter = iexecHubService.getChainTask(chainTaskId)
.map(ChainTask::getRevealCounter)
.orElse(0);
attempts++;
if (attempts == maxAttempts) {
if (attempts == MAX_POLLING_ATTEMPTS) {
throw new Exception("Too long to wait for reveal: " + chainTaskId);
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/itest/resources/application-itest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spring:
data:
mongodb:
port: 23012

chain:
id: 65535
node-address: http://localhost:28545
hub-address: "0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca"
broker-url: http://localhost:23000
10 changes: 5 additions & 5 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ spring:
port: ${IEXEC_BLOCKCHAIN_ADAPTER_API_MONGO_PORT:13012}

chain:
id: ${IEXEC_BLOCKCHAIN_ADAPTER_API_CHAIN_ID:65535}
node-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_NODE_ADDRESS:http://localhost:8545} #https://viviani.iex.ec/
block-time: ${IEXEC_BLOCKCHAIN_ADAPTER_API_BLOCK_TIME:1} #in seconds, use 15 for mainnet
hub-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_HUB_ADDRESS:0xBF6B2B07e47326B7c8bfCb4A5460bef9f0Fd2002} #0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f
is-sidechain: ${IEXEC_BLOCKCHAIN_ADAPTER_API_IS_SIDECHAIN:false}
id: ${IEXEC_BLOCKCHAIN_ADAPTER_API_CHAIN_ID:134}
node-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_NODE_ADDRESS:https://bellecour.iex.ec}
block-time: ${IEXEC_BLOCKCHAIN_ADAPTER_API_BLOCK_TIME:5} #in seconds
hub-address: ${IEXEC_BLOCKCHAIN_ADAPTER_API_HUB_ADDRESS:0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f}
is-sidechain: ${IEXEC_BLOCKCHAIN_ADAPTER_API_IS_SIDECHAIN:true}
gas-price-multiplier: ${IEXEC_BLOCKCHAIN_ADAPTER_API_GAS_PRICE_MULTIPLIER:1.0} # txs will be sent with networkGasPrice*gasPriceMultiplier, 4.0 means super fast
gas-price-cap: ${IEXEC_BLOCKCHAIN_ADAPTER_API_GAS_PRICE_CAP:22000000000} #in Wei, will be used for txs if networkGasPrice*gasPriceMultiplier > gasPriceCap
broker-url: ${IEXEC_BLOCKCHAIN_ADAPTER_API_BROKER_URL:http://localhost:3000}
Expand Down
8 changes: 0 additions & 8 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
spring:
data:
mongodb:
port: 23012

chain:
node-address: http://localhost:28545
broker-url: http://localhost:23000

0 comments on commit bd3c9a1

Please sign in to comment.