use of com.hedera.services.bdd.suites.utils.validation.domain.SysFilesDownScenario in project hedera-services by hashgraph.
the class ValidationScenarios method sysFilesDown.
private static HapiApiSpec sysFilesDown() {
ensureScenarios();
if (scenarios.getSysFilesDown() == null) {
scenarios.setSysFilesDown(new SysFilesDownScenario());
}
var sys = scenarios.getSysFilesDown();
final long[] targets = sys.getNumsToFetch().stream().mapToLong(Integer::longValue).toArray();
try {
return customHapiSpec("SysFilesDown").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()))).when().then(Arrays.stream(targets).mapToObj(fileNum -> appropriateQuery(sys, fileNum)).toArray(HapiSpecOperation[]::new));
} catch (Exception e) {
log.warn("Unable to initialize system file scenarios, skipping it!", e);
errorsOccurred.set(true);
return null;
}
}
use of com.hedera.services.bdd.suites.utils.validation.domain.SysFilesDownScenario 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