use of com.hedera.services.bdd.suites.utils.validation.ValidationScenarios.Scenario.FILE in project hedera-services by hashgraph.
the class ValidationScenarios method updatePaymentCsv.
private static HapiApiSpec updatePaymentCsv() {
ensureScenarios();
if (scenarios.getFeeSnapshots() == null) {
scenarios.setFeeSnapshots(new FeeSnapshotsScenario());
}
var feeSnapshots = scenarios.getFeeSnapshots();
try {
return customHapiSpec("UpdatePaymentCsv").withProperties(Map.of("nodes", nodes(), "default.payer", primaryPayer(), "default.node", defaultNode(), "fees.useFixedOffer", "true", "fees.fixedOffer", "" + FEE_TO_OFFER, "startupAccounts.literal", payerKeystoreLiteral())).given().when().then(withOpContext((spec, opLog) -> {
var payments = HapiApiSpec.costSnapshotFrom("cost-snapshots/fees/ValidationScenarios-FeeSnapshots-costs.properties");
var network = params.getTargetNetwork();
var feesCsvLoc = String.format("fees/%s-fees.csv", network);
var csvFile = new File(feesCsvLoc);
if (!feeSnapshots.getAppendToSnapshotCsv() || !csvFile.exists()) {
createInitialFeesCsv(feesCsvLoc, payments, feeSnapshots);
} else {
appendToFeesCsv(feesCsvLoc, payments, feeSnapshots);
}
}));
} catch (Exception e) {
log.warn("Unable to ensure fee snapshots bytecode, skipping it!", e);
errorsOccurred.set(true);
return null;
}
}
use of com.hedera.services.bdd.suites.utils.validation.ValidationScenarios.Scenario.FILE 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.ValidationScenarios.Scenario.FILE 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() + "'!");
}
}
Aggregations