Search in sources :

Example 1 with TopicID

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

the class BaseHederaLedgerTestHelper method commonSetup.

protected void commonSetup() {
    sideEffectsTracker = mock(SideEffectsTracker.class);
    creator = mock(ExpiringCreations.class);
    historian = mock(AccountRecordsHistorian.class);
    ids = new EntityIdSource() {

        long nextId = NEXT_ID;

        @Override
        public TopicID newTopicId(final AccountID sponsor) {
            return TopicID.newBuilder().setTopicNum(nextId++).build();
        }

        @Override
        public AccountID newAccountId(AccountID newAccountSponsor) {
            return AccountID.newBuilder().setAccountNum(nextId++).build();
        }

        @Override
        public ContractID newContractId(AccountID newContractSponsor) {
            return ContractID.newBuilder().setContractNum(nextId++).build();
        }

        @Override
        public FileID newFileId(AccountID newFileSponsor) {
            return FileID.newBuilder().setFileNum(nextId++).build();
        }

        @Override
        public TokenID newTokenId(AccountID sponsor) {
            return TokenID.newBuilder().setTokenNum(nextId++).build();
        }

        @Override
        public ScheduleID newScheduleId(AccountID sponsor) {
            return ScheduleID.newBuilder().setScheduleNum(nextId++).build();
        }

        @Override
        public void reclaimLastId() {
            nextId--;
        }

        @Override
        public void reclaimProvisionalIds() {
        }

        @Override
        public void resetProvisionalIds() {
        }
    };
}
Also used : EntityIdSource(com.hedera.services.ledger.ids.EntityIdSource) AccountID(com.hederahashgraph.api.proto.java.AccountID) SideEffectsTracker(com.hedera.services.context.SideEffectsTracker) TopicID(com.hederahashgraph.api.proto.java.TopicID) FileID(com.hederahashgraph.api.proto.java.FileID) ContractID(com.hederahashgraph.api.proto.java.ContractID) ExpiringCreations(com.hedera.services.state.expiry.ExpiringCreations) TokenID(com.hederahashgraph.api.proto.java.TokenID) ScheduleID(com.hederahashgraph.api.proto.java.ScheduleID) AccountRecordsHistorian(com.hedera.services.records.AccountRecordsHistorian)

Example 2 with TopicID

use of com.hederahashgraph.api.proto.java.TopicID 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)

Example 3 with TopicID

use of com.hederahashgraph.api.proto.java.TopicID 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());
}
Also used : ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) Response(com.hederahashgraph.api.proto.java.Response) ConsensusGetTopicInfoResponse(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoResponse) 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)

Example 4 with TopicID

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

the class SeqNoEntityIdSourceTest method returnsExpectedTopicId.

@Test
void returnsExpectedTopicId() {
    given(seqNo.getAndIncrement()).willReturn(222L);
    TopicID id = subject.newTopicId(sponsor);
    assertEquals(asTopic("1.2.222"), id);
}
Also used : TopicID(com.hederahashgraph.api.proto.java.TopicID) Test(org.junit.jupiter.api.Test)

Example 5 with TopicID

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

the class MerkleTopicTest method topicFrom.

private MerkleTopic topicFrom(int s) throws IOException {
    long v = 1_234_567L + s * 1_000_000L;
    long t = s + 1;
    AccountID payer = AccountID.newBuilder().setAccountNum(123).build();
    TopicID id = TopicID.newBuilder().setTopicNum(s).build();
    var topic = new MerkleTopic(memos[s], adminKeys[s], submitKeys[s], v, new EntityId(t, t * 2, t * 3), new RichInstant(v, s));
    for (int i = 0; i < s; i++) {
        topic.updateRunningHashAndSequenceNumber(payer, "Hello world!".getBytes(), id, Instant.ofEpochSecond(v, i));
    }
    topic.setKey(EntityNum.fromInt(s));
    return topic;
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) AccountID(com.hederahashgraph.api.proto.java.AccountID) TopicID(com.hederahashgraph.api.proto.java.TopicID) RichInstant(com.hedera.services.state.submerkle.RichInstant)

Aggregations

TopicID (com.hederahashgraph.api.proto.java.TopicID)16 Test (org.junit.jupiter.api.Test)9 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)5 EntityId (com.hedera.mirror.common.domain.entity.EntityId)4 Transaction (com.hederahashgraph.api.proto.java.Transaction)4 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)4 Consumer (java.util.function.Consumer)4 MoreObjects (com.google.common.base.MoreObjects)3 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)3 AccountID (com.hederahashgraph.api.proto.java.AccountID)3 ConsensusSubmitMessageTransactionBody (com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 Range (com.google.common.collect.Range)2 ByteString (com.google.protobuf.ByteString)2 Entity (com.hedera.mirror.common.domain.entity.Entity)2 EntityIdEndec (com.hedera.mirror.common.domain.entity.EntityIdEndec)2 EntityType (com.hedera.mirror.common.domain.entity.EntityType)2 ACCOUNT (com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT)2 TOPIC (com.hedera.mirror.common.domain.entity.EntityType.TOPIC)2