Search in sources :

Example 1 with SupportedContract

use of com.hedera.services.bdd.spec.infrastructure.meta.SupportedContract in project hedera-services by hashgraph.

the class RandomContract method get.

@Override
public Optional<HapiSpecOperation> get() {
    if (contracts.numPresent() >= ceilingNum) {
        return Optional.empty();
    }
    Optional<String> key = keys.getQualifying();
    if (key.isEmpty()) {
        return Optional.empty();
    }
    int n = opNo.getAndIncrement();
    final String tentativeContract = my("contract" + n);
    final SupportedContract choice = choices[n % choices.length];
    HapiContractCreate op = contractCreate(tentativeContract).adminKey(key.get()).bytecode(fileFor(choice)).skipAccountRegistration().hasPrecheckFrom(STANDARD_PERMISSIBLE_PRECHECKS).hasKnownStatusFrom(permissibleOutcomes).uponSuccess(registry -> {
        registry.saveContractChoice(tentativeContract, choice);
        AtomicInteger tag = new AtomicInteger();
        choice.getCallDetails().forEach(detail -> {
            ActionableContractCall call = new ActionableContractCall(tentativeContract, detail);
            registry.saveActionableCall(tentativeContract + "-" + tag.getAndIncrement(), call);
        });
        choice.getLocalCallDetails().forEach(detail -> {
            ActionableContractCallLocal call = new ActionableContractCallLocal(tentativeContract, detail);
            registry.saveActionableLocalCall(tentativeContract + "-" + tag.getAndIncrement(), call);
        });
    });
    return Optional.of(op);
}
Also used : SupportedContract(com.hedera.services.bdd.spec.infrastructure.meta.SupportedContract) ActionableContractCall(com.hedera.services.bdd.spec.infrastructure.meta.ActionableContractCall) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ActionableContractCallLocal(com.hedera.services.bdd.spec.infrastructure.meta.ActionableContractCallLocal) HapiContractCreate(com.hedera.services.bdd.spec.transactions.contract.HapiContractCreate)

Example 2 with SupportedContract

use of com.hedera.services.bdd.spec.infrastructure.meta.SupportedContract in project hedera-services by hashgraph.

the class RandomContract method suggestedInitializers.

@Override
public List<HapiSpecOperation> suggestedInitializers() {
    List<HapiSpecOperation> ops = new ArrayList<>();
    for (SupportedContract choice : choices) {
        HapiFileCreate op = fileCreate(fileFor(choice)).noLogging().path(choice.getPathToBytecode());
        ops.add(op);
    }
    return ops;
}
Also used : SupportedContract(com.hedera.services.bdd.spec.infrastructure.meta.SupportedContract) ArrayList(java.util.ArrayList) HapiSpecOperation(com.hedera.services.bdd.spec.HapiSpecOperation) HapiFileCreate(com.hedera.services.bdd.spec.transactions.file.HapiFileCreate)

Example 3 with SupportedContract

use of com.hedera.services.bdd.spec.infrastructure.meta.SupportedContract in project hedera-services by hashgraph.

the class HapiContractDelete method updateStateOf.

@Override
protected void updateStateOf(HapiApiSpec spec) throws Throwable {
    if (actualStatus != SUCCESS) {
        return;
    }
    if (shouldPurge) {
        if (spec.registry().hasAccountId(contract)) {
            spec.registry().removeAccount(contract);
        }
        spec.registry().removeKey(contract);
        spec.registry().removeContractId(contract);
        spec.registry().removeContractInfo(contract);
        if (spec.registry().hasContractChoice(contract)) {
            SupportedContract choice = spec.registry().getContractChoice(contract);
            AtomicInteger tag = new AtomicInteger();
            choice.getCallDetails().forEach(detail -> {
                spec.registry().removeActionableCall(contract + "-" + tag.getAndIncrement());
            });
            choice.getLocalCallDetails().forEach(detail -> {
                spec.registry().removeActionableLocalCall(contract + "-" + tag.getAndIncrement());
            });
            spec.registry().removeContractChoice(contract);
        }
    }
}
Also used : SupportedContract(com.hedera.services.bdd.spec.infrastructure.meta.SupportedContract) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Aggregations

SupportedContract (com.hedera.services.bdd.spec.infrastructure.meta.SupportedContract)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 HapiSpecOperation (com.hedera.services.bdd.spec.HapiSpecOperation)1 ActionableContractCall (com.hedera.services.bdd.spec.infrastructure.meta.ActionableContractCall)1 ActionableContractCallLocal (com.hedera.services.bdd.spec.infrastructure.meta.ActionableContractCallLocal)1 HapiContractCreate (com.hedera.services.bdd.spec.transactions.contract.HapiContractCreate)1 HapiFileCreate (com.hedera.services.bdd.spec.transactions.file.HapiFileCreate)1 ArrayList (java.util.ArrayList)1