use of com.hedera.services.bdd.suites.utils.validation.domain.FeeSnapshotsScenario 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.domain.FeeSnapshotsScenario in project hedera-services by hashgraph.
the class ValidationScenarios method ensureBytecode.
private static HapiApiSpec ensureBytecode() {
ensureScenarios();
if (scenarios.getFeeSnapshots() == null) {
scenarios.setFeeSnapshots(new FeeSnapshotsScenario());
}
var feeSnapshots = scenarios.getFeeSnapshots();
try {
return customHapiSpec("EnsureBytecodeForFeeSnapshots").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) -> {
if (feeSnapshots.getOpsConfig().getBytecode() == null) {
var bytecodeCreate = fileCreate("unusedName").path(ContractResources.MULTIPURPOSE_BYTECODE_PATH);
allRunFor(spec, bytecodeCreate);
feeSnapshots.getOpsConfig().setBytecode(bytecodeCreate.numOfCreatedFile());
}
}));
} 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.domain.FeeSnapshotsScenario in project hedera-services by hashgraph.
the class ValidationScenarios method feeSnapshots.
private static HapiApiSpec feeSnapshots() {
ensureScenarios();
if (scenarios.getFeeSnapshots() == null) {
scenarios.setFeeSnapshots(new FeeSnapshotsScenario());
}
var feeSnapshots = scenarios.getFeeSnapshots();
var tinyBarsToOffer = feeSnapshots.getTinyBarsToOffer();
/* Crypto signing */
var complex = KeyShape.threshOf(1, KeyShape.listOf(2), KeyShape.threshOf(1, 3));
/* File signing */
var complexWacl = KeyShape.listOf(KeyShape.threshOf(2, 3), KeyShape.threshOf(1, 3));
var secondComplexWacl = KeyShape.listOf(3);
var normalDeleteSigs = secondComplexWacl.signedWith(KeyShape.sigs(ON, ON, ON));
var revocationDeleteSigs = secondComplexWacl.signedWith(KeyShape.sigs(ON, OFF, OFF));
/* Topic signing */
var complexAdmin = KeyShape.threshOf(1, KeyShape.listOf(2), KeyShape.threshOf(1, 3));
/* Contract signing */
var complexContract = KeyShape.listOf(KeyShape.threshOf(2, 3), KeyShape.threshOf(1, 3));
try {
return customHapiSpec("FeeSnapshots").withProperties(Map.of("nodes", nodes(), "default.fee", "" + tinyBarsToOffer, "default.payer", primaryPayer(), "default.node", defaultNode(), "cost.snapshot.dir", "fees", "cost.snapshot.mode", "TAKE", "startupAccounts.literal", payerKeystoreLiteral())).given(keyFromPem(() -> pemForAccount(targetNetwork().getScenarioPayer())).name(SCENARIO_PAYER_NAME).linkedTo(() -> String.format("0.0.%d", targetNetwork().getScenarioPayer())), /* Crypto keys */
newKeyNamed("firstKey").shape(complex), newKeyNamed("secondKey"), /* File keys */
newKeyNamed("fileFirstKey").shape(complexWacl), newKeyNamed("fileSecondKey").shape(secondComplexWacl), /* Topic keys */
newKeyNamed("topicKey").shape(complexAdmin), /* Contract keys */
newKeyNamed("contractFirstKey").shape(complexContract), newKeyNamed("contractSecondKey"), /* Token keys */
newKeyNamed("tokenFirstKey").shape(complex), newKeyNamed("tokenSecondKey"), newKeyNamed("supplyKey"), newKeyNamed("wipeKey"), newKeyNamed("freezeKey"), newKeyNamed("kycKey")).when(/* Crypto ops */
cryptoCreate("tbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).receiveThreshold(1_000L).balance(1_234L).key("firstKey"), getAccountBalance("tbd").logged(), cryptoUpdate("tbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).key("secondKey"), cryptoTransfer(tinyBarsFromTo(SCENARIO_PAYER_NAME, "tbd", 1_234L)).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), getAccountRecords("tbd").logged(), getAccountInfo("tbd").logged(), cryptoDelete("tbd").fee(tinyBarsToOffer).via("deleteTxn").payingWith(SCENARIO_PAYER_NAME).transfer(SCENARIO_PAYER_NAME), getTxnRecord("deleteTxn").logged(), /* Token ops */
tokenCreate("tokenTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).treasury(DEFAULT_PAYER).autoRenewAccount(SCENARIO_PAYER_NAME).adminKey("tokenFirstKey").supplyKey("supplyKey").wipeKey("wipeKey").freezeKey("freezeKey").kycKey("kycKey"), tokenUpdate("tokenTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).adminKey("tokenSecondKey"), tokenAssociate(SCENARIO_PAYER_NAME, "tokenTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), tokenUnfreeze("tokenTbd", SCENARIO_PAYER_NAME).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), grantTokenKyc("tokenTbd", SCENARIO_PAYER_NAME).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), cryptoTransfer(moving(10, "tokenTbd").between(DEFAULT_PAYER, SCENARIO_PAYER_NAME)).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), wipeTokenAccount("tokenTbd", SCENARIO_PAYER_NAME, 10).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), mintToken("tokenTbd", 10).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), burnToken("tokenTbd", 10).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), tokenFreeze("tokenTbd", SCENARIO_PAYER_NAME).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), revokeTokenKyc("tokenTbd", SCENARIO_PAYER_NAME).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), tokenUnfreeze("tokenTbd", SCENARIO_PAYER_NAME).fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), tokenDissociate(SCENARIO_PAYER_NAME, "tokenTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), tokenDelete("tokenTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), /* File ops */
fileCreate("fileTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).key("fileFirstKey").contents("abcdefghijklm"), fileAppend("fileTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).content("nopqrstuvwxyz"), getFileContents("fileTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).hasContents(ignore -> "abcdefghijklmnopqrstuvwxyz".getBytes()), fileUpdate("fileTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).wacl("fileSecondKey"), getFileInfo("fileTbd").payingWith(SCENARIO_PAYER_NAME), fileDelete("fileTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).sigControl(ControlForKey.forKey("fileTbd", params.isRevocationService() ? revocationDeleteSigs : normalDeleteSigs)), /* Consensus ops */
createTopic("topicTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).adminKeyName("topicKey").submitKeyShape(KeyShape.SIMPLE), submitMessageTo("topicTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), updateTopic("topicTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).signedBy(SCENARIO_PAYER_NAME, "topicKey").submitKey(EMPTY_KEY), submitMessageTo("topicTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).signedBy(SCENARIO_PAYER_NAME), getTopicInfo("topicTbd").payingWith(SCENARIO_PAYER_NAME), deleteTopic("topicTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME), /* Contract ops */
contractCreate("contractTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).bytecode(() -> String.format("0.0.%d", feeSnapshots.getOpsConfig().getBytecode())).adminKey("contractFirstKey").balance(1), contractCall("contractTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).sending(1L), contractCallLocal("contractTbd", ContractResources.LUCKY_NO_LOOKUP_ABI), contractUpdate("contractTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).newKey("contractSecondKey"), getContractInfo("contractTbd").payingWith(SCENARIO_PAYER_NAME), getContractBytecode("contractTbd").payingWith(SCENARIO_PAYER_NAME), contractDelete("contractTbd").fee(tinyBarsToOffer).payingWith(SCENARIO_PAYER_NAME).transferAccount(SCENARIO_PAYER_NAME)).then();
} catch (Exception e) {
log.warn("Unable to initialize system file scenarios, skipping it!", e);
errorsOccurred.set(true);
return null;
}
}
Aggregations