Search in sources :

Example 1 with ConsensusTopicInfo

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());
}
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 2 with ConsensusTopicInfo

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()));
}
Also used : ConsensusTopicInfo(com.hederahashgraph.api.proto.java.ConsensusTopicInfo)

Example 3 with ConsensusTopicInfo

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

Aggregations

ConsensusTopicInfo (com.hederahashgraph.api.proto.java.ConsensusTopicInfo)3 ConsensusGetTopicInfoQuery (com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery)2 ConsensusGetTopicInfoResponse (com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoResponse)2 Query (com.hederahashgraph.api.proto.java.Query)2 Response (com.hederahashgraph.api.proto.java.Response)2 Test (org.junit.jupiter.api.Test)2