Search in sources :

Example 1 with BALANCE_LOOKUP_ABI

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));
}
Also used : LoadTest(com.hedera.services.bdd.spec.utilops.LoadTest) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) BALANCE_LOOKUP_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BALANCE_LOOKUP_ABI) TxnVerbs.contractUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractUpdate) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) Supplier(java.util.function.Supplier) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) TxnUtils.randomUtf8Bytes(com.hedera.services.bdd.spec.transactions.TxnUtils.randomUtf8Bytes) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) List(java.util.List) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) Logger(org.apache.logging.log4j.Logger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) THRESHOLD(com.hedera.services.bdd.spec.keys.KeyFactory.KeyType.THRESHOLD) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) QueryVerbs.contractCallLocal(com.hedera.services.bdd.spec.queries.QueryVerbs.contractCallLocal) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) PerfTestLoadSettings(com.hedera.services.bdd.suites.perf.PerfTestLoadSettings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation)

Aggregations

HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)1 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)1 ContractResources (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources)1 BALANCE_LOOKUP_ABI (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BALANCE_LOOKUP_ABI)1 THRESHOLD (com.hedera.services.bdd.spec.keys.KeyFactory.KeyType.THRESHOLD)1 QueryVerbs.contractCallLocal (com.hedera.services.bdd.spec.queries.QueryVerbs.contractCallLocal)1 QueryVerbs.getContractInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo)1 TxnUtils.randomUtf8Bytes (com.hedera.services.bdd.spec.transactions.TxnUtils.randomUtf8Bytes)1 TxnVerbs.contractCall (com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall)1 TxnVerbs.contractCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate)1 TxnVerbs.contractUpdate (com.hedera.services.bdd.spec.transactions.TxnVerbs.contractUpdate)1 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)1 TxnVerbs.fileCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate)1 LoadTest (com.hedera.services.bdd.spec.utilops.LoadTest)1 UtilVerbs.logIt (com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt)1 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)1 PerfTestLoadSettings (com.hedera.services.bdd.suites.perf.PerfTestLoadSettings)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1