use of com.hedera.services.bdd.suites.utils.validation.domain.PersistentContract 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;
}
}
Aggregations