Search in sources :

Example 36 with Response

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

the class ContractCallLocalAnswerTest method respectsMetaValidity.

@Test
void respectsMetaValidity() throws Throwable {
    // given:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, INVALID_TRANSACTION, 0L);
    // then:
    var opResponse = response.getContractCallLocal();
    assertEquals(INVALID_TRANSACTION, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ContractCallLocalResponse(com.hederahashgraph.api.proto.java.ContractCallLocalResponse) Query(com.hederahashgraph.api.proto.java.Query) ContractCallLocalQuery(com.hederahashgraph.api.proto.java.ContractCallLocalQuery) Test(org.junit.jupiter.api.Test)

Example 37 with Response

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

the class GetBytecodeAnswerTest method getsInvalidResponse.

@Test
void getsInvalidResponse() throws Throwable {
    // setup:
    Query query = validQuery(COST_ANSWER, fee, target);
    // when:
    Response response = subject.responseGiven(query, view, CONTRACT_DELETED, fee);
    // then:
    assertTrue(response.hasContractGetBytecodeResponse());
    assertEquals(CONTRACT_DELETED, response.getContractGetBytecodeResponse().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, response.getContractGetBytecodeResponse().getHeader().getResponseType());
    assertEquals(fee, response.getContractGetBytecodeResponse().getHeader().getCost());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ContractGetBytecodeResponse(com.hederahashgraph.api.proto.java.ContractGetBytecodeResponse) Query(com.hederahashgraph.api.proto.java.Query) ContractGetBytecodeQuery(com.hederahashgraph.api.proto.java.ContractGetBytecodeQuery) Test(org.junit.jupiter.api.Test)

Example 38 with Response

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

the class GetBytecodeAnswerTest method getsValidity.

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

Example 39 with Response

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

the class GetContractInfoAnswerTest method getsInfoFromCtxWhenAvailable.

@Test
void getsInfoFromCtxWhenAvailable() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, target);
    Map<String, Object> ctx = new HashMap<>();
    // given:
    ctx.put(GetContractInfoAnswer.CONTRACT_INFO_CTX_KEY, info);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L, ctx);
    // then:
    var opResponse = response.getContractGetInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
    assertSame(info, opResponse.getContractInfo());
    // and:
    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) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test)

Example 40 with Response

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

the class GetContractInfoAnswerTest method recognizesMissingInfoWhenNoCtxGiven.

@Test
void recognizesMissingInfoWhenNoCtxGiven() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, target);
    given(view.infoForContract(asContract(target), aliasManager)).willReturn(Optional.empty());
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    ContractGetInfoResponse opResponse = response.getContractGetInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(INVALID_CONTRACT_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
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)

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