Search in sources :

Example 46 with Response

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

the class GetMerkleTopicInfoAnswerTest method getsValidity.

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

Example 47 with Response

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

the class GetMerkleTopicInfoAnswerTest method getsTopicInfoWithEmptyRunningHash.

@Test
void getsTopicInfoWithEmptyRunningHash() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, target);
    merkleTopic.setRunningHash(null);
    given(topics.get(asTopic(target))).willReturn(merkleTopic);
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasConsensusGetTopicInfo());
    // and:
    ConsensusTopicInfo info = response.getConsensusGetTopicInfo().getTopicInfo();
    assertArrayEquals(new byte[48], info.getRunningHash().toByteArray());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ConsensusGetTopicInfoResponse(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoResponse) ConsensusTopicInfo(com.hederahashgraph.api.proto.java.ConsensusTopicInfo) Query(com.hederahashgraph.api.proto.java.Query) ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) Test(org.junit.jupiter.api.Test)

Example 48 with Response

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

the class ContractCallLocalAnswerTest 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.hasContractCallLocal());
    assertEquals(FAIL_INVALID, response.getContractCallLocal().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, response.getContractCallLocal().getHeader().getResponseType());
    assertEquals(fee, response.getContractCallLocal().getHeader().getCost());
}
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 49 with Response

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

the class ContractCallLocalAnswerTest method getsCallResponseWhenNoCtx.

@Test
void getsCallResponseWhenNoCtx() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L);
    final var transactionProcessingResult = TransactionProcessingResult.failed(0, 0, 1, Optional.empty(), Optional.empty(), new TreeMap<>());
    given(accountStore.loadAccount(any())).willReturn(new Account(Id.fromGrpcContract(target)));
    given(accountStore.loadContract(any())).willReturn(new Account(Id.fromGrpcContract(target)));
    given(evmTxProcessor.execute(any(), any(), anyLong(), anyLong(), any(), any())).willReturn(transactionProcessingResult);
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
    // then:
    var opResponse = response.getContractCallLocal();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(CONTRACT_EXECUTION_EXCEPTION, opResponse.getHeader().getNodeTransactionPrecheckCode());
    assertEquals(target, opResponse.getFunctionResult().getContractID());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ContractCallLocalResponse(com.hederahashgraph.api.proto.java.ContractCallLocalResponse) MerkleAccount(com.hedera.services.state.merkle.MerkleAccount) Account(com.hedera.services.store.models.Account) Query(com.hederahashgraph.api.proto.java.Query) ContractCallLocalQuery(com.hederahashgraph.api.proto.java.ContractCallLocalQuery) Test(org.junit.jupiter.api.Test)

Example 50 with Response

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

the class VerifyGetAccountNftInfosNotSupported method submitOp.

@Override
protected boolean submitOp(HapiApiSpec spec) throws Throwable {
    TokenGetAccountNftInfosQuery.Builder op = TokenGetAccountNftInfosQuery.newBuilder().setAccountID(asAccount("0.0.2"));
    Query query = Query.newBuilder().setTokenGetAccountNftInfos(op).build();
    Response response = spec.clients().getTokenSvcStub(targetNodeFor(spec), useTls).getAccountNftInfos(query);
    Assertions.assertEquals(NOT_SUPPORTED, response.getTokenGetAccountNftInfos().getHeader().getNodeTransactionPrecheckCode());
    return false;
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetAccountNftInfosQuery(com.hederahashgraph.api.proto.java.TokenGetAccountNftInfosQuery) Query(com.hederahashgraph.api.proto.java.Query) TokenGetAccountNftInfosQuery(com.hederahashgraph.api.proto.java.TokenGetAccountNftInfosQuery)

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