Search in sources :

Example 1 with ConsensusTopicQuery

use of com.hedera.mirror.api.proto.ConsensusTopicQuery 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));
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) ConsensusTopicQuery(com.hedera.mirror.api.proto.ConsensusTopicQuery) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with ConsensusTopicQuery

use of com.hedera.mirror.api.proto.ConsensusTopicQuery 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));
}
Also used : ConsensusTopicQuery(com.hedera.mirror.api.proto.ConsensusTopicQuery) TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with ConsensusTopicQuery

use of com.hedera.mirror.api.proto.ConsensusTopicQuery 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));
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) ConsensusTopicQuery(com.hedera.mirror.api.proto.ConsensusTopicQuery) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with ConsensusTopicQuery

use of com.hedera.mirror.api.proto.ConsensusTopicQuery in project hedera-mirror-node by hashgraph.

the class ConsensusControllerTest method constraintViolationException.

@Test
void constraintViolationException() {
    ConsensusTopicQuery query = ConsensusTopicQuery.newBuilder().setTopicID(TopicID.newBuilder().build()).setLimit(-1).build();
    grpcConsensusService.subscribeTopic(Mono.just(query)).as(StepVerifier::create).expectErrorSatisfies(t -> assertException(t, Status.Code.INVALID_ARGUMENT, "limit: must be greater " + "than or equal to 0")).verify(Duration.ofMillis(500));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) TopicID(com.hederahashgraph.api.proto.java.TopicID) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) ConsensusServiceGrpc(com.hedera.mirror.api.proto.ConsensusServiceGrpc) Duration(java.time.Duration) Status(io.grpc.Status) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) GrpcClient(net.devh.boot.grpc.client.inject.GrpcClient) ReactorConsensusServiceGrpc(com.hedera.mirror.api.proto.ReactorConsensusServiceGrpc) ConsensusTopicResponse(com.hedera.mirror.api.proto.ConsensusTopicResponse) ConsensusTopicQuery(com.hedera.mirror.api.proto.ConsensusTopicQuery) Resource(javax.annotation.Resource) ListenerProperties(com.hedera.mirror.grpc.listener.ListenerProperties) Mono(reactor.core.publisher.Mono) Instant(java.time.Instant) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) AfterEach(org.junit.jupiter.api.AfterEach) Log4j2(lombok.extern.log4j.Log4j2) TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) DomainBuilder(com.hedera.mirror.grpc.domain.DomainBuilder) ConsensusTopicQuery(com.hedera.mirror.api.proto.ConsensusTopicQuery) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 5 with ConsensusTopicQuery

use of com.hedera.mirror.api.proto.ConsensusTopicQuery 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));
}
Also used : TopicMessage(com.hedera.mirror.grpc.domain.TopicMessage) ConsensusTopicQuery(com.hedera.mirror.api.proto.ConsensusTopicQuery) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ConsensusTopicQuery (com.hedera.mirror.api.proto.ConsensusTopicQuery)9 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)9 TopicMessage (com.hedera.mirror.grpc.domain.TopicMessage)9 Test (org.junit.jupiter.api.Test)9 StepVerifier (reactor.test.StepVerifier)8 ConsensusServiceGrpc (com.hedera.mirror.api.proto.ConsensusServiceGrpc)4 ConsensusTopicResponse (com.hedera.mirror.api.proto.ConsensusTopicResponse)4 ReactorConsensusServiceGrpc (com.hedera.mirror.api.proto.ReactorConsensusServiceGrpc)4 DomainBuilder (com.hedera.mirror.grpc.domain.DomainBuilder)4 ListenerProperties (com.hedera.mirror.grpc.listener.ListenerProperties)4 Timestamp (com.hederahashgraph.api.proto.java.Timestamp)4 TopicID (com.hederahashgraph.api.proto.java.TopicID)4 Status (io.grpc.Status)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 Duration (java.time.Duration)4 Instant (java.time.Instant)4 Resource (javax.annotation.Resource)4 Log4j2 (lombok.extern.log4j.Log4j2)4 GrpcClient (net.devh.boot.grpc.client.inject.GrpcClient)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4