Search in sources :

Example 6 with MerkleTopic

use of com.hedera.services.state.merkle.MerkleTopic in project hedera-services by hashgraph.

the class SubmitMessageTransitionLogicTest method givenChunkMessage.

private void givenChunkMessage(int totalChunks, int chunkNumber, TransactionID initialTransactionID) {
    ConsensusMessageChunkInfo chunkInfo = ConsensusMessageChunkInfo.newBuilder().setInitialTransactionID(initialTransactionID).setTotal(totalChunks).setNumber(chunkNumber).build();
    givenTransaction(getBasicValidTransactionBodyBuilder().setChunkInfo(chunkInfo));
    given(validator.queryableTopicStatus(asTopic(TOPIC_ID), topics)).willReturn(OK);
    topics.put(EntityNum.fromTopicId(asTopic(TOPIC_ID)), new MerkleTopic());
}
Also used : ConsensusMessageChunkInfo(com.hederahashgraph.api.proto.java.ConsensusMessageChunkInfo) MerkleTopic(com.hedera.services.state.merkle.MerkleTopic)

Example 7 with MerkleTopic

use of com.hedera.services.state.merkle.MerkleTopic in project hedera-services by hashgraph.

the class UpdateMerkleTopicResourceUsageTest method getFeeThrowsExceptionForBadKeys.

@Test
void getFeeThrowsExceptionForBadKeys() throws DecoderException, IllegalArgumentException {
    final var txnBody = makeTransactionBody(topicId, defaultMemo, JKey.mapJKey(adminKey), JKey.mapJKey(submitKey), IdUtils.asAccount("0.1.2"), null, null);
    final var merkleTopic = new MerkleTopic(defaultMemo, adminKey, submitKey, 0, new EntityId(0, 1, 2), new RichInstant(36_000, 0));
    given(topics.get(EntityNum.fromTopicId(topicId))).willReturn(merkleTopic);
    final var mockedJkey = mockStatic(JKey.class);
    mockedJkey.when(() -> JKey.mapJKey(any())).thenThrow(new DecoderException());
    assertThrows(InvalidTxBodyException.class, () -> subject.usageGiven(txnBody, sigValueObj, view));
    assertThat(logCaptor.warnLogs(), Matchers.contains(Matchers.startsWith("Usage estimation unexpectedly failed for")));
    mockedJkey.close();
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) DecoderException(org.apache.commons.codec.DecoderException) MerkleTopic(com.hedera.services.state.merkle.MerkleTopic) RichInstant(com.hedera.services.state.submerkle.RichInstant) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with MerkleTopic

use of com.hedera.services.state.merkle.MerkleTopic in project hedera-services by hashgraph.

the class SubmitMessageTransitionLogicTest method givenValidTransactionContext.

private void givenValidTransactionContext() {
    givenTransaction(getBasicValidTransactionBodyBuilder());
    given(validator.queryableTopicStatus(asTopic(TOPIC_ID), topics)).willReturn(OK);
    topics.put(EntityNum.fromTopicId(asTopic(TOPIC_ID)), new MerkleTopic());
}
Also used : MerkleTopic(com.hedera.services.state.merkle.MerkleTopic)

Example 9 with MerkleTopic

use of com.hedera.services.state.merkle.MerkleTopic in project hedera-services by hashgraph.

the class GetTopicInfoAnswer method checkValidity.

@Override
public ResponseCodeEnum checkValidity(Query query, StateView view) {
    MerkleMap<EntityNum, MerkleTopic> topics = view.topics();
    ConsensusGetTopicInfoQuery op = query.getConsensusGetTopicInfo();
    return validityOf(op, topics);
}
Also used : ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) MerkleTopic(com.hedera.services.state.merkle.MerkleTopic) EntityNum(com.hedera.services.utils.EntityNum)

Example 10 with MerkleTopic

use of com.hedera.services.state.merkle.MerkleTopic in project hedera-services by hashgraph.

the class MerkleTopicTest method equalsViaCopy.

@ParameterizedTest
@CsvSource({ "memo, 0000000000000000000000000000000000000000000000000000000000000000, " + "1111111111111111111111111111111111111111111111111111111111111111, 2, 3.4.5, 6666_777777777", ", , , 0, , 0_0" })
void equalsViaCopy(final String memo, @ConvertWith(JEd25519KeyConverter.class) final JEd25519Key adminKey, @ConvertWith(JEd25519KeyConverter.class) final JEd25519Key submitKey, final long autoRenewDurationSeconds, @ConvertWith(EntityIdConverter.class) final EntityId autoRenewAccountId, @ConvertWith(RichInstantConverter.class) final RichInstant expirationTimestamp) {
    final var topic = new MerkleTopic(memo, adminKey, submitKey, autoRenewDurationSeconds, autoRenewAccountId, expirationTimestamp);
    assertEquals(topic, new MerkleTopic(topic));
}
Also used : MerkleTopic(com.hedera.services.state.merkle.MerkleTopic) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MerkleTopic (com.hedera.services.state.merkle.MerkleTopic)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Test (org.junit.jupiter.api.Test)4 EntityId (com.hedera.services.state.submerkle.EntityId)3 RichInstant (com.hedera.services.state.submerkle.RichInstant)3 EntityNum (com.hedera.services.utils.EntityNum)2 CsvSource (org.junit.jupiter.params.provider.CsvSource)2 NetworkInfo (com.hedera.services.config.NetworkInfo)1 MutableStateChildren (com.hedera.services.context.MutableStateChildren)1 HFileMeta (com.hedera.services.files.HFileMeta)1 JKeyList (com.hedera.services.legacy.core.jproto.JKeyList)1 MerkleAccount (com.hedera.services.state.merkle.MerkleAccount)1 MerkleSpecialFiles (com.hedera.services.state.merkle.MerkleSpecialFiles)1 MerkleToken (com.hedera.services.state.merkle.MerkleToken)1 MerkleTokenRelStatus (com.hedera.services.state.merkle.MerkleTokenRelStatus)1 ContractKey (com.hedera.services.state.virtual.ContractKey)1 ContractValue (com.hedera.services.state.virtual.ContractValue)1 VirtualBlobKey (com.hedera.services.state.virtual.VirtualBlobKey)1 VirtualBlobValue (com.hedera.services.state.virtual.VirtualBlobValue)1 ScheduleStore (com.hedera.services.store.schedule.ScheduleStore)1