use of com.hederahashgraph.api.proto.java.NodeAddress in project hedera-mirror-node by hashgraph.
the class AddressBookServiceImplTest method verifyAddressBookWithDeprecatedIpAndServiceEndpoints.
@Test
void verifyAddressBookWithDeprecatedIpAndServiceEndpoints() throws UnknownHostException {
List<NodeAddress> nodeAddressList = new ArrayList<>();
int nodeAccountStart = 3;
int addressBookEntries = 5;
// deprecated ip + service endpoints
int numEndpointsPerNode = 5;
for (int i = nodeAccountStart; i < addressBookEntries + nodeAccountStart; i++) {
nodeAddressList.add(getNodeAddress(i, baseAccountId + i, String.format("127.0.%d.0", i), List.of(String.format("127.0.%d.1", i), String.format("127.0.%d.2", i), String.format("127.0.%d.3", i), String.format("127.0.%d.4", i))));
}
NodeAddressBook.Builder nodeAddressBookBuilder = NodeAddressBook.newBuilder().addAllNodeAddress(nodeAddressList);
byte[] addressBookBytes = nodeAddressBookBuilder.build().toByteArray();
update(addressBookBytes, 2L, true);
assertArrayEquals(addressBookBytes, addressBookService.getCurrent().getFileData());
// bootstrap and new address book with service endpoints
assertEquals(2, addressBookRepository.count());
assertEquals(TEST_INITIAL_ADDRESS_BOOK_NODE_COUNT + addressBookEntries, addressBookEntryRepository.count());
assertEquals(addressBookEntries * numEndpointsPerNode, addressBookServiceEndpointRepository.count());
}
use of com.hederahashgraph.api.proto.java.NodeAddress 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();
}
use of com.hederahashgraph.api.proto.java.NodeAddress 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));
}
Aggregations