Search in sources :

Example 31 with AddressBook

use of com.hedera.mirror.common.domain.addressbook.AddressBook in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method limitReached.

@Test
void limitReached() {
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).limit(1).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 32 with AddressBook

use of com.hedera.mirror.common.domain.addressbook.AddressBook in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method equalToPageSize.

@Test
void equalToPageSize() {
    addressBookProperties.setPageSize(2);
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    AddressBookEntry addressBookEntry2 = addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1, addressBookEntry2);
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 33 with AddressBook

use of com.hedera.mirror.common.domain.addressbook.AddressBook in project hedera-mirror-node by hashgraph.

the class NetworkServiceTest method noNodes.

@Test
void noNodes() {
    AddressBook addressBook = addressBook();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
    networkService.getNodes(filter).as(StepVerifier::create).thenAwait(Duration.ofMillis(100)).expectNextCount(0L).expectComplete().verify(Duration.ofMillis(500));
}
Also used : AddressBookFilter(com.hedera.mirror.grpc.domain.AddressBookFilter) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 34 with AddressBook

use of com.hedera.mirror.common.domain.addressbook.AddressBook in project hedera-mirror-node by hashgraph.

the class AddressBookServiceImpl method validateAndCompleteAddressBookList.

/**
 * Ensure all addressBook file_data entries prior to this fileData and after the current address book have been
 * parsed. If not parse them and populate the address_book tables to complete the list. This does not handle initial
 * startup and only ensure any unprocessed address book files are processed.
 *
 * @param fileData
 */
private void validateAndCompleteAddressBookList(FileData fileData) {
    AddressBook currentAddressBook = getCurrent();
    long startConsensusTimestamp = currentAddressBook == null ? 0 : currentAddressBook.getStartConsensusTimestamp();
    transactionTemplate.executeWithoutResult(status -> parseHistoricAddressBooks(startConsensusTimestamp, fileData.getConsensusTimestamp()));
}
Also used : AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) NodeAddressBook(com.hederahashgraph.api.proto.java.NodeAddressBook)

Example 35 with AddressBook

use of com.hedera.mirror.common.domain.addressbook.AddressBook in project hedera-mirror-node by hashgraph.

the class AddressBookRepositoryTest method cascade.

@Test
@Transactional
void cascade() {
    AddressBook addressBook = domainBuilder.addressBook().persist();
    assertThat(addressBookRepository.findById(addressBook.getStartConsensusTimestamp())).get().extracting(AddressBook::getEntries).isNull();
    domainBuilder.addressBookEntry(1).customize(a -> a.consensusTimestamp(addressBook.getStartConsensusTimestamp())).persist();
    assertThat(addressBookRepository.findById(addressBook.getStartConsensusTimestamp())).get().extracting(AddressBook::getEntries).as("Ensure entries aren't eagerly loaded").isNull();
}
Also used : Test(org.junit.jupiter.api.Test) EntityId(com.hedera.mirror.common.domain.entity.EntityId) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Resource(javax.annotation.Resource) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Transactional(org.springframework.transaction.annotation.Transactional) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) Test(org.junit.jupiter.api.Test) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)43 Test (org.junit.jupiter.api.Test)33 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)17 NodeAddressBook (com.hederahashgraph.api.proto.java.NodeAddressBook)17 AddressBookEntry (com.hedera.mirror.common.domain.addressbook.AddressBookEntry)12 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)11 ServiceEndpoint (com.hederahashgraph.api.proto.java.ServiceEndpoint)10 AddressBookServiceEndpoint (com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint)9 EntityId (com.hedera.mirror.common.domain.entity.EntityId)6 AddressBookFilter (com.hedera.mirror.grpc.domain.AddressBookFilter)6 Resource (javax.annotation.Resource)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 ByteString (com.google.protobuf.ByteString)4 DomainBuilder (com.hedera.mirror.common.domain.DomainBuilder)4 NodeAddress (com.hederahashgraph.api.proto.java.NodeAddress)4 StepVerifier (reactor.test.StepVerifier)4 AddressBookQuery (com.hedera.mirror.api.proto.AddressBookQuery)3 EntityType (com.hedera.mirror.common.domain.entity.EntityType)3 SignatureVerificationException (com.hedera.mirror.importer.exception.SignatureVerificationException)3