Search in sources :

Example 76 with Response

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

the class GetAccountInfoAnswerTest method getsCostAnswerResponse.

@Test
void getsCostAnswerResponse() throws Throwable {
    // setup:
    Query query = validQuery(COST_ANSWER, fee, target);
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasCryptoGetInfo());
    assertEquals(OK, response.getCryptoGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, response.getCryptoGetInfo().getHeader().getResponseType());
    assertEquals(fee, response.getCryptoGetInfo().getHeader().getCost());
}
Also used : CryptoGetInfoResponse(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse) Response(com.hederahashgraph.api.proto.java.Response) CryptoGetInfoQuery(com.hederahashgraph.api.proto.java.CryptoGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 77 with Response

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

the class GetStakersAnswerTest method respectsTypeOfUnsupportedQuery.

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

Example 78 with Response

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

the class GetStakersAnswerTest method extractsValidity.

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

Example 79 with Response

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

the class GetFileContentsAnswerTest method getsValidity.

@Test
void getsValidity() {
    // given:
    Response response = Response.newBuilder().setFileGetContents(FileGetContentsResponse.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) FileGetContentsResponse(com.hederahashgraph.api.proto.java.FileGetContentsResponse) FileGetInfoResponse(com.hederahashgraph.api.proto.java.FileGetInfoResponse) Test(org.junit.jupiter.api.Test)

Example 80 with Response

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

the class GetFileContentsAnswerTest method getsTheContents.

@Test
void getsTheContents() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, target);
    given(view.contentsOf(asFile(target))).willReturn(Optional.of(data));
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasFileGetContents());
    assertEquals(asFile(target), response.getFileGetContents().getFileContents().getFileID());
    assertTrue(response.getFileGetContents().hasHeader(), "Missing response header!");
    assertEquals(OK, response.getFileGetContents().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, response.getFileGetContents().getHeader().getResponseType());
    assertEquals(fee, response.getFileGetContents().getHeader().getCost());
    // and:
    var actual = response.getFileGetContents().getFileContents().getContents().toByteArray();
    assertTrue(Arrays.equals(data, actual));
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) FileGetContentsResponse(com.hederahashgraph.api.proto.java.FileGetContentsResponse) FileGetInfoResponse(com.hederahashgraph.api.proto.java.FileGetInfoResponse) Query(com.hederahashgraph.api.proto.java.Query) FileGetContentsQuery(com.hederahashgraph.api.proto.java.FileGetContentsQuery) 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