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