Search in sources :

Example 26 with AddressBookEntry

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

the class AddressBookServiceEndpointRepositoryTest method addressBookEntry.

private AddressBookEntry addressBookEntry(long consensusTimestamp, long nodeAccountId, List<Integer> portNums) throws UnknownHostException {
    long nodeId = nodeAccountId - 3;
    String nodeAccountIdString = String.format("0.0.%s", nodeAccountId);
    EntityId nodeAccountEntityId = EntityId.of(nodeAccountIdString, EntityType.ACCOUNT);
    AddressBookEntry.AddressBookEntryBuilder builder = AddressBookEntry.builder().consensusTimestamp(consensusTimestamp).memo(nodeAccountIdString).nodeAccountId(nodeAccountEntityId).nodeCertHash("nodeCertHash".getBytes()).nodeId(nodeId).publicKey("rsa+public/key");
    if (!CollectionUtils.isEmpty(portNums)) {
        Set<AddressBookServiceEndpoint> serviceEndpoints = new HashSet<>();
        for (int i = 0; i < portNums.size(); i++) {
            serviceEndpoints.add(addressBookServiceEndpoint(consensusTimestamp, InetAddress.getByName("127.0.0." + i).getHostAddress(), portNums.get(i), nodeId));
        }
        builder.serviceEndpoints(serviceEndpoints);
    }
    return builder.build();
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) AddressBookServiceEndpoint(com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) AddressBookServiceEndpoint(com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint) HashSet(java.util.HashSet)

Aggregations

AddressBookEntry (com.hedera.mirror.common.domain.addressbook.AddressBookEntry)26 Test (org.junit.jupiter.api.Test)18 AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)12 AddressBookServiceEndpoint (com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint)11 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)10 EntityId (com.hedera.mirror.common.domain.entity.EntityId)6 AddressBookFilter (com.hedera.mirror.grpc.domain.AddressBookFilter)6 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)6 NodeAddress (com.hederahashgraph.api.proto.java.NodeAddress)6 ByteString (com.google.protobuf.ByteString)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 AddressBookQuery (com.hedera.mirror.api.proto.AddressBookQuery)3 Log4j2 (lombok.extern.log4j.Log4j2)3 ReactorNetworkServiceGrpc (com.hedera.mirror.api.proto.ReactorNetworkServiceGrpc)2 DomainBuilder (com.hedera.mirror.common.domain.DomainBuilder)2 EntityType (com.hedera.mirror.common.domain.entity.EntityType)2 ProtoUtil (com.hedera.mirror.grpc.util.ProtoUtil)2 FileID (com.hederahashgraph.api.proto.java.FileID)2 ServiceEndpoint (com.hederahashgraph.api.proto.java.ServiceEndpoint)2 Status (io.grpc.Status)2