use of com.hedera.services.bdd.spec.utilops.UtilVerbs.sleepFor in project hedera-services by hashgraph.
the class UpdateAllProtectedFilesDuringReconnect method updateAllProtectedFilesDuringReconnect.
private HapiApiSpec updateAllProtectedFilesDuringReconnect() {
final String fileInfoRegistry = "apiPermissionsReconnect";
final String nonUpdatableFile = "nonUpdatableFile";
return customHapiSpec("UpdateAllProtectedFilesDuringReconnect").withProperties(Map.of("txn.start.offset.secs", "-5")).given(saveFileToRegistry(APP_PROPERTIES, APP_FILE_REGISTRY), saveFileToRegistry(API_PERMISSIONS, API_FILE_REGISTRY), saveFileToRegistry(EXCHANGE_RATES, RATES_FILE_REGISTRY), saveFileToRegistry(FEE_SCHEDULE, FEES_FILE_REGISTRY), sleepFor(Duration.ofSeconds(25).toMillis()), getAccountBalance(GENESIS).setNode("0.0.8").unavailableNode()).when(fileUpdate(APP_PROPERTIES).payingWith(GENESIS).overridingProps(Map.of("ledger.autoRenewPeriod.minDuration", "20")).erasingProps(Set.of("minimumAutoRenewDuration")), fileUpdate(API_PERMISSIONS).payingWith(GENESIS).overridingProps(Map.of("updateFile", "2-50")), fileCreate(nonUpdatableFile).contents("Cannot update file because of the new api permissions"), fileUpdate(EXCHANGE_RATES).contents(spec -> {
ByteString newRates = spec.ratesProvider().rateSetWith(100, 1).toByteString();
spec.registry().saveBytes("newRates", newRates);
return newRates;
}).payingWith(GENESIS), makeFree(CryptoGetInfo), getAccountBalance(GENESIS).setNode("0.0.8").unavailableNode()).then(withLiveNode("0.0.8").within(5 * 60, TimeUnit.SECONDS).loggingAvailabilityEvery(30).sleepingBetweenRetriesFor(10), UtilVerbs.sleepFor(30 * 1000), withLiveNode("0.0.8").within(5 * 60, TimeUnit.SECONDS).loggingAvailabilityEvery(30).sleepingBetweenRetriesFor(10), getFileContents(API_PERMISSIONS).logged().setNode("0.0.3").payingWith(GENESIS).saveToRegistry(fileInfoRegistry), getFileContents(API_PERMISSIONS).logged().setNode("0.0.8").payingWith(GENESIS).hasContents(fileInfoRegistry), fileUpdate(nonUpdatableFile).setNode("0.0.8").fee(ONE_MILLION_HBARS).hasPrecheck(NOT_SUPPORTED), fileCreate("contractFile").setNode("0.0.8").payingWith(GENESIS).path(ContractResources.VALID_BYTECODE_PATH), contractCreate("testContract").bytecode("contractFile").autoRenewSecs(15).setNode("0.0.8").hasPrecheck(AUTORENEW_DURATION_NOT_IN_RANGE), cryptoCreate("civilian").setNode("0.0.8").fee(ONE_HUNDRED_HBARS).hasPrecheck(INSUFFICIENT_TX_FEE), cryptoCreate("civilian").setNode("0.0.8"), getAccountInfo("0.0.2").payingWith("civilian").nodePayment(0L).setNode("0.0.8").hasAnswerOnlyPrecheck(OK), restoreFileFromRegistry(APP_PROPERTIES, APP_FILE_REGISTRY), restoreFileFromRegistry(API_PERMISSIONS, API_FILE_REGISTRY), restoreFileFromRegistry(EXCHANGE_RATES, RATES_FILE_REGISTRY), restoreFileFromRegistry(FEE_SCHEDULE, FEES_FILE_REGISTRY));
}
Aggregations