use of com.hederahashgraph.api.proto.java.ContractCallLocalResponse in project hedera-services by hashgraph.
the class ContractCallLocalResourceUsage method usageFor.
private FeeData usageFor(final Query query, final ResponseType type, final StateView view, @Nullable final Map<String, Object> queryCtx) {
try {
final var op = query.getContractCallLocal();
ContractCallLocalResponse response;
if (null == queryCtx) {
response = dummyResponse(op.getContractID());
} else {
final var entityAccess = new StaticEntityAccess(view, aliasManager, validator, properties);
final var codeCache = new CodeCache(nodeProperties, entityAccess);
final var worldState = new HederaWorldState(ids, entityAccess, codeCache, properties);
evmTxProcessor.setWorldState(worldState);
response = CallLocalExecutor.execute(accountStore, evmTxProcessor, op, aliasManager);
queryCtx.put(CONTRACT_CALL_LOCAL_CTX_KEY, response);
}
final var nonGasUsage = usageEstimator.getContractCallLocalFeeMatrices(op.getFunctionParameters().size(), response.getFunctionResult(), type);
return nonGasUsage.toBuilder().setNodedata(nonGasUsage.getNodedata().toBuilder().setGas(op.getGas())).build();
} catch (final Exception internal) {
log.warn("Usage estimation unexpectedly failed for {}!", query, internal);
throw new IllegalStateException(internal);
}
}
use of com.hederahashgraph.api.proto.java.ContractCallLocalResponse in project hedera-services by hashgraph.
the class ContractCallLocalAnswerTest method getsCostAnswerResponse.
@Test
void getsCostAnswerResponse() throws Throwable {
// setup:
Query query = validQuery(COST_ANSWER, fee);
// when:
Response response = subject.responseGiven(query, view, OK, fee);
// then:
assertTrue(response.hasContractCallLocal());
ContractCallLocalResponse opResponse = response.getContractCallLocal();
assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
assertEquals(COST_ANSWER, opResponse.getHeader().getResponseType());
assertEquals(fee, opResponse.getHeader().getCost());
}
Aggregations