use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class ConsensusControllerTest method subscribeTopicQueryLongOverflowEndTime.
@Test
void subscribeTopicQueryLongOverflowEndTime() {
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
ConsensusTopicQuery query = ConsensusTopicQuery.newBuilder().setLimit(5L).setConsensusStartTime(Timestamp.newBuilder().setSeconds(1).setNanos(2).build()).setConsensusEndTime(Timestamp.newBuilder().setSeconds(31556889864403199L).setNanos(999999999).build()).setTopicID(TopicID.newBuilder().setRealmNum(0).setTopicNum(100).build()).build();
Flux<TopicMessage> generator = domainBuilder.topicMessages(2, Instant.now().plusSeconds(10L));
grpcConsensusService.subscribeTopic(Mono.just(query)).as(StepVerifier::create).expectNext(topicMessage1.getResponse()).expectNext(topicMessage2.getResponse()).expectNext(topicMessage3.getResponse()).thenAwait(Duration.ofMillis(50)).then(() -> generator.blockLast()).expectNextCount(2).expectComplete().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class ConsensusControllerTest method subscribeVerifySequence.
@Test
void subscribeVerifySequence() {
domainBuilder.topicMessage().block();
domainBuilder.topicMessage().block();
domainBuilder.topicMessage().block();
ConsensusTopicQuery query = ConsensusTopicQuery.newBuilder().setLimit(7L).setConsensusStartTime(Timestamp.newBuilder().setSeconds(0).build()).setTopicID(TopicID.newBuilder().setRealmNum(0).setTopicNum(100).build()).build();
Flux<TopicMessage> generator = domainBuilder.topicMessages(4, Instant.now().plusSeconds(10L));
grpcConsensusService.subscribeTopic(Mono.just(query)).map(ConsensusTopicResponse::getSequenceNumber).as(StepVerifier::create).expectNext(1L, 2L, 3L).thenAwait(Duration.ofMillis(50)).then(() -> generator.blockLast()).expectNext(4L, 5L, 6L, 7L).expectComplete().verify(Duration.ofMillis(1000));
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class ConsensusControllerTest method subscribeTopicReactive.
@Test
void subscribeTopicReactive() {
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
ConsensusTopicQuery query = ConsensusTopicQuery.newBuilder().setLimit(5L).setConsensusStartTime(Timestamp.newBuilder().setSeconds(0).build()).setTopicID(TopicID.newBuilder().setRealmNum(0).setTopicNum(100).build()).build();
Flux<TopicMessage> generator = domainBuilder.topicMessages(2, Instant.now().plusSeconds(10L));
grpcConsensusService.subscribeTopic(Mono.just(query)).as(StepVerifier::create).expectNext(topicMessage1.getResponse()).expectNext(topicMessage2.getResponse()).expectNext(topicMessage3.getResponse()).thenAwait(Duration.ofMillis(50)).then(() -> generator.blockLast()).expectNextCount(2).expectComplete().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class ConsensusControllerTest method subscribeTopicQueryPreEpochStartTime.
@Test
void subscribeTopicQueryPreEpochStartTime() {
TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
ConsensusTopicQuery query = ConsensusTopicQuery.newBuilder().setLimit(5L).setConsensusStartTime(Timestamp.newBuilder().setSeconds(-123).setNanos(-456).build()).setTopicID(TopicID.newBuilder().setRealmNum(0).setTopicNum(100).build()).build();
Flux<TopicMessage> generator = domainBuilder.topicMessages(2, Instant.now().plusSeconds(10L));
grpcConsensusService.subscribeTopic(Mono.just(query)).as(StepVerifier::create).expectNext(topicMessage1.getResponse()).expectNext(topicMessage2.getResponse()).expectNext(topicMessage3.getResponse()).thenAwait(Duration.ofMillis(50)).then(() -> generator.blockLast()).expectNextCount(2).expectComplete().verify(Duration.ofMillis(500));
}
use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.
the class PollingTopicMessageRetriever method poll.
private Flux<TopicMessage> poll(PollingContext context) {
TopicMessageFilter filter = context.getFilter();
TopicMessage last = context.getLast();
int limit = filter.hasLimit() ? (int) (filter.getLimit() - context.getTotal().get()) : Integer.MAX_VALUE;
int pageSize = Math.min(limit, context.getMaxPageSize());
Instant startTime = last != null ? last.getConsensusTimestampInstant().plusNanos(1) : filter.getStartTime();
context.getPageSize().set(0L);
TopicMessageFilter newFilter = filter.toBuilder().limit(pageSize).startTime(startTime).build();
log.debug("Executing query: {}", newFilter);
return Flux.fromStream(topicMessageRepository.findByFilter(newFilter)).name("findByFilter").metrics();
}
Aggregations