Search in sources :

Example 1 with UtilOp

use of com.hedera.services.bdd.spec.utilops.UtilOp in project hedera-services by hashgraph.

the class HapiSpecOperation method execFor.

public Optional<Throwable> execFor(HapiApiSpec spec) {
    pauseIfRequested();
    configureProtoStructureFor(spec);
    try {
        boolean hasCompleteLifecycle = submitOp(spec);
        if (!(this instanceof UtilOp)) {
            spec.incrementNumLedgerOps();
        }
        if (shouldRegisterTxn) {
            registerTxnSubmitted(spec);
        }
        if (hasCompleteLifecycle) {
            assertExpectationsGiven(spec);
            updateStateOf(spec);
        }
    } catch (Throwable t) {
        if (unavailableNode && t.getMessage().startsWith("UNAVAILABLE")) {
            log.info("Node {} is unavailable as expected!", HapiPropertySource.asAccountString(node.get()));
            return Optional.empty();
        }
        if (verboseLoggingOn) {
            log.warn(spec.logPrefix() + this + " failed - {}", t);
        } else if (!loggingOff) {
            log.warn(spec.logPrefix() + this + " failed {}!", t.getMessage());
        }
        return Optional.of(t);
    }
    if (unavailableNode) {
        String message = String.format("Node %s is NOT unavailable as expected!!!", HapiPropertySource.asAccountString(node.get()));
        log.error(message);
        return Optional.of(new RuntimeException(message));
    }
    return Optional.empty();
}
Also used : ByteString(com.google.protobuf.ByteString) UtilOp(com.hedera.services.bdd.spec.utilops.UtilOp)

Aggregations

ByteString (com.google.protobuf.ByteString)1 UtilOp (com.hedera.services.bdd.spec.utilops.UtilOp)1