Search in sources :

Example 1 with AddressBookQuery

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

the class NetworkControllerTest method notFound.

@Test
void notFound() {
    AddressBookQuery query = AddressBookQuery.newBuilder().setFileId(FileID.newBuilder().setFileNum(102L).build()).build();
    reactiveService.getNodes(Mono.just(query)).as(StepVerifier::create).expectErrorSatisfies(t -> assertException(t, Status.Code.NOT_FOUND, "does not exist")).verify(Duration.ofSeconds(1L));
}
Also used : FileID(com.hederahashgraph.api.proto.java.FileID) AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) ServiceEndpoint(com.hederahashgraph.api.proto.java.ServiceEndpoint) GrpcClient(net.devh.boot.grpc.client.inject.GrpcClient) StepVerifier(reactor.test.StepVerifier) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) ProtoUtil(com.hedera.mirror.grpc.util.ProtoUtil) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) Mono(reactor.core.publisher.Mono) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) ByteString(com.google.protobuf.ByteString) StatusRuntimeException(io.grpc.StatusRuntimeException) InetAddress(java.net.InetAddress) Test(org.junit.jupiter.api.Test) ReactorNetworkServiceGrpc(com.hedera.mirror.api.proto.ReactorNetworkServiceGrpc) Duration(java.time.Duration) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Log4j2(lombok.extern.log4j.Log4j2) NodeAddress(com.hederahashgraph.api.proto.java.NodeAddress) Status(io.grpc.Status) AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with AddressBookQuery

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

the class NetworkControllerTest method invalidLimit.

@Test
void invalidLimit() {
    AddressBookQuery query = AddressBookQuery.newBuilder().setFileId(FileID.newBuilder().build()).setLimit(-1).build();
    reactiveService.getNodes(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.ofSeconds(1L));
}
Also used : FileID(com.hederahashgraph.api.proto.java.FileID) AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) ServiceEndpoint(com.hederahashgraph.api.proto.java.ServiceEndpoint) GrpcClient(net.devh.boot.grpc.client.inject.GrpcClient) StepVerifier(reactor.test.StepVerifier) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) ProtoUtil(com.hedera.mirror.grpc.util.ProtoUtil) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) Mono(reactor.core.publisher.Mono) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) ByteString(com.google.protobuf.ByteString) StatusRuntimeException(io.grpc.StatusRuntimeException) InetAddress(java.net.InetAddress) Test(org.junit.jupiter.api.Test) ReactorNetworkServiceGrpc(com.hedera.mirror.api.proto.ReactorNetworkServiceGrpc) Duration(java.time.Duration) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Log4j2(lombok.extern.log4j.Log4j2) NodeAddress(com.hederahashgraph.api.proto.java.NodeAddress) Status(io.grpc.Status) AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with AddressBookQuery

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

the class NetworkControllerTest method limitReached.

@Test
void limitReached() {
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    addressBookEntry();
    AddressBookQuery query = AddressBookQuery.newBuilder().setFileId(FileID.newBuilder().setFileNum(addressBook.getFileId().getEntityNum()).build()).setLimit(1).build();
    reactiveService.getNodes(Mono.just(query)).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).consumeNextWith(n -> assertEntry(addressBookEntry1, n)).expectComplete().verify(Duration.ofSeconds(1L));
}
Also used : AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 4 with AddressBookQuery

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

the class NetworkControllerTest method nullFields.

@Test
void nullFields() {
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry = domainBuilder.addressBookEntry().customize(a -> a.consensusTimestamp(CONSENSUS_TIMESTAMP).description(null).memo(null).nodeCertHash(null).publicKey(null).stake(null)).persist();
    AddressBookQuery query = AddressBookQuery.newBuilder().setFileId(FileID.newBuilder().setFileNum(addressBook.getFileId().getEntityNum()).build()).build();
    reactiveService.getNodes(Mono.just(query)).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).consumeNextWith(n -> assertThat(n).isNotNull().returns("", NodeAddress::getDescription).returns(ByteString.EMPTY, NodeAddress::getMemo).returns(addressBookEntry.getNodeAccountId(), t -> EntityId.of(n.getNodeAccountId())).returns(ByteString.EMPTY, NodeAddress::getNodeCertHash).returns(addressBookEntry.getNodeId(), NodeAddress::getNodeId).returns("", NodeAddress::getRSAPubKey).returns(0L, NodeAddress::getStake)).expectComplete().verify(Duration.ofSeconds(1L));
}
Also used : FileID(com.hederahashgraph.api.proto.java.FileID) AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) ServiceEndpoint(com.hederahashgraph.api.proto.java.ServiceEndpoint) GrpcClient(net.devh.boot.grpc.client.inject.GrpcClient) StepVerifier(reactor.test.StepVerifier) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) ProtoUtil(com.hedera.mirror.grpc.util.ProtoUtil) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) Mono(reactor.core.publisher.Mono) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) ByteString(com.google.protobuf.ByteString) StatusRuntimeException(io.grpc.StatusRuntimeException) InetAddress(java.net.InetAddress) Test(org.junit.jupiter.api.Test) ReactorNetworkServiceGrpc(com.hedera.mirror.api.proto.ReactorNetworkServiceGrpc) Duration(java.time.Duration) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Log4j2(lombok.extern.log4j.Log4j2) NodeAddress(com.hederahashgraph.api.proto.java.NodeAddress) Status(io.grpc.Status) AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) NodeAddress(com.hederahashgraph.api.proto.java.NodeAddress) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 5 with AddressBookQuery

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

the class NetworkControllerTest method invalidFileId.

@Test
void invalidFileId() {
    AddressBookQuery query = AddressBookQuery.newBuilder().setFileId(FileID.newBuilder().setFileNum(-1).build()).build();
    reactiveService.getNodes(Mono.just(query)).as(StepVerifier::create).expectErrorSatisfies(t -> assertException(t, Status.Code.INVALID_ARGUMENT, "Invalid entity ID")).verify(Duration.ofSeconds(1L));
}
Also used : FileID(com.hederahashgraph.api.proto.java.FileID) AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) ServiceEndpoint(com.hederahashgraph.api.proto.java.ServiceEndpoint) GrpcClient(net.devh.boot.grpc.client.inject.GrpcClient) StepVerifier(reactor.test.StepVerifier) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) ProtoUtil(com.hedera.mirror.grpc.util.ProtoUtil) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) Mono(reactor.core.publisher.Mono) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) ByteString(com.google.protobuf.ByteString) StatusRuntimeException(io.grpc.StatusRuntimeException) InetAddress(java.net.InetAddress) Test(org.junit.jupiter.api.Test) ReactorNetworkServiceGrpc(com.hedera.mirror.api.proto.ReactorNetworkServiceGrpc) Duration(java.time.Duration) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Log4j2(lombok.extern.log4j.Log4j2) NodeAddress(com.hederahashgraph.api.proto.java.NodeAddress) Status(io.grpc.Status) AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AddressBookQuery (com.hedera.mirror.api.proto.AddressBookQuery)7 AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)7 AddressBookEntry (com.hedera.mirror.common.domain.addressbook.AddressBookEntry)7 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)7 Test (org.junit.jupiter.api.Test)7 StepVerifier (reactor.test.StepVerifier)7 ByteString (com.google.protobuf.ByteString)6 ReactorNetworkServiceGrpc (com.hedera.mirror.api.proto.ReactorNetworkServiceGrpc)6 DomainBuilder (com.hedera.mirror.common.domain.DomainBuilder)6 EntityId (com.hedera.mirror.common.domain.entity.EntityId)6 ProtoUtil (com.hedera.mirror.grpc.util.ProtoUtil)6 FileID (com.hederahashgraph.api.proto.java.FileID)6 NodeAddress (com.hederahashgraph.api.proto.java.NodeAddress)6 ServiceEndpoint (com.hederahashgraph.api.proto.java.ServiceEndpoint)6 Status (io.grpc.Status)6 StatusRuntimeException (io.grpc.StatusRuntimeException)6 InetAddress (java.net.InetAddress)6 Duration (java.time.Duration)6 Resource (javax.annotation.Resource)6 Log4j2 (lombok.extern.log4j.Log4j2)6