Search in sources :

Example 6 with Query

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());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) NetworkGetExecutionTimeResponse(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse) Query(com.hederahashgraph.api.proto.java.Query) NetworkGetExecutionTimeQuery(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery) Test(org.junit.jupiter.api.Test)

Example 7 with Query

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());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) NetworkGetExecutionTimeResponse(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse) Query(com.hederahashgraph.api.proto.java.Query) NetworkGetExecutionTimeQuery(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery) Test(org.junit.jupiter.api.Test)

Example 8 with Query

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());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) NetworkGetExecutionTimeResponse(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse) Query(com.hederahashgraph.api.proto.java.Query) NetworkGetExecutionTimeQuery(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery) Test(org.junit.jupiter.api.Test)

Example 9 with Query

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));
}
Also used : TransactionGetFastRecordResponse(com.hederahashgraph.api.proto.java.TransactionGetFastRecordResponse) Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) TransactionGetFastRecordQuery(com.hederahashgraph.api.proto.java.TransactionGetFastRecordQuery) Test(org.junit.jupiter.api.Test)

Example 10 with Query

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());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Query(com.hederahashgraph.api.proto.java.Query) TransactionGetReceiptQuery(com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Test(org.junit.jupiter.api.Test)

Aggregations

Query (com.hederahashgraph.api.proto.java.Query)152 Test (org.junit.jupiter.api.Test)108 Response (com.hederahashgraph.api.proto.java.Response)95 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)24 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)13 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)13 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)11 ByteString (com.google.protobuf.ByteString)10 ConsensusGetTopicInfoQuery (com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery)10 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)10 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)10 CryptoGetAccountBalanceQuery (com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery)9 CryptoGetInfoQuery (com.hederahashgraph.api.proto.java.CryptoGetInfoQuery)9 FileGetInfoQuery (com.hederahashgraph.api.proto.java.FileGetInfoQuery)8 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)8 HashMap (java.util.HashMap)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetBytecodeQuery (com.hederahashgraph.api.proto.java.ContractGetBytecodeQuery)7 FileGetContentsQuery (com.hederahashgraph.api.proto.java.FileGetContentsQuery)7 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)7