use of com.hedera.services.bdd.spec.keys.KeyFactory.KeyType.THRESHOLD in project hedera-services by hashgraph.
the class ContractCreateSuite method canCallPendingContractSafely.
private HapiApiSpec canCallPendingContractSafely() {
final int numSlots = 64;
final int createBurstSize = 500;
final int[] targets = { 19, 24 };
final AtomicLong createdFileNum = new AtomicLong();
final var callTxn = "callTxn";
final var initcode = "initcode";
return defaultHapiSpec("CanCallPendingContractSafely").given(UtilVerbs.overriding("contracts.throttle.throttleByGas", "false"), fileCreate(initcode).path(FIBONACCI_PLUS_PATH).payingWith(GENESIS).exposingNumTo(createdFileNum::set), inParallel(IntStream.range(0, createBurstSize).mapToObj(i -> contractCreate("contract" + i, FIBONACCI_PLUS_CONSTRUCTOR_ABI, numSlots).fee(ONE_HUNDRED_HBARS).gas(300_000L).payingWith(GENESIS).noLogging().deferStatusResolution().bytecode(initcode).adminKey(THRESHOLD)).toArray(HapiSpecOperation[]::new))).when().then(sourcing(() -> contractCall("0.0." + (createdFileNum.get() + createBurstSize), ADD_NTH_FIB_ABI, targets, 12).payingWith(GENESIS).gas(300_000L).via(callTxn)), UtilVerbs.resetAppPropertiesTo("src/main/resource/bootstrap.properties"));
}
use of com.hedera.services.bdd.spec.keys.KeyFactory.KeyType.THRESHOLD 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