use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class PollingTopicMessageRetrieverTest method lessThanPageSize.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void lessThanPageSize(boolean throttle) {
domainBuilder.topicMessage().block();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(TOPIC_ID).build();
pollingTopicMessageRetriever.retrieve(filter, throttle).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(1L).expectComplete().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class PollingTopicMessageRetrieverTest method equalPageSize.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void equalPageSize(boolean throttle) {
int maxPageSize = overrideMaxPageSize(throttle, 2);
domainBuilder.topicMessage().block();
domainBuilder.topicMessage().block();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).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);
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class PollingTopicMessageRetrieverTest method topicId.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void topicId(boolean throttle) {
domainBuilder.topicMessage(t -> t.topicId(0)).block();
domainBuilder.topicMessage(t -> t.topicId(1)).block();
domainBuilder.topicMessage(t -> t.topicId(2)).block();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(EntityId.of(1L, EntityType.TOPIC)).build();
pollingTopicMessageRetriever.retrieve(filter, throttle).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(2L).thenCancel().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class PollingTopicMessageRetrieverTest method unthrottledShouldKeepPolling.
@Test
void unthrottledShouldKeepPolling() {
retrieverProperties.getUnthrottled().setMaxPolls(20);
Instant now = Instant.now();
Flux<TopicMessage> firstBatch = domainBuilder.topicMessages(5, now);
Flux<TopicMessage> secondBatch = domainBuilder.topicMessages(5, now.plusNanos(5));
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(TOPIC_ID).build();
// in unthrottled mode, the retriever should query the db for up to MaxPolls + 1 times when no limit is set,
// regardless of whether a db query returns less rows than MaxPageSize
pollingTopicMessageRetriever.retrieve(filter, false).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).thenAwait(Duration.ofMillis(20L)).then(firstBatch::blockLast).thenAwait(Duration.ofMillis(20L)).then(secondBatch::blockLast).expectNextSequence(LongStream.range(1, 11).boxed().collect(Collectors.toList())).expectComplete().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessageFilter in project hedera-mirror-node by hashgraph.
the class PollingTopicMessageRetrieverTest method startTimeAfter.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void startTimeAfter(boolean throttle) {
Instant now = Instant.now();
domainBuilder.topicMessage(t -> t.consensusTimestamp(now.minusNanos(1))).block();
TopicMessageFilter filter = TopicMessageFilter.builder().startTime(now).topicId(TOPIC_ID).build();
pollingTopicMessageRetriever.retrieve(filter, throttle).as(StepVerifier::create).expectNextCount(0).thenCancel().verify(Duration.ofMillis(500));
}
Aggregations