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());
}
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());
}
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);
}
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());
}
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);
}
Aggregations