Search in sources :

Example 51 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class PollingTopicMessageRetrieverTest method startTimeBefore.

@ParameterizedTest
@ValueSource(booleans = { true, false })
void startTimeBefore(boolean throttle) {
    domainBuilder.topicMessages(10, Instant.now()).blockLast();
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(TOPIC_ID).build();
    pollingTopicMessageRetriever.retrieve(filter, throttle).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L).thenCancel().verify(Duration.ofMillis(1000));
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 52 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class PollingTopicMessageRetrieverTest method noMessages.

@ParameterizedTest
@ValueSource(booleans = { true, false })
void noMessages(boolean throttled) {
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(Instant.EPOCH).topicId(TOPIC_ID).build();
    pollingTopicMessageRetriever.retrieve(filter, throttled).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNextCount(0L).expectComplete().verify(Duration.ofMillis(500));
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 53 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class PollingTopicMessageRetrieverTest method greaterThanPageSize.

@ParameterizedTest
@ValueSource(booleans = { true, false })
void greaterThanPageSize(boolean throttle) {
    int maxPageSize = overrideMaxPageSize(throttle, 2);
    domainBuilder.topicMessage().block();
    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, 3L).expectComplete().verify(Duration.ofMillis(500));
    restoreMaxPageSize(throttle, maxPageSize);
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 54 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class PollingTopicMessageRetrieverTest method startTimeEquals.

@ParameterizedTest
@ValueSource(booleans = { true, false })
void startTimeEquals(boolean throttle) {
    Instant now = Instant.now();
    domainBuilder.topicMessage(t -> t.consensusTimestamp(now)).block();
    TopicMessageFilter filter = TopicMessageFilter.builder().startTime(now).topicId(TOPIC_ID).build();
    pollingTopicMessageRetriever.retrieve(filter, throttle).map(TopicMessage::getSequenceNumber).as(StepVerifier::create).expectNext(1L).thenCancel().verify(Duration.ofMillis(500));
}
Also used : ValueSource(org.junit.jupiter.params.provider.ValueSource) BeforeEach(org.junit.jupiter.api.BeforeEach) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) LongStream(java.util.stream.LongStream) StepVerifier(reactor.test.StepVerifier) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Resource(javax.annotation.Resource) Autowired(org.springframework.beans.factory.annotation.Autowired) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Duration(java.time.Duration) TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) DomainBuilder(com.hedera.mirror.grpc.domain.DomainBuilder) TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) Instant(java.time.Instant) TopicMessageFilter(com.hedera.mirror.grpc.domain.TopicMessageFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 55 with TopicMessage

use of com.hedera.mirror.grpc.domain.TopicMessage in project hedera-mirror-node by hashgraph.

the class ConsensusControllerTest method subscribeTopicBlocking.

@Test
void subscribeTopicBlocking() {
    TopicMessage topicMessage1 = domainBuilder.topicMessage().block();
    TopicMessage topicMessage2 = domainBuilder.topicMessage().block();
    TopicMessage topicMessage3 = domainBuilder.topicMessage().block();
    ConsensusTopicQuery query = ConsensusTopicQuery.newBuilder().setLimit(3L).setConsensusStartTime(Timestamp.newBuilder().setSeconds(0).build()).setTopicID(TopicID.newBuilder().setRealmNum(0).setTopicNum(100).build()).build();
    assertThat(blockingService.subscribeTopic(query)).toIterable().hasSize(3).containsSequence(topicMessage1.getResponse(), topicMessage2.getResponse(), topicMessage3.getResponse());
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) ConsensusTopicQuery(com.hedera.mirror.api.proto.ConsensusTopicQuery) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

TopicMessage (com.hedera.mirror.grpc.domain.TopicMessage)58 TopicMessageFilter (com.hedera.mirror.grpc.domain.TopicMessageFilter)50 Test (org.junit.jupiter.api.Test)45 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)43 Instant (java.time.Instant)17 StepVerifier (reactor.test.StepVerifier)15 Duration (java.time.Duration)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 DomainBuilder (com.hedera.mirror.grpc.domain.DomainBuilder)10 Resource (javax.annotation.Resource)10 ValueSource (org.junit.jupiter.params.provider.ValueSource)10 Autowired (org.springframework.beans.factory.annotation.Autowired)10 Flux (reactor.core.publisher.Flux)10 EntityId (com.hedera.mirror.common.domain.entity.EntityId)9 EntityType (com.hedera.mirror.common.domain.entity.EntityType)9 AfterEach (org.junit.jupiter.api.AfterEach)9 BeforeEach (org.junit.jupiter.api.BeforeEach)9 ConsensusTopicQuery (com.hedera.mirror.api.proto.ConsensusTopicQuery)6 GrpcProperties (com.hedera.mirror.grpc.GrpcProperties)5 ListenerProperties (com.hedera.mirror.grpc.listener.ListenerProperties)5