Search in sources :

Example 11 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetTxnReceiptAnswerTest method getsValidity.

@Test
void getsValidity() {
    // given:
    Response response = Response.newBuilder().setTransactionGetReceipt(TransactionGetReceiptResponse.newBuilder().setHeader(subject.answerOnlyHeader(RESULT_SIZE_LIMIT_EXCEEDED))).build();
    // expect:
    assertEquals(RESULT_SIZE_LIMIT_EXCEEDED, subject.extractValidityFrom(response));
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetReceiptResponse(com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse) Test(org.junit.jupiter.api.Test)

Example 12 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetTxnReceiptAnswerTest method returnsChildrenIfRequested.

@Test
void returnsChildrenIfRequested() {
    // setup:
    Query sensibleQuery = queryWith(validTxnId, ANSWER_ONLY, false, true);
    var childReceipts = List.of(duplicateReceipt.toGrpc(), unclassifiableReceipt.toGrpc());
    given(recordCache.getPriorityReceipt(validTxnId)).willReturn(receipt);
    given(recordCache.getChildReceipts(validTxnId)).willReturn(childReceipts);
    // 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());
    assertEquals(childReceipts, opResponse.getChildTransactionReceiptsList());
}
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)

Example 13 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetTxnReceiptAnswerTest method rejectsQueryForMissingReceipt.

@Test
void rejectsQueryForMissingReceipt() {
    // setup:
    Query sensibleQuery = queryWith(validTxnId);
    given(recordCache.getPriorityReceipt(validTxnId)).willReturn(null);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
    assertEquals(RECEIPT_NOT_FOUND, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
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)

Example 14 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetAccountBalanceAnswerTest method requiresOkMetaValidity.

@Test
void requiresOkMetaValidity() {
    // setup:
    AccountID id = asAccount(accountIdLit);
    // given:
    CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setAccountID(id).build();
    Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
    // when:
    Response response = subject.responseGiven(query, view, PLATFORM_NOT_ACTIVE);
    ResponseCodeEnum status = response.getCryptogetAccountBalance().getHeader().getNodeTransactionPrecheckCode();
    // expect:
    assertEquals(PLATFORM_NOT_ACTIVE, status);
    assertEquals(id, response.getCryptogetAccountBalance().getAccountID());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) CryptoGetAccountBalanceResponse(com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceResponse) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) AccountID(com.hederahashgraph.api.proto.java.AccountID) CryptoGetAccountBalanceQuery(com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery) Query(com.hederahashgraph.api.proto.java.Query) CryptoGetAccountBalanceQuery(com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery) Test(org.junit.jupiter.api.Test)

Example 15 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetAccountBalanceAnswerTest method getsValidity.

@Test
void getsValidity() {
    // given:
    Response response = Response.newBuilder().setCryptogetAccountBalance(CryptoGetAccountBalanceResponse.newBuilder().setHeader(subject.answerOnlyHeader(RESULT_SIZE_LIMIT_EXCEEDED))).build();
    // expect:
    assertEquals(RESULT_SIZE_LIMIT_EXCEEDED, subject.extractValidityFrom(response));
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) CryptoGetAccountBalanceResponse(com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceResponse) Test(org.junit.jupiter.api.Test)

Aggregations

Response (com.hederahashgraph.api.proto.java.Response)114 Query (com.hederahashgraph.api.proto.java.Query)96 Test (org.junit.jupiter.api.Test)87 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)9 ByteString (com.google.protobuf.ByteString)8 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)8 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)8 TokenGetNftInfoResponse (com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse)8 TransactionGetReceiptResponse (com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)7 ContractGetInfoResponse (com.hederahashgraph.api.proto.java.ContractGetInfoResponse)7 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)7 NetworkGetExecutionTimeResponse (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse)7 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)7 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)7 ScheduleGetInfoResponse (com.hederahashgraph.api.proto.java.ScheduleGetInfoResponse)7 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)7 TokenGetInfoResponse (com.hederahashgraph.api.proto.java.TokenGetInfoResponse)7 HashMap (java.util.HashMap)7