Search in sources :

Example 6 with RichInstant

use of com.hedera.services.state.submerkle.RichInstant 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)

Example 7 with RichInstant

use of com.hedera.services.state.submerkle.RichInstant in project hedera-services by hashgraph.

the class DomainSerdesTest method readsNullForNullInstant.

@Test
void readsNullForNullInstant() throws IOException {
    // setup:
    var in = mock(SerializableDataInputStream.class);
    given(in.readBoolean()).willReturn(false);
    // when:
    RichInstant data = subject.readNullableInstant(in);
    // then:
    verify(in).readBoolean();
    verifyNoMoreInteractions(in);
    // and:
    assertNull(data);
}
Also used : RichInstant(com.hedera.services.state.submerkle.RichInstant) Test(org.junit.jupiter.api.Test)

Example 8 with RichInstant

use of com.hedera.services.state.submerkle.RichInstant 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 9 with RichInstant

use of com.hedera.services.state.submerkle.RichInstant in project hedera-services by hashgraph.

the class DomainSerdesTest method readsExpectedForNonNullInstant.

@Test
void readsExpectedForNonNullInstant() throws IOException {
    // setup:
    var in = mock(SerializableDataInputStream.class);
    // and:
    var expected = new RichInstant(123L, 456);
    given(in.readBoolean()).willReturn(true);
    given(in.readLong()).willReturn(123L);
    given(in.readInt()).willReturn(456);
    // when:
    RichInstant data = subject.readNullableInstant(in);
    // then:
    assertEquals(expected, data);
}
Also used : RichInstant(com.hedera.services.state.submerkle.RichInstant) Test(org.junit.jupiter.api.Test)

Example 10 with RichInstant

use of com.hedera.services.state.submerkle.RichInstant in project hedera-services by hashgraph.

the class MerkleTopicTest method constructorWithEmptyValuesTestingAccessors.

@Test
void constructorWithEmptyValuesTestingAccessors() {
    final var topic = new MerkleTopic("", new JKeyList(), new JKeyList(), 0L, new EntityId(), new RichInstant());
    assertDefaultTopicAccessors(topic);
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) JKeyList(com.hedera.services.legacy.core.jproto.JKeyList) 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)

Aggregations

RichInstant (com.hedera.services.state.submerkle.RichInstant)10 Test (org.junit.jupiter.api.Test)7 EntityId (com.hedera.services.state.submerkle.EntityId)5 MerkleTopic (com.hedera.services.state.merkle.MerkleTopic)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 JKeyList (com.hedera.services.legacy.core.jproto.JKeyList)1 MerkleToken (com.hedera.services.state.merkle.MerkleToken)1 MerkleUniqueToken (com.hedera.services.state.merkle.MerkleUniqueToken)1 ExpirableTxnRecord (com.hedera.services.state.submerkle.ExpirableTxnRecord)1 TxnId (com.hedera.services.state.submerkle.TxnId)1 Id (com.hedera.services.store.models.Id)1 NftId (com.hedera.services.store.models.NftId)1 UniqueToken (com.hedera.services.store.models.UniqueToken)1 AccountID (com.hederahashgraph.api.proto.java.AccountID)1 TopicID (com.hederahashgraph.api.proto.java.TopicID)1 DecoderException (org.apache.commons.codec.DecoderException)1 CsvSource (org.junit.jupiter.params.provider.CsvSource)1