use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetExecTimeAnswerTest method getsExecutionTimeWhenAvailable.
@Test
void getsExecutionTimeWhenAvailable() throws Throwable {
// setup:
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, aTxnId, bTxnId, cTxnId);
// given:
assertEquals(OK, subject.checkValidity(sensibleQuery, view));
// when:
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
// then:
var opResponse = response.getNetworkGetExecutionTime();
assertTrue(opResponse.hasHeader(), "Missing response header!");
assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
assertEquals(List.of(nanos, nanos, nanos), opResponse.getExecutionTimesList());
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetExecTimeAnswerTest method complainsWhenAnyExecutionTimeUnavailable.
@Test
void complainsWhenAnyExecutionTimeUnavailable() throws Throwable {
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, aTxnId, bTxnId);
given(executionTimeTracker.getExecNanosIfPresentFor(bTxnId)).willReturn(null);
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
final var opResponse = response.getNetworkGetExecutionTime();
assertEquals(INVALID_TRANSACTION_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetExecTimeAnswerTest method respectsMetaValidity.
@Test
void respectsMetaValidity() throws Throwable {
// given:
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L);
// when:
Response response = subject.responseGiven(sensibleQuery, view, INVALID_TRANSACTION, 0L);
// then:
var opResponse = response.getNetworkGetExecutionTime();
assertEquals(INVALID_TRANSACTION, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetFastTxnRecordAnswerTest method respectsTypeOfUnsupportedQuery.
@Test
void respectsTypeOfUnsupportedQuery() {
// given:
Query costAnswer = getFastTxnRecordQuery(COST_ANSWER);
Query answerOnly = getFastTxnRecordQuery(ANSWER_ONLY);
// when:
Response costAnswerResponse = subject.responseGiven(costAnswer, StateView.EMPTY_VIEW, OK, 0L);
Response answerOnlyResponse = subject.responseGiven(answerOnly, StateView.EMPTY_VIEW, OK, 0L);
// then:
assertEquals(COST_ANSWER, costAnswerResponse.getTransactionGetFastRecord().getHeader().getResponseType());
assertEquals(ANSWER_ONLY, answerOnlyResponse.getTransactionGetFastRecord().getHeader().getResponseType());
// and:
assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(costAnswerResponse));
assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(answerOnlyResponse));
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetTxnReceiptAnswerTest method shortCircuitsToAnswerOnly.
@Test
void shortCircuitsToAnswerOnly() {
// setup:
Query sensibleQuery = queryWith(validTxnId, ResponseType.COST_ANSWER);
given(recordCache.getPriorityReceipt(validTxnId)).willReturn(receipt);
// when:
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
// then:
TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
assertTrue(opResponse.hasHeader(), "Missing response header!");
assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
assertEquals(ANSWER_ONLY, opResponse.getHeader().getResponseType());
assertEquals(receipt.toGrpc(), opResponse.getReceipt());
assertTrue(opResponse.getDuplicateTransactionReceiptsList().isEmpty());
verify(recordCache, never()).getDuplicateReceipts(any());
}
Aggregations