use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.
the class AddAddressBookServiceEndpointsMigrationTest method verifyMigrateWhenNeitherDeprecatedIpNorAddressBookServiceEndpointsAreSet.
@Test
void verifyMigrateWhenNeitherDeprecatedIpNorAddressBookServiceEndpointsAreSet() throws IOException {
long consensusTimestamp = 1;
int nodeIdCount = 3;
int endPointPerNode = 0;
insertAddressBook(AddressBookServiceImpl.ADDRESS_BOOK_102_ENTITY_ID, consensusTimestamp, nodeIdCount);
getAndSaveAddressBookEntries(false, consensusTimestamp, nodeIdCount, endPointPerNode);
assertThat(addressBookEntryRepository.count()).isEqualTo(nodeIdCount);
runMigration();
assertThat(addressBookEntryRepository.findAll()).isNotEmpty().hasSize(nodeIdCount).extracting(AddressBookEntry::getId).extracting(AddressBookEntry.Id::getNodeId).containsExactlyInAnyOrder(0L, 1L, 2L);
assertThat(addressBookServiceEndpointRepository.findAll()).isEmpty();
}
use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.
the class NetworkServiceTest method moreThanPageSize.
@Test
void moreThanPageSize() {
addressBookProperties.setPageSize(2);
AddressBook addressBook = addressBook();
AddressBookEntry addressBookEntry1 = addressBookEntry();
AddressBookEntry addressBookEntry2 = addressBookEntry();
AddressBookEntry addressBookEntry3 = addressBookEntry();
AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
assertThat(getNodes(filter)).containsExactly(addressBookEntry1, addressBookEntry2, addressBookEntry3);
}
use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry 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);
}
use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry 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);
}
use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.
the class AddressBookServiceImpl method retrieveNodeAddressesFromAddressBook.
/**
* Extracts a collection of AddressBookEntry domain objects from NodeAddressBook proto. Sets provided
* consensusTimestamp as the consensusTimestamp of each address book entry to ensure mapping to a single
* AddressBook
*
* @param nodeAddressBook node address book proto
* @param consensusTimestamp transaction consensusTimestamp
* @return
*/
private static Collection<AddressBookEntry> retrieveNodeAddressesFromAddressBook(NodeAddressBook nodeAddressBook, long consensusTimestamp) throws UnknownHostException {
// node id to entry
Map<Long, AddressBookEntry> addressBookEntries = new LinkedHashMap<>();
for (NodeAddress nodeAddressProto : nodeAddressBook.getNodeAddressList()) {
Pair<Long, EntityId> nodeIds = getNodeIds(nodeAddressProto);
AddressBookEntry addressBookEntry = addressBookEntries.computeIfAbsent(nodeIds.getLeft(), k -> getAddressBookEntry(nodeAddressProto, consensusTimestamp, nodeIds));
Set<AddressBookServiceEndpoint> updatedList = new HashSet<>(addressBookEntry.getServiceEndpoints());
updatedList.addAll(getAddressBookServiceEndpoints(nodeAddressProto, consensusTimestamp));
addressBookEntry.setServiceEndpoints(updatedList);
}
return addressBookEntries.values();
}
Aggregations