diff --git a/CHANGELOG.md b/CHANGELOG.md index 7acb7b4..269f94e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `poco-chain@native-v5.4.2-5s`. (#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 diff --git a/docker-compose.yml b/docker-compose.yml index 885718e..35303ac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 @@ -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: @@ -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 diff --git a/gradle.properties b/gradle.properties index e15dd10..db2e997 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=8.0.0 +version=8.0.1 iexecCommonVersion=7.0.0 nexusUser diff --git a/src/itest/java/com/iexec/blockchain/IntegrationTests.java b/src/itest/java/com/iexec/blockchain/IntegrationTests.java index 5a07c93..9c89a1c 100644 --- a/src/itest/java/com/iexec/blockchain/IntegrationTests.java +++ b/src/itest/java/com/iexec/blockchain/IntegrationTests.java @@ -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; @@ -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; @@ -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); @@ -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 @@ -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) { @@ -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)); @@ -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 { @@ -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); } } diff --git a/src/itest/resources/application-itest.yml b/src/itest/resources/application-itest.yml new file mode 100644 index 0000000..3657932 --- /dev/null +++ b/src/itest/resources/application-itest.yml @@ -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 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ae76b81..4fa651f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -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} diff --git a/src/test/resources/application-test.yml b/src/test/resources/application-test.yml index 418df38..e69de29 100644 --- a/src/test/resources/application-test.yml +++ b/src/test/resources/application-test.yml @@ -1,8 +0,0 @@ -spring: - data: - mongodb: - port: 23012 - -chain: - node-address: http://localhost:28545 - broker-url: http://localhost:23000 \ No newline at end of file