use of com.hederahashgraph.api.proto.java.ConsensusTopicInfo 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());
}
use of com.hederahashgraph.api.proto.java.ConsensusTopicInfo in project hedera-services by hashgraph.
the class HapiGetTopicInfo method assertExpectationsGiven.
@Override
protected void assertExpectationsGiven(HapiApiSpec spec) {
ConsensusTopicInfo info = response.getConsensusGetTopicInfo().getTopicInfo();
topicMemo.ifPresent(exp -> assertEquals(exp, info.getMemo(), "Bad memo!"));
if (seqNoFn.isPresent()) {
seqNo = OptionalLong.of(seqNoFn.get().getAsLong());
}
seqNo.ifPresent(exp -> assertEquals(exp, info.getSequenceNumber(), "Bad sequence number!"));
seqNoInfoObserver.ifPresent(obs -> obs.accept(info.getSequenceNumber()));
runningHashEntry.ifPresent(entry -> runningHash = Optional.of(spec.registry().getBytes(entry)));
runningHash.ifPresent(exp -> assertArrayEquals(exp, info.getRunningHash().toByteArray(), "Bad running hash!"));
expiry.ifPresent(exp -> assertEquals(exp, info.getExpirationTime().getSeconds(), "Bad expiry!"));
autoRenewPeriod.ifPresent(exp -> assertEquals(exp, info.getAutoRenewPeriod().getSeconds(), "Bad auto-renew period!"));
adminKey.ifPresent(exp -> assertEquals(spec.registry().getKey(exp), info.getAdminKey(), "Bad admin key!"));
submitKey.ifPresent(exp -> assertEquals(spec.registry().getKey(exp), info.getSubmitKey(), "Bad submit key!"));
autoRenewAccount.ifPresent(exp -> assertEquals(asId(exp, spec), info.getAutoRenewAccount(), "Bad auto-renew account!"));
if (hasNoAdminKey) {
assertFalse(info.hasAdminKey(), "Should have no admin key!");
}
expectedLedgerId.ifPresent(id -> Assertions.assertEquals(rationalize(id), info.getLedgerId()));
}
use of com.hederahashgraph.api.proto.java.ConsensusTopicInfo in project hedera-services by hashgraph.
the class GetMerkleTopicInfoAnswerTest method getsTheTopicInfo.
@Test
void getsTheTopicInfo() throws Throwable {
// setup:
Query query = validQuery(ANSWER_ONLY, fee, target);
// when:
Response response = subject.responseGiven(query, view, OK, fee);
// then:
assertTrue(response.hasConsensusGetTopicInfo());
assertEquals(OK, response.getConsensusGetTopicInfo().getHeader().getNodeTransactionPrecheckCode());
assertEquals(ANSWER_ONLY, response.getConsensusGetTopicInfo().getHeader().getResponseType());
assertEquals(0, response.getConsensusGetTopicInfo().getHeader().getCost());
assertEquals(asTopic(target), response.getConsensusGetTopicInfo().getTopicID());
// and:
ConsensusTopicInfo info = response.getConsensusGetTopicInfo().getTopicInfo();
assertEquals(adminKey, info.getAdminKey());
assertEquals(submitKey, info.getSubmitKey());
assertEquals(merkleTopic.getExpirationTimestamp().getSeconds(), info.getExpirationTime().getSeconds());
assertEquals(merkleTopic.getAutoRenewDurationSeconds(), info.getAutoRenewPeriod().getSeconds());
assertEquals(ByteString.copyFrom(merkleTopic.getRunningHash()), info.getRunningHash());
assertEquals(merkleTopic.getAutoRenewAccountId().num(), info.getAutoRenewAccount().getAccountNum());
assertEquals(merkleTopic.getSequenceNumber(), info.getSequenceNumber());
assertEquals(merkleTopic.getMemo(), info.getMemo());
assertEquals(ledgerId, info.getLedgerId());
}
Aggregations