Search in sources :

Example 41 with Response

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

the class GetContractInfoAnswerTest method recognizesMissingInfoWhenCtxGiven.

@Test
void recognizesMissingInfoWhenCtxGiven() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, target);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L, Collections.emptyMap());
    // then:
    ContractGetInfoResponse opResponse = response.getContractGetInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(INVALID_CONTRACT_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
    verify(view, never()).infoForContract(any(), any());
}
Also used : ContractGetInfoResponse(com.hederahashgraph.api.proto.java.ContractGetInfoResponse) Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) ContractGetInfoQuery(com.hederahashgraph.api.proto.java.ContractGetInfoQuery) ContractGetInfoResponse(com.hederahashgraph.api.proto.java.ContractGetInfoResponse) Test(org.junit.jupiter.api.Test)

Example 42 with Response

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

the class GetContractInfoAnswerTest method getsValidity.

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

Example 43 with Response

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

the class GetContractInfoAnswerTest 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.hasContractGetInfo());
    assertEquals(OK, response.getContractGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, response.getContractGetInfo().getHeader().getResponseType());
    assertEquals(fee, response.getContractGetInfo().getHeader().getCost());
}
Also used : ContractGetInfoResponse(com.hederahashgraph.api.proto.java.ContractGetInfoResponse) Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) ContractGetInfoQuery(com.hederahashgraph.api.proto.java.ContractGetInfoQuery) Test(org.junit.jupiter.api.Test)

Example 44 with Response

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

the class GetMerkleTopicInfoAnswerTest method requiresOkMetaValidity.

@Test
void requiresOkMetaValidity() {
    // setup:
    TopicID id = asTopic(idLit);
    // given:
    ConsensusGetTopicInfoQuery op = ConsensusGetTopicInfoQuery.newBuilder().setTopicID(id).build();
    Query query = Query.newBuilder().setConsensusGetTopicInfo(op).build();
    // when:
    Response response = subject.responseGiven(query, view, PLATFORM_NOT_ACTIVE);
    ResponseCodeEnum status = response.getConsensusGetTopicInfo().getHeader().getNodeTransactionPrecheckCode();
    // expect:
    assertEquals(PLATFORM_NOT_ACTIVE, status);
    assertEquals(id, response.getConsensusGetTopicInfo().getTopicID());
}
Also used : ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) Response(com.hederahashgraph.api.proto.java.Response) ConsensusGetTopicInfoResponse(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoResponse) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Query(com.hederahashgraph.api.proto.java.Query) ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) TopicID(com.hederahashgraph.api.proto.java.TopicID) Test(org.junit.jupiter.api.Test)

Example 45 with Response

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

the class GetMerkleTopicInfoAnswerTest method failsAsExpectedWhenFetchingMissingTopicInfo.

@Test
void failsAsExpectedWhenFetchingMissingTopicInfo() throws Throwable {
    given(topics.get(key)).willReturn(null);
    Query query = validQuery(ANSWER_ONLY, fee, target);
    Response response = subject.responseGiven(query, view, OK, fee);
    assertTrue(response.hasConsensusGetTopicInfo());
    assertEquals(INVALID_TOPIC_ID, response.getConsensusGetTopicInfo().getHeader().getNodeTransactionPrecheckCode());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ConsensusGetTopicInfoResponse(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoResponse) Query(com.hederahashgraph.api.proto.java.Query) ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) 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