use of com.hedera.services.bdd.suites.utils.validation.domain.CryptoScenario in project hedera-services by hashgraph.
the class ValidationScenarios method cryptoScenario.
private static HapiApiSpec cryptoScenario() {
try {
ensureScenarios();
if (scenarios.getCrypto() == null) {
scenarios.setCrypto(new CryptoScenario());
}
var crypto = scenarios.getCrypto();
var transferFee = new AtomicLong(0);
long expectedDelta = params.isNovelContent() ? 2L : 1L;
return customHapiSpec("CryptoScenario").withProperties(Map.of("nodes", nodes(), "default.payer", primaryPayer(), "default.node", defaultNode(), "fees.useFixedOffer", "true", "fees.fixedOffer", "" + FEE_TO_OFFER, "startupAccounts.literal", payerKeystoreLiteral())).given(keyFromPem(() -> pemForAccount(targetNetwork().getScenarioPayer())).name(SCENARIO_PAYER_NAME).linkedTo(() -> String.format("0.0.%d", targetNetwork().getScenarioPayer())), ensureValidatedAccountExistence(SENDER_NAME, 2L, pemForAccount(senderOrNegativeOne(crypto).getAsLong()), senderOrNegativeOne(crypto), crypto::setSender), ensureValidatedAccountExistence(RECEIVER_NAME, 0L, pemForAccount(receiverOrNegativeOne(crypto).getAsLong()), receiverOrNegativeOne(crypto), crypto::setReceiver), balanceSnapshot("receiverBefore", RECEIVER_NAME)).when(flattened(cryptoTransfer(tinyBarsFromTo(SENDER_NAME, RECEIVER_NAME, 1L)).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).via("transferTxn"), withOpContext((spec, opLog) -> {
var lookup = getTxnRecord("transferTxn").payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).logged();
allRunFor(spec, lookup);
var record = lookup.getResponseRecord();
transferFee.set(record.getTransactionFee());
}), novelAccountIfDesired(transferFee))).then(getAccountBalance(RECEIVER_NAME).setNodeFrom(ValidationScenarios::nextNode).hasTinyBars(changeFromSnapshot("receiverBefore", expectedDelta)));
} catch (Exception e) {
log.warn("Unable to initialize crypto scenario, skipping it!", e);
errorsOccurred.set(true);
return null;
}
}
Aggregations