Search in sources :

Example 81 with Response

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

the class GetFileInfoAnswerTest method failsWhenMissingInfo.

@Test
void failsWhenMissingInfo() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, target);
    given(view.infoForFile(asFile(target))).willReturn(Optional.empty());
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasFileGetInfo());
    assertEquals(FAIL_INVALID, response.getFileGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, response.getFileGetInfo().getHeader().getResponseType());
    assertFalse(response.getFileGetInfo().hasFileInfo());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) FileGetInfoResponse(com.hederahashgraph.api.proto.java.FileGetInfoResponse) FileGetInfoQuery(com.hederahashgraph.api.proto.java.FileGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 82 with Response

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

the class GetFileInfoAnswerTest method getsTheInfo.

@Test
void getsTheInfo() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, target);
    given(view.infoForFile(asFile(target))).willReturn(Optional.of(expected));
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasFileGetInfo());
    assertTrue(response.getFileGetInfo().hasHeader(), "Missing response header!");
    assertEquals(OK, response.getFileGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, response.getFileGetInfo().getHeader().getResponseType());
    assertEquals(fee, response.getFileGetInfo().getHeader().getCost());
    // and:
    var actual = response.getFileGetInfo().getFileInfo();
    assertEquals(expected, actual);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) FileGetInfoResponse(com.hederahashgraph.api.proto.java.FileGetInfoResponse) FileGetInfoQuery(com.hederahashgraph.api.proto.java.FileGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 83 with Response

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

the class GetFileInfoAnswerTest method getsValidity.

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

Example 84 with Response

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

the class GetExecTimeAnswerTest method getsInvalidResponse.

@Test
void getsInvalidResponse() throws Throwable {
    // setup:
    Query query = validQuery(COST_ANSWER, fee);
    // when:
    Response response = subject.responseGiven(query, view, FAIL_INVALID, fee);
    // then:
    assertTrue(response.hasNetworkGetExecutionTime());
    assertEquals(FAIL_INVALID, response.getNetworkGetExecutionTime().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, response.getNetworkGetExecutionTime().getHeader().getResponseType());
    assertEquals(fee, response.getNetworkGetExecutionTime().getHeader().getCost());
}
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 85 with Response

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

the class GetExecTimeAnswerTest method getsCostAnswerResponse.

@Test
void getsCostAnswerResponse() throws Throwable {
    // setup:
    Query query = validQuery(COST_ANSWER, fee);
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasNetworkGetExecutionTime());
    NetworkGetExecutionTimeResponse opResponse = response.getNetworkGetExecutionTime();
    assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, opResponse.getHeader().getResponseType());
    assertEquals(fee, opResponse.getHeader().getCost());
    assertEquals(OK, subject.checkValidity(query, view));
}
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) NetworkGetExecutionTimeResponse(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse) 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