use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.
the class AddressBookServiceImplTest method assertAddressBook.
private void assertAddressBook(AddressBook actual, NodeAddressBook expected) {
ListAssert<AddressBookEntry> listAssert = assertThat(actual.getEntries()).hasSize(expected.getNodeAddressCount());
for (NodeAddress nodeAddress : expected.getNodeAddressList()) {
listAssert.anySatisfy(abe -> {
assertThat(abe.getMemo()).isEqualTo(nodeAddress.getMemo().toStringUtf8());
assertThat(abe.getNodeAccountId()).isEqualTo(EntityId.of(nodeAddress.getNodeAccountId()));
assertThat(abe.getNodeCertHash()).isEqualTo(nodeAddress.getNodeCertHash().toByteArray());
assertThat(abe.getPublicKey()).isEqualTo(nodeAddress.getRSAPubKey());
assertThat(abe.getNodeId()).isEqualTo(nodeAddress.getNodeId());
assertAddressBookEndPoints(abe.getServiceEndpoints(), nodeAddress.getServiceEndpointList());
});
}
}
use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.
the class AddressBookServiceImplTest method verifyAddressBookEntriesWithNodeIdAndPortNotSet.
@Test
void verifyAddressBookEntriesWithNodeIdAndPortNotSet() {
Map<String, Integer> memoToNodeIdMap = Map.of("0.0.3", 0, "0.0.4", 1);
String[] accountIds = memoToNodeIdMap.keySet().stream().sorted().toArray(String[]::new);
// nodeId 0, port 0
NodeAddress nodeAddress1 = NodeAddress.newBuilder().setIpAddress(ByteString.copyFromUtf8("127.0.0.1")).setMemo(ByteString.copyFromUtf8(accountIds[0])).setNodeAccountId(AccountID.newBuilder().setAccountNum(3)).setNodeCertHash(ByteString.copyFromUtf8("nodeCertHash")).setRSAPubKey("rsa+public/key").build();
// nodeId 0, port 50211
NodeAddress nodeAddress2 = NodeAddress.newBuilder(nodeAddress1).setIpAddress(ByteString.copyFromUtf8("127.0.0.2")).setMemo(ByteString.copyFromUtf8(accountIds[1])).setNodeAccountId(AccountID.newBuilder().setAccountNum(4)).setPortno(50211).build();
NodeAddressBook nodeAddressBook = NodeAddressBook.newBuilder().addAllNodeAddress(List.of(nodeAddress1, nodeAddress2)).build();
byte[] addressBookBytes = nodeAddressBook.toByteArray();
long addressBookConsensusTimeStamp = 5L;
update(addressBookBytes, addressBookConsensusTimeStamp, true);
assertAddressBookData(addressBookBytes, addressBookConsensusTimeStamp + 1);
AddressBook addressBook = addressBookService.getCurrent();
ListAssert<AddressBookEntry> listAssert = assertThat(addressBook.getEntries()).hasSize(nodeAddressBook.getNodeAddressCount());
for (NodeAddress nodeAddress : nodeAddressBook.getNodeAddressList()) {
int expectedNodeId = memoToNodeIdMap.get(nodeAddress.getMemo().toStringUtf8());
listAssert.anySatisfy(abe -> {
assertThat(abe.getMemo()).isEqualTo(nodeAddress.getMemo().toStringUtf8());
assertThat(abe.getNodeAccountId()).isEqualTo(EntityId.of(nodeAddress.getNodeAccountId()));
assertThat(abe.getNodeCertHash()).isEqualTo(nodeAddress.getNodeCertHash().toByteArray());
assertThat(abe.getPublicKey()).isEqualTo(nodeAddress.getRSAPubKey());
// both entries have null node id
assertThat(abe.getNodeId()).isEqualTo(expectedNodeId);
assertAddressBookEndPoints(abe.getServiceEndpoints(), nodeAddress.getServiceEndpointList());
});
}
}
use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.
the class AbstractDownloaderTest method oneThirdConsensus.
@Test
@DisplayName("Exactly 1/3 consensus")
void oneThirdConsensus() throws Exception {
List<AddressBookEntry> entries = addressBook.getEntries().stream().limit(3).collect(Collectors.toList());
AddressBook addressBookWith3Nodes = addressBook.toBuilder().entries(entries).nodeCount(entries.size()).build();
doReturn(addressBookWith3Nodes).when(addressBookService).getCurrent();
mirrorProperties.setStartBlockNumber(null);
String nodeAccountId = entries.get(0).getNodeAccountId().toString();
log.info("Only copy node {}'s stream files and signature files for a 3-node network", nodeAccountId);
fileCopier.filterDirectories("*" + nodeAccountId).copy();
expectLastStreamFile(Instant.EPOCH);
downloader.download();
verifyForSuccess();
}
use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.
the class MissingAddressBooksMigrationTest method assertAddressBook.
private void assertAddressBook(AddressBook actual, NodeAddressBook expected) {
ListAssert<AddressBookEntry> listAssert = assertThat(actual.getEntries()).hasSize(expected.getNodeAddressCount());
for (NodeAddress nodeAddress : expected.getNodeAddressList()) {
listAssert.anySatisfy(abe -> {
assertThat(abe.getMemo()).isEqualTo(nodeAddress.getMemo().toStringUtf8());
assertThat(abe.getNodeAccountId()).isEqualTo(EntityId.of(nodeAddress.getNodeAccountId()));
assertThat(abe.getNodeCertHash()).isEqualTo(nodeAddress.getNodeCertHash().toByteArray());
assertThat(abe.getPublicKey()).isEqualTo(nodeAddress.getRSAPubKey());
assertThat(abe.getNodeId()).isEqualTo(nodeAddress.getNodeId());
});
}
}
use of com.hedera.mirror.common.domain.addressbook.AddressBookEntry in project hedera-mirror-node by hashgraph.
the class AddAddressBookServiceEndpointsMigrationTest method verifyMigrateWhenBothDeprecatedIpAndAddressBookServiceEndpointsAreSet.
@Test
void verifyMigrateWhenBothDeprecatedIpAndAddressBookServiceEndpointsAreSet() throws IOException {
long consensusTimestamp = 1;
int nodeIdCount = 3;
int endPointPerNode = 3;
int numEndPoints = nodeIdCount * (endPointPerNode + 1);
insertAddressBook(AddressBookServiceImpl.ADDRESS_BOOK_101_ENTITY_ID, consensusTimestamp, nodeIdCount);
getAndSaveAddressBookEntries(true, consensusTimestamp, nodeIdCount, endPointPerNode);
assertThat(addressBookEntryRepository.count()).isEqualTo(numEndPoints);
runMigration();
assertThat(addressBookEntryRepository.findAll()).isNotEmpty().hasSize(nodeIdCount).extracting(AddressBookEntry::getId).extracting(AddressBookEntry.Id::getNodeId).containsExactlyInAnyOrder(0L, 1L, 2L);
assertThat(addressBookServiceEndpointRepository.findAll()).isNotEmpty().hasSize(numEndPoints).extracting(AddressBookServiceEndpoint::getId).extracting(AddressBookServiceEndpoint.Id::getPort).containsExactlyInAnyOrder(443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454);
}
Aggregations