use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class AbstractTopicListenerTest method startTimeAfter.
@Test
void startTimeAfter() {
Mono<TopicMessage> topicMessage = domainBuilder.topicMessage(t -> t.consensusTimestamp(future.minusNanos(1)));
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(future).topicId(topicId).build();
topicListener.listen(filter).as(StepVerifier::create).thenAwait(Duration.ofMillis(100)).then(() -> publish(topicMessage)).expectNextCount(0).thenCancel().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class AbstractTopicListenerTest method greaterThanPageSize.
@Test
void greaterThanPageSize() {
int maxPageSize = listenerProperties.getMaxPageSize();
listenerProperties.setMaxPageSize(2);
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(topicId).build();
topicListener.listen(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).then(() -> publish(domainBuilder.topicMessages(3, future))).expectNext(1L, 2L, 3L).thenCancel().verify(Duration.ofMillis(500));
listenerProperties.setMaxPageSize(maxPageSize);
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter 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.TopicMessageFilter 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.TopicMessageFilter 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);
}
Aggregations