use of com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.CREATE2_FACTORY_DEPLOY_ABI in project hedera-services by hashgraph.
the class DynamicGasCostSuite method inlineCreate2CanFailSafely.
// https://github.com/hashgraph/hedera-services/issues/2868
private HapiApiSpec inlineCreate2CanFailSafely() {
final var tcValue = 1_234L;
final var creation = "creation";
final var initcode = "initcode";
final var inlineCreate2Factory = "inlineCreate2Factory";
final int foo = 22;
final int salt = 23;
final int timesToFail = 7;
final AtomicLong factoryEntityNum = new AtomicLong();
final AtomicReference<String> factoryEvmAddress = new AtomicReference<>();
final AtomicReference<byte[]> testContractInitcode = new AtomicReference<>();
return defaultHapiSpec("InlineCreate2CanFailSafely").given(overriding("contracts.throttle.throttleByGas", "false"), fileCreate(initcode).path(REVERTING_CREATE2_FACTORY_PATH), contractCreate(inlineCreate2Factory).payingWith(GENESIS).bytecode(initcode).via(creation).exposingNumTo(num -> {
factoryEntityNum.set(num);
factoryEvmAddress.set(asHexedSolidityAddress(0, 0, num));
})).when(sourcing(() -> contractCallLocal(inlineCreate2Factory, CREATE2_FACTORY_GET_BYTECODE_ABI, factoryEvmAddress.get(), foo).exposingTypedResultsTo(results -> {
final var tcInitcode = (byte[]) results[0];
testContractInitcode.set(tcInitcode);
log.info("Contract reported TestContract initcode is {} bytes", tcInitcode.length);
}).payingWith(GENESIS).nodePayment(ONE_HBAR))).then(inParallel(IntStream.range(0, timesToFail).mapToObj(i -> sourcing(() -> contractCall(inlineCreate2Factory, CREATE2_FACTORY_DEPLOY_ABI, testContractInitcode.get(), salt).payingWith(GENESIS).gas(4_000_000L).sending(tcValue).via(creation))).toArray(HapiSpecOperation[]::new)), sourcing(() -> cryptoCreate("nextUp").exposingCreatedIdTo(id -> log.info("Next entity num was {} instead of expected {}", id.getAccountNum(), factoryEntityNum.get() + 1))));
}
Aggregations