use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class NotifyingTopicListenerTest method json.
// Test deserialization from JSON to verify contract with PostgreSQL listen/notify
@Test
void json() {
String json = "{" + "\"@type\":\"TopicMessage\"," + "\"chunk_num\":1," + "\"chunk_total\":2," + "\"consensus_timestamp\":1594401417000000000," + "\"message\":\"AQID\"," + "\"payer_account_id\":4294968296," + "\"running_hash\":\"BAUG\"," + "\"running_hash_version\":2," + "\"sequence_number\":1," + "\"topic_id\":1001," + "\"valid_start_timestamp\":1594401416000000000" + "}";
TopicMessage topicMessage = TopicMessage.builder().chunkNum(1).chunkTotal(2).consensusTimestamp(Instant.ofEpochSecond(1594401417)).message(new byte[] { 1, 2, 3 }).payerAccountId(4294968296L).runningHash(new byte[] { 4, 5, 6 }).runningHashVersion(2).sequenceNumber(1L).topicId(1001).validStartTimestamp(Instant.ofEpochSecond(1594401416)).build();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(1001L, EntityType.TOPIC)).build();
topicListener.listen(filter).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).then(() -> jdbcTemplate.execute("NOTIFY topic_message, '" + json + "'")).expectNext(topicMessage).thenCancel().verify(Duration.ofMillis(500L));
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class TopicMessageRepositoryTest method findByFilterWithTopicId.
@Test
void findByFilterWithTopicId() {
TopicMessage topicMessage1 = domainBuilder.topicMessage(t -> t.topicId(1)).block();
TopicMessage topicMessage2 = domainBuilder.topicMessage(t -> t.topicId(2)).block();
TopicMessage topicMessage3 = domainBuilder.topicMessage(t -> t.topicId(3)).block();
TopicMessageFilter filter = TopicMessageFilter.builder().topicId(EntityId.of(2L, EntityType.TOPIC)).startTime(topicMessage1.getConsensusTimestampInstant()).build();
assertThat(topicMessageRepository.findByFilter(filter)).containsExactly(topicMessage2);
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class TopicMessageRepositoryTest method findLatest.
@Test
void findLatest() {
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
TopicMessage topicMessage4 = domainBuilder.topicMessage().block();
Pageable pageable = PageRequest.of(0, 2);
assertThat(topicMessageRepository.findLatest(topicMessage1.getConsensusTimestamp(), pageable)).containsExactly(topicMessage2, topicMessage3);
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class TopicMessageRepositoryTest method findByFilterWithStartTime.
@Test
void findByFilterWithStartTime() {
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(topicMessage2.getConsensusTimestampInstant()).topicId(EntityId.of(topicMessage1.getTopicId(), EntityType.TOPIC)).build();
assertThat(topicMessageRepository.findByFilter(filter)).containsExactly(topicMessage2, topicMessage3);
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class PollingTopicMessageRetrieverTest method limitEqualPageSize.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void limitEqualPageSize(boolean throttle) {
int maxPageSize = overrideMaxPageSize(throttle, 2);
domainBuilder.topicMessages(4, Instant.now()).blockLast();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).limit(2L).topicId(TOPIC_ID).build();
pollingTopicMessageRetriever.retrieve(filter, throttle).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(1L, 2L).expectComplete().verify(Duration.ofMillis(500));
restoreMaxPageSize(throttle, maxPageSize);
}
Aggregations