Search in sources :

Example 96 with Response

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

the class GetTokenNftInfoAnswerTest method validatesInvalidNftIdInContext.

@Test
void validatesInvalidNftIdInContext() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, nftId);
    Map<String, Object> ctx = new HashMap<>();
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L, ctx);
    // then:
    var opResponse = response.getTokenGetNftInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(INVALID_NFT_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
    // and:
    verify(view, never()).infoForNft(any());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetNftInfoResponse(com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse) TokenGetNftInfoQuery(com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test)

Example 97 with Response

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

the class GetTokenNftInfosAnswerTest method respectsTypeOfUnsupportedQuery.

@Test
void respectsTypeOfUnsupportedQuery() {
    // given:
    Query costAnswer = getQuery(COST_ANSWER);
    Query answerOnly = getQuery(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.getTokenGetNftInfos().getHeader().getResponseType());
    assertEquals(ANSWER_ONLY, answerOnlyResponse.getTokenGetNftInfos().getHeader().getResponseType());
    // and:
    assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(costAnswerResponse));
    assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(answerOnlyResponse));
}
Also used : TokenGetNftInfosResponse(com.hederahashgraph.api.proto.java.TokenGetNftInfosResponse) Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) TokenGetNftInfosQuery(com.hederahashgraph.api.proto.java.TokenGetNftInfosQuery) Test(org.junit.jupiter.api.Test)

Example 98 with Response

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

the class GetTokenNftInfosAnswerTest method extractsValidity.

@Test
void extractsValidity() {
    // given:
    Response response = Response.newBuilder().setTokenGetNftInfos(TokenGetNftInfosResponse.newBuilder().setHeader(ResponseHeader.newBuilder().setNodeTransactionPrecheckCode(FAIL_FEE))).build();
    // expect:
    assertEquals(FAIL_FEE, subject.extractValidityFrom(response));
}
Also used : TokenGetNftInfosResponse(com.hederahashgraph.api.proto.java.TokenGetNftInfosResponse) Response(com.hederahashgraph.api.proto.java.Response) Test(org.junit.jupiter.api.Test)

Example 99 with Response

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

the class GetFastTxnRecordAnswerTest method extractsValidity.

@Test
void extractsValidity() {
    // given:
    Response response = Response.newBuilder().setTransactionGetFastRecord(TransactionGetFastRecordResponse.newBuilder().setHeader(ResponseHeader.newBuilder().setNodeTransactionPrecheckCode(FAIL_FEE))).build();
    // expect:
    assertEquals(FAIL_FEE, subject.extractValidityFrom(response));
}
Also used : TransactionGetFastRecordResponse(com.hederahashgraph.api.proto.java.TransactionGetFastRecordResponse) Response(com.hederahashgraph.api.proto.java.Response) Test(org.junit.jupiter.api.Test)

Example 100 with Response

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

the class GetTxnReceiptAnswerTest method returnsDuplicatesIfRequested.

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

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