use of com.hedera.services.bdd.suites.utils.validation.domain.Network.SCENARIO_PAYER_NAME in project hedera-services by hashgraph.
the class ValidationScenarios method fileScenario.
private static HapiApiSpec fileScenario() {
try {
ensureScenarios();
if (scenarios.getFile() == null) {
var fs = new FileScenario();
fs.setPersistent(new PersistentFile());
scenarios.setFile(fs);
}
var file = scenarios.getFile();
return customHapiSpec("FileScenario").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())), ensureValidatedFileExistence(PERSISTENT_FILE_NAME, file.getPersistent().getContents(), pemForFile(persistentOrNegativeOne(file).getAsLong()), persistentOrNegativeOne(file), num -> file.getPersistent().setNum(num), loc -> file.getPersistent().setContents(loc))).when().then(novelFileIfDesired());
} catch (Exception e) {
log.warn("Unable to initialize file scenario, skipping it!", e);
errorsOccurred.set(true);
return null;
}
}
use of com.hedera.services.bdd.suites.utils.validation.domain.Network.SCENARIO_PAYER_NAME in project hedera-services by hashgraph.
the class ValidationScenarios method contractScenario.
private static HapiApiSpec contractScenario() {
try {
ensureScenarios();
if (scenarios.getContract() == null) {
var cs = new ContractScenario();
cs.setPersistent(new PersistentContract());
scenarios.setContract(cs);
}
var contract = scenarios.getContract();
Object[] donationArgs = new Object[] { Integer.valueOf((int) targetNetwork().getBootstrap()), "Hey, Ma!" };
return customHapiSpec("ContractScenario").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())), ensureValidatedContractExistence(PERSISTENT_CONTRACT_NAME, contract.getPersistent().getLuckyNo(), contract.getPersistent().getSource(), pemForContract(persistentContractOrNegativeOne(contract).getAsLong()), persistentContractOrNegativeOne(contract), num -> contract.getPersistent().setNum(num), bytecodeNum -> contract.getPersistent().setBytecode(bytecodeNum), luckyNo -> contract.getPersistent().setLuckyNo(luckyNo), loc -> contract.getPersistent().setSource(loc))).when(flattened(contractCall(PERSISTENT_CONTRACT_NAME).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).sending(1L), contractCall(PERSISTENT_CONTRACT_NAME, ContractResources.CONSPICUOUS_DONATION_ABI, donationArgs).payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).via("donation"), getTxnRecord("donation").payingWith(SCENARIO_PAYER_NAME).setNodeFrom(ValidationScenarios::nextNode).logged().hasPriority(recordWith().transfers(includingDeduction(contract.getPersistent()::getNum, 1))), novelContractIfDesired(contract))).then();
} catch (Exception e) {
log.warn("Unable to initialize contract scenario, skipping it!", e);
errorsOccurred.set(true);
return null;
}
}
use of com.hedera.services.bdd.suites.utils.validation.domain.Network.SCENARIO_PAYER_NAME in project hedera-services by hashgraph.
the class ValidationScenarios method appropriateQuery.
private static HapiSpecOperation appropriateQuery(SysFilesDownScenario sys, long fileNum) {
String fid = String.format("0.0.%d", fileNum);
SysFileSerde<String> serde = SYS_FILE_SERDES.get(fileNum);
String fqn = params.getTargetNetwork() + "-" + serde.preferredFileName();
String loc = "files/" + fqn;
UnaryOperator<byte[]> preCompare = (fileNum == 121 || fileNum == 122) ? ValidationScenarios::asOrdered : bytes -> bytes;
if (SysFilesDownScenario.COMPARE_EVAL_MODE.equals(sys.getEvalMode())) {
String actualLoc = "files/actual-" + fqn;
try {
byte[] expected = serde.toRawFile(readString(Paths.get(loc)));
return getFileContents(fid).payingWith(SCENARIO_PAYER_NAME).saveReadableTo(serde::fromRawFile, actualLoc).hasContents(spec -> expected).afterBytesTransform(preCompare);
} catch (IOException e) {
throw new IllegalStateException("Cannot read comparison file @ '" + loc + "'!", e);
}
} else if (SysFilesDownScenario.SNAPSHOT_EVAL_MODE.equals(sys.getEvalMode())) {
return getFileContents(fid).payingWith(SCENARIO_PAYER_NAME).saveReadableTo(serde::fromRawFile, loc);
} else {
throw new IllegalArgumentException("No such sys files eval mode '" + sys.getEvalMode() + "'!");
}
}
use of com.hedera.services.bdd.suites.utils.validation.domain.Network.SCENARIO_PAYER_NAME 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