Search in sources :

Example 56 with Query

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

the class GetContractInfoAnswerTest method getsExpectedPayment.

@Test
void getsExpectedPayment() throws Throwable {
    // given:
    Query query = validQuery(COST_ANSWER, fee, target);
    // expect:
    assertEquals(paymentTxn, subject.extractPaymentFrom(query).get().getSignedTxnWrapper());
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) ContractGetInfoQuery(com.hederahashgraph.api.proto.java.ContractGetInfoQuery) Test(org.junit.jupiter.api.Test)

Example 57 with Query

use of com.hederahashgraph.api.proto.java.Query 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 58 with Query

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

the class GetContractInfoAnswerTest method returnsInvalidContractIdFromValidator.

@Test
void returnsInvalidContractIdFromValidator() throws Throwable {
    // setup:
    Query query = validQuery(COST_ANSWER, fee, target);
    given(optionValidator.queryableContractStatus(asContract(target), contracts)).willReturn(INVALID_CONTRACT_ID);
    given(view.contracts()).willReturn(contracts);
    // when:
    ResponseCodeEnum validity = subject.checkValidity(query, view);
    // then:
    assertEquals(INVALID_CONTRACT_ID, validity);
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Query(com.hederahashgraph.api.proto.java.Query) ContractGetInfoQuery(com.hederahashgraph.api.proto.java.ContractGetInfoQuery) Test(org.junit.jupiter.api.Test)

Example 59 with Query

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

the class GetContractRecordsAnswerTest method assertHeadersWhenResponseTypeIsMissing.

@Test
void assertHeadersWhenResponseTypeIsMissing() {
    Query query = Query.newBuilder().setContractGetRecords(queryBuilder.build()).build();
    var result = subject.responseGiven(query, null, null, 0);
    assertEquals(NOT_SUPPORTED, result.getContractGetRecordsResponse().getHeader().getNodeTransactionPrecheckCode());
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) ContractGetRecordsQuery(com.hederahashgraph.api.proto.java.ContractGetRecordsQuery) Test(org.junit.jupiter.api.Test)

Example 60 with Query

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

the class GetMerkleTopicInfoAnswerTest method syntaxCheckValidatesTidIfPresent.

@Test
void syntaxCheckValidatesTidIfPresent() {
    // setup:
    TopicID tid = asTopic(idLit);
    // given:
    ConsensusGetTopicInfoQuery op = ConsensusGetTopicInfoQuery.newBuilder().setTopicID(tid).build();
    Query query = Query.newBuilder().setConsensusGetTopicInfo(op).build();
    // and:
    given(optionValidator.queryableTopicStatus(tid, topics)).willReturn(TOPIC_EXPIRED);
    // when:
    ResponseCodeEnum status = subject.checkValidity(query, view);
    // expect:
    assertEquals(TOPIC_EXPIRED, status);
}
Also used : ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) 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)

Aggregations

Query (com.hederahashgraph.api.proto.java.Query)152 Test (org.junit.jupiter.api.Test)108 Response (com.hederahashgraph.api.proto.java.Response)95 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)24 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)13 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)13 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)11 ByteString (com.google.protobuf.ByteString)10 ConsensusGetTopicInfoQuery (com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery)10 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)10 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)10 CryptoGetAccountBalanceQuery (com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery)9 CryptoGetInfoQuery (com.hederahashgraph.api.proto.java.CryptoGetInfoQuery)9 FileGetInfoQuery (com.hederahashgraph.api.proto.java.FileGetInfoQuery)8 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)8 HashMap (java.util.HashMap)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetBytecodeQuery (com.hederahashgraph.api.proto.java.ContractGetBytecodeQuery)7 FileGetContentsQuery (com.hederahashgraph.api.proto.java.FileGetContentsQuery)7 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)7