use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method historicalMessages.
@Test
void historicalMessages() {
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(topicId).build();
topicMessageService.subscribeTopic(filter).as(StepVerifier::create).expectNext(topicMessage1, topicMessage2, topicMessage3).thenCancel().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class TopicMessageServiceTest method incomingMessagesWithEndTimeEquals.
@Test
void incomingMessagesWithEndTimeEquals() {
Flux<TopicMessage> generator = domainBuilder.topicMessages(3, future.minusNanos(2));
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).endTime(future).topicId(topicId).build();
topicMessageService.subscribeTopic(filter).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(100)).then(generator::blockLast).expectNext(1L, 2L).expectComplete().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class AbstractTopicListenerTest method multipleSubscribers.
@Test
void multipleSubscribers() {
// @formatter:off
Flux<TopicMessage> generator = Flux.concat(domainBuilder.topicMessage(t -> t.topicId(1).sequenceNumber(1).consensusTimestamp(future.plusNanos(1L))), domainBuilder.topicMessage(t -> t.topicId(1).sequenceNumber(2).consensusTimestamp(future.plusNanos(2L))), domainBuilder.topicMessage(t -> t.topicId(2).sequenceNumber(7).consensusTimestamp(future.plusNanos(3L))), domainBuilder.topicMessage(t -> t.topicId(2).sequenceNumber(8).consensusTimestamp(future.plusNanos(4L))), domainBuilder.topicMessage(t -> t.topicId(1).sequenceNumber(3).consensusTimestamp(future.plusNanos(5L))));
// @formatter:on
TopicMessageFilter filter1 = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(1L, EntityType.TOPIC)).build();
TopicMessageFilter filter2 = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(2L, EntityType.TOPIC)).build();
StepVerifier stepVerifier1 = topicListener.listen(filter1).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(1L, 2L, 3L).thenCancel().verifyLater();
StepVerifier stepVerifier2 = topicListener.listen(filter2).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(7L, 8L).thenCancel().verifyLater();
Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
publish(generator);
stepVerifier1.verify(Duration.ofMillis(500));
stepVerifier2.verify(Duration.ofMillis(500));
topicListener.listen(filter1).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).as("Verify can still re-subscribe after poller cancelled when no subscriptions").expectNextCount(0).thenCancel().verify(Duration.ofMillis(100));
}
use of com.hedera.mirror.grpc.domain.TopicMessage 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.TopicMessage 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);
}
Aggregations