Search in sources :

Example 6 with ACCOUNT

use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.

the class TokenUpdateTransactionHandlerTest method updateTransactionThrowsWithAliasNotFound.

@ParameterizedTest(name = "{0}")
@EnumSource(value = PartialDataAction.class, names = { "DEFAULT", "ERROR" })
void updateTransactionThrowsWithAliasNotFound(PartialDataAction partialDataAction) {
    // given
    recordParserProperties.setPartialDataAction(partialDataAction);
    var alias = DomainUtils.fromBytes(domainBuilder.key());
    var recordItem = recordItemBuilder.tokenUpdate().transactionBody(b -> b.getAutoRenewAccountBuilder().setAlias(alias)).build();
    var tokenId = EntityId.of(recordItem.getTransactionBody().getTokenUpdate().getToken());
    var timestamp = recordItem.getConsensusTimestamp();
    var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(tokenId)).get();
    when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", ACCOUNT));
    // when, then
    assertThrows(AliasNotFoundException.class, () -> transactionHandler.updateTransaction(transaction, recordItem));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) PartialDataAction(com.hedera.mirror.importer.parser.PartialDataAction) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EnumSource(org.junit.jupiter.params.provider.EnumSource) Duration(com.hederahashgraph.api.proto.java.Duration) NftTransfer(com.hederahashgraph.api.proto.java.NftTransfer) EntityType(com.hedera.mirror.common.domain.entity.EntityType) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) AccountID(com.hederahashgraph.api.proto.java.AccountID) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) NftRepository(com.hedera.mirror.importer.repository.NftRepository) DomainUtils(com.hedera.mirror.common.util.DomainUtils) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) TokenUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody) EntityIdEndec(com.hedera.mirror.common.domain.entity.EntityIdEndec) Range(com.google.common.collect.Range) Mockito.when(org.mockito.Mockito.when) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Mockito.verify(org.mockito.Mockito.verify) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TokenID(com.hederahashgraph.api.proto.java.TokenID) Assertions(org.junit.jupiter.api.Assertions) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with ACCOUNT

use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.

the class TokenTransferRepositoryTest method findById.

@Test
void findById() {
    EntityId tokenId = EntityId.of(0L, 1L, 20L, TOKEN);
    EntityId accountId = EntityId.of(0L, 1L, 7L, ACCOUNT);
    EntityId payerAccountId = EntityId.of(0L, 1L, 500L, ACCOUNT);
    long amount = 40L;
    TokenTransfer tokenTransfer = domainBuilder.tokenTransfer().customize(t -> t.amount(amount).id(new TokenTransfer.Id(1L, tokenId, accountId)).payerAccountId(payerAccountId).tokenDissociate(false)).get();
    tokenTransferRepository.save(tokenTransfer);
    assertThat(tokenTransferRepository.findById(tokenTransfer.getId())).get().isEqualTo(tokenTransfer);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Test(org.junit.jupiter.api.Test) EntityId(com.hedera.mirror.common.domain.entity.EntityId) TOKEN(com.hedera.mirror.common.domain.entity.EntityType.TOKEN) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) TokenTransfer(com.hedera.mirror.common.domain.token.TokenTransfer) TokenTransfer(com.hedera.mirror.common.domain.token.TokenTransfer) Test(org.junit.jupiter.api.Test)

Example 8 with ACCOUNT

use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT 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 9 with ACCOUNT

use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.

the class EntityIdServiceImplTest method storeAccountDeleted.

@Test
void storeAccountDeleted() {
    Entity account = domainBuilder.entity().customize(e -> e.deleted(true)).get();
    entityIdService.notify(account);
    assertThrows(AliasNotFoundException.class, () -> entityIdService.lookup(getProtoAccountId(account)));
}
Also used : CsvSource(org.junit.jupiter.params.provider.CsvSource) DomainUtils(com.hedera.mirror.common.util.DomainUtils) Contract(com.hedera.mirror.common.domain.contract.Contract) EntityId(com.hedera.mirror.common.domain.entity.EntityId) ContractRepository(com.hedera.mirror.importer.repository.ContractRepository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) Entity(com.hedera.mirror.common.domain.entity.Entity) CONTRACT(com.hedera.mirror.common.domain.entity.EntityType.CONTRACT) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ContractID(com.hederahashgraph.api.proto.java.ContractID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Assertions(org.junit.jupiter.api.Assertions) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) AccountID(com.hederahashgraph.api.proto.java.AccountID) InvalidDatasetException(com.hedera.mirror.importer.exception.InvalidDatasetException) Entity(com.hedera.mirror.common.domain.entity.Entity) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with ACCOUNT

use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.

the class EntityIdServiceImplTest method storeAccount.

@ParameterizedTest
@CsvSource(value = { "false", "," })
void storeAccount(Boolean deleted) {
    Entity account = domainBuilder.entity().customize(e -> e.deleted(deleted)).get();
    entityIdService.notify(account);
    assertThat(entityIdService.lookup(getProtoAccountId(account))).isEqualTo(account.toEntityId());
}
Also used : CsvSource(org.junit.jupiter.params.provider.CsvSource) DomainUtils(com.hedera.mirror.common.util.DomainUtils) Contract(com.hedera.mirror.common.domain.contract.Contract) EntityId(com.hedera.mirror.common.domain.entity.EntityId) ContractRepository(com.hedera.mirror.importer.repository.ContractRepository) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Resource(javax.annotation.Resource) Entity(com.hedera.mirror.common.domain.entity.Entity) CONTRACT(com.hedera.mirror.common.domain.entity.EntityType.CONTRACT) Test(org.junit.jupiter.api.Test) IntegrationTest(com.hedera.mirror.importer.IntegrationTest) ContractID(com.hederahashgraph.api.proto.java.ContractID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) DomainBuilder(com.hedera.mirror.common.domain.DomainBuilder) Assertions(org.junit.jupiter.api.Assertions) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) AccountID(com.hederahashgraph.api.proto.java.AccountID) InvalidDatasetException(com.hedera.mirror.importer.exception.InvalidDatasetException) Entity(com.hedera.mirror.common.domain.entity.Entity) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

EntityId (com.hedera.mirror.common.domain.entity.EntityId)17 ACCOUNT (com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT)17 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)16 Test (org.junit.jupiter.api.Test)16 Assertions (org.junit.jupiter.api.Assertions)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 EntityType (com.hedera.mirror.common.domain.entity.EntityType)13 Contract (com.hedera.mirror.common.domain.contract.Contract)12 Entity (com.hedera.mirror.common.domain.entity.Entity)12 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)12 DomainUtils (com.hedera.mirror.common.util.DomainUtils)12 AccountID (com.hederahashgraph.api.proto.java.AccountID)12 AliasNotFoundException (com.hedera.mirror.importer.exception.AliasNotFoundException)11 Consumer (java.util.function.Consumer)11 Range (com.google.common.collect.Range)9 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)9 EntityIdEndec (com.hedera.mirror.common.domain.entity.EntityIdEndec)8 CONTRACT (com.hedera.mirror.common.domain.entity.EntityType.CONTRACT)8 PartialDataAction (com.hedera.mirror.importer.parser.PartialDataAction)8 RecordParserProperties (com.hedera.mirror.importer.parser.record.RecordParserProperties)8