Search in sources :

Example 1 with AddressBookEntry

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

the class AddressBookEntryRepositoryTest method save.

@Test
void save() {
    addressBookRepository.save(addressBook(null, 1L, Collections.emptyList()));
    AddressBookEntry addressBookEntry = addressBookEntryRepository.save(addressBookEntry(null, 1L, 3));
    assertThat(addressBookEntryRepository.findById(addressBookEntry.getId())).get().isEqualTo(addressBookEntry);
}
Also used : AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) Test(org.junit.jupiter.api.Test)

Example 2 with AddressBookEntry

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

the class NetworkControllerTest method limitReached.

@Test
void limitReached() {
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry1 = addressBookEntry();
    addressBookEntry();
    AddressBookQuery query = AddressBookQuery.newBuilder().setFileId(FileID.newBuilder().setFileNum(addressBook.getFileId().getEntityNum()).build()).setLimit(1).build();
    reactiveService.getNodes(Mono.just(query)).as(StepVerifier::create).thenAwait(Duration.ofMillis(50)).consumeNextWith(n -> assertEntry(addressBookEntry1, n)).expectComplete().verify(Duration.ofSeconds(1L));
}
Also used : AddressBookQuery(com.hedera.mirror.api.proto.AddressBookQuery) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) StepVerifier(reactor.test.StepVerifier) GrpcIntegrationTest(com.hedera.mirror.grpc.GrpcIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with AddressBookEntry

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

the class DomainBuilder method addressBookEntry.

public DomainWrapper<AddressBookEntry, AddressBookEntry.AddressBookEntryBuilder> addressBookEntry(int endpoints) {
    long consensusTimestamp = timestamp();
    long nodeId = id();
    var builder = AddressBookEntry.builder().consensusTimestamp(consensusTimestamp).description(text(10)).memo(text(10)).nodeId(nodeId).nodeAccountId(EntityId.of(0L, 0L, nodeId + 3, ACCOUNT)).nodeCertHash(bytes(96)).publicKey(text(64)).stake(0L);
    var serviceEndpoints = new HashSet<AddressBookServiceEndpoint>();
    builder.serviceEndpoints(serviceEndpoints);
    for (int i = 0; i < endpoints; ++i) {
        var endpoint = addressBookServiceEndpoint().customize(a -> a.consensusTimestamp(consensusTimestamp).nodeId(nodeId)).get();
        serviceEndpoints.add(endpoint);
    }
    return new DomainWrapperImpl<>(builder, builder::build);
}
Also used : SCHEDULE(com.hedera.mirror.common.domain.entity.EntityType.SCHEDULE) EntityId(com.hedera.mirror.common.domain.entity.EntityId) NonFeeTransfer(com.hedera.mirror.common.domain.transaction.NonFeeTransfer) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) AccountBalanceFile(com.hedera.mirror.common.domain.balance.AccountBalanceFile) RequiredArgsConstructor(lombok.RequiredArgsConstructor) Autowired(org.springframework.beans.factory.annotation.Autowired) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) EntityType(com.hedera.mirror.common.domain.entity.EntityType) NodeStake(com.hedera.mirror.common.domain.addressbook.NodeStake) TransactionType(com.hedera.mirror.common.domain.transaction.TransactionType) InetAddress(java.net.InetAddress) SecureRandom(java.security.SecureRandom) AccountBalance(com.hedera.mirror.common.domain.balance.AccountBalance) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TOKEN(com.hedera.mirror.common.domain.entity.EntityType.TOKEN) NftTransfer(com.hedera.mirror.common.domain.token.NftTransfer) RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) Token(com.hedera.mirror.common.domain.token.Token) TokenId(com.hedera.mirror.common.domain.token.TokenId) ContractResult(com.hedera.mirror.common.domain.contract.ContractResult) ContractStateChange(com.hedera.mirror.common.domain.contract.ContractStateChange) TopicMessage(com.hedera.mirror.common.domain.topic.TopicMessage) Range(com.google.common.collect.Range) CryptoTransfer(com.hedera.mirror.common.domain.transaction.CryptoTransfer) CryptoAllowance(com.hedera.mirror.common.domain.entity.CryptoAllowance) TokenPauseStatusEnum(com.hedera.mirror.common.domain.token.TokenPauseStatusEnum) Instant(java.time.Instant) TINYBARS_IN_ONE_HBAR(com.hedera.mirror.common.util.DomainUtils.TINYBARS_IN_ONE_HBAR) SignaturePair(com.hederahashgraph.api.proto.java.SignaturePair) ZoneId(java.time.ZoneId) FileData(com.hedera.mirror.common.domain.file.FileData) NftAllowance(com.hedera.mirror.common.domain.entity.NftAllowance) CONTRACT(com.hedera.mirror.common.domain.entity.EntityType.CONTRACT) ByteString(com.google.protobuf.ByteString) List(java.util.List) Nft(com.hedera.mirror.common.domain.token.Nft) TransactionOperations(org.springframework.transaction.support.TransactionOperations) StakingRewardTransfer(com.hedera.mirror.common.domain.transaction.StakingRewardTransfer) LocalDate(java.time.LocalDate) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) RandomStringUtils(org.apache.commons.lang3.RandomStringUtils) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) Schedule(com.hedera.mirror.common.domain.schedule.Schedule) TOPIC(com.hedera.mirror.common.domain.entity.EntityType.TOPIC) NftId(com.hedera.mirror.common.domain.token.NftId) Contract(com.hedera.mirror.common.domain.contract.Contract) Supplier(java.util.function.Supplier) Scope(org.springframework.context.annotation.Scope) Value(lombok.Value) HashSet(java.util.HashSet) FILE(com.hedera.mirror.common.domain.entity.EntityType.FILE) TransactionSignature(com.hedera.mirror.common.domain.transaction.TransactionSignature) AccountID(com.hederahashgraph.api.proto.java.AccountID) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) DomainUtils(com.hedera.mirror.common.util.DomainUtils) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) EntityManager(javax.persistence.EntityManager) ContractLog(com.hedera.mirror.common.domain.contract.ContractLog) TokenBalance(com.hedera.mirror.common.domain.balance.TokenBalance) UnknownHostException(java.net.UnknownHostException) AddressBookServiceEndpoint(com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) Key(com.hederahashgraph.api.proto.java.Key) Component(org.springframework.stereotype.Component) Log4j2(lombok.extern.log4j.Log4j2) TokenAllowance(com.hedera.mirror.common.domain.entity.TokenAllowance) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) EthereumTransaction(com.hedera.mirror.common.domain.transaction.EthereumTransaction) TokenTransfer(com.hedera.mirror.common.domain.token.TokenTransfer) AddressBookServiceEndpoint(com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint) HashSet(java.util.HashSet)

Example 4 with AddressBookEntry

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

the class NetworkServiceTest method lessThanPageSize.

@Test
void lessThanPageSize() {
    addressBookProperties.setPageSize(2);
    AddressBook addressBook = addressBook();
    AddressBookEntry addressBookEntry = addressBookEntry();
    AddressBookFilter filter = AddressBookFilter.builder().fileId(addressBook.getFileId()).build();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry);
}
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 5 with AddressBookEntry

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

the class NetworkServiceTest method cached.

@Test
void cached() {
    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);
    addressBookEntryRepository.deleteAll();
    assertThat(getNodes(filter)).containsExactly(addressBookEntry1, addressBookEntry2, addressBookEntry3);
}
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)

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