use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetMerkleTopicInfoAnswerTest 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 GetMerkleTopicInfoAnswerTest method syntaxCheckRequiresId.
@Test
void syntaxCheckRequiresId() {
// given:
ConsensusGetTopicInfoQuery op = ConsensusGetTopicInfoQuery.newBuilder().build();
Query query = Query.newBuilder().setConsensusGetTopicInfo(op).build();
// when:
ResponseCodeEnum status = subject.checkValidity(query, view);
// expect:
assertEquals(INVALID_TOPIC_ID, status);
}
use of com.hederahashgraph.api.proto.java.Query 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());
}
use of com.hederahashgraph.api.proto.java.Query 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());
}
use of com.hederahashgraph.api.proto.java.Query 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());
}
Aggregations