use of com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BALANCE_LOOKUP_ABI in project hedera-services by hashgraph.
the class MixedSmartContractOpsLoadTest method RunMixedSmartContractOps.
protected HapiApiSpec RunMixedSmartContractOps() {
PerfTestLoadSettings settings = new PerfTestLoadSettings();
final AtomicInteger createdSoFar = new AtomicInteger(0);
final String SOME_BYTE_CODE = "contractByteCode";
final String UPDATABLE_CONTRACT = "updatableContract";
final String CONTRACT_NAME_PREFIX = "testContract";
final String PAYABLE_FILE = "payableByteCode";
final String PAYABLE_CONTRACT = "payableContract";
final String LOOKUP_FILE = "lookUpByteCode";
final String LOOKUP_CONTRACT = "lookUpContract";
final String CIVILIAN_ACCOUNT = "civilian";
final int depositAmount = 1;
Supplier<HapiSpecOperation[]> mixedOpsBurst = () -> new HapiSpecOperation[] { /* create a contract */
contractCreate(CONTRACT_NAME_PREFIX + createdSoFar.getAndIncrement()).bytecode(SOME_BYTE_CODE).hasAnyPrecheck().deferStatusResolution(), /* update the memo and do get info on the contract that needs to be updated */
contractUpdate(UPDATABLE_CONTRACT).newMemo(new String(randomUtf8Bytes(memoLength.getAsInt()))).hasAnyPrecheck().deferStatusResolution(), /* call balance lookup contract and contract to deposit funds*/
contractCallLocal(LOOKUP_CONTRACT, BALANCE_LOOKUP_ABI, spec -> new Object[] { spec.registry().getAccountID(CIVILIAN_ACCOUNT).getAccountNum() }).payingWith(GENESIS), contractCall(PAYABLE_CONTRACT, ContractResources.DEPOSIT_ABI, depositAmount).sending(depositAmount).suppressStats(true).deferStatusResolution() };
return defaultHapiSpec("RunMixedSmartContractOps").given(withOpContext((spec, ignore) -> settings.setFrom(spec.setup().ciPropertiesMap())), logIt(ignore -> settings.toString())).when(/* create an account */
cryptoCreate(CIVILIAN_ACCOUNT).balance(ONE_HUNDRED_HBARS), /* create a file with some contents and contract with it */
fileCreate(SOME_BYTE_CODE).path(ContractResources.VALID_BYTECODE_PATH), contractCreate(UPDATABLE_CONTRACT).bytecode(SOME_BYTE_CODE).adminKey(THRESHOLD), /* create a contract which does a query to look up balance of the civilan account */
fileCreate(LOOKUP_FILE).path(ContractResources.BALANCE_LOOKUP_BYTECODE_PATH), contractCreate(LOOKUP_CONTRACT).bytecode(LOOKUP_FILE).adminKey(THRESHOLD), /* create a contract that does a transaction to deposit funds */
fileCreate(PAYABLE_FILE).path(ContractResources.PAYABLE_CONTRACT_BYTECODE_PATH), contractCreate(PAYABLE_CONTRACT).bytecode(PAYABLE_FILE).adminKey(THRESHOLD), /* get contract info on all contracts created */
getContractInfo(LOOKUP_CONTRACT).hasExpectedInfo().logged(), getContractInfo(PAYABLE_CONTRACT).hasExpectedInfo().logged(), getContractInfo(UPDATABLE_CONTRACT).hasExpectedInfo().logged()).then(defaultLoadTest(mixedOpsBurst, settings));
}
Aggregations