Search in sources :

Example 16 with EntityId

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

the class EntityRecordItemListenerTokenTest method assertNftInRepository.

private void assertNftInRepository(TokenID tokenID, long serialNumber, boolean present, long createdTimestamp, long modifiedTimestamp, AccountID accountId, boolean deleted) {
    EntityId accountEntityId = accountId.equals(DEFAULT_ACCOUNT_ID) ? null : EntityId.of(accountId);
    assertNftInRepository(tokenID, serialNumber, present, createdTimestamp, modifiedTimestamp, METADATA.getBytes(), accountEntityId, deleted);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId)

Example 17 with EntityId

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

the class EntityRecordItemListenerTokenTest method tokenDissociate.

@Test
void tokenDissociate() {
    createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
    Transaction dissociateTransaction = tokenDissociate(List.of(TOKEN_ID), PAYER2);
    long dissociateTimeStamp = 10L;
    insertAndParseTransaction(dissociateTimeStamp, dissociateTransaction);
    EntityId tokenId = EntityId.of(TOKEN_ID);
    EntityId accountId = EntityId.of(PAYER2);
    TokenAccount expected = new TokenAccount(tokenId, accountId, dissociateTimeStamp);
    expected.setCreatedTimestamp(ASSOCIATE_TIMESTAMP);
    expected.setAssociated(false);
    expected.setAutomaticAssociation(false);
    expected.setFreezeStatus(TokenFreezeStatusEnum.NOT_APPLICABLE);
    expected.setKycStatus(TokenKycStatusEnum.NOT_APPLICABLE);
    assertThat(latestTokenAccount(TOKEN_ID, PAYER2)).get().isEqualTo(expected);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Transaction(com.hederahashgraph.api.proto.java.Transaction) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with EntityId

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

the class AbstractEntityRecordItemListenerTest method assertRecordTransfers.

protected void assertRecordTransfers(TransactionRecord record) {
    long consensusTimestamp = DomainUtils.timeStampInNanos(record.getConsensusTimestamp());
    if (entityProperties.getPersist().isCryptoTransferAmounts()) {
        TransferList transferList = record.getTransferList();
        for (AccountAmount accountAmount : transferList.getAccountAmountsList()) {
            EntityId account = EntityId.of(accountAmount.getAccountID());
            assertThat(cryptoTransferRepository.findById(new CryptoTransfer.Id(accountAmount.getAmount(), consensusTimestamp, account.getId()))).isPresent();
        }
    } else {
        assertThat(cryptoTransferRepository.count()).isEqualTo(0L);
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) CryptoTransfer(com.hedera.mirror.common.domain.transaction.CryptoTransfer) TransferList(com.hederahashgraph.api.proto.java.TransferList) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount)

Example 19 with EntityId

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

the class ConsensusUpdateTopicTransactionHandlerTest 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.consensusUpdateTopic().transactionBody(b -> b.getAutoRenewAccountBuilder().setAlias(alias)).build();
    var topicId = EntityId.of(recordItem.getTransactionBody().getConsensusUpdateTopic().getTopicID());
    var timestamp = recordItem.getConsensusTimestamp();
    var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(topicId)).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 : TOPIC(com.hedera.mirror.common.domain.entity.EntityType.TOPIC) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) TopicID(com.hederahashgraph.api.proto.java.TopicID) PartialDataAction(com.hedera.mirror.importer.parser.PartialDataAction) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EnumSource(org.junit.jupiter.params.provider.EnumSource) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) AccountID(com.hederahashgraph.api.proto.java.AccountID) DomainUtils(com.hedera.mirror.common.util.DomainUtils) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) EntityIdEndec(com.hedera.mirror.common.domain.entity.EntityIdEndec) Range(com.google.common.collect.Range) Mockito.times(org.mockito.Mockito.times) ConsensusUpdateTopicTransactionBody(com.hederahashgraph.api.proto.java.ConsensusUpdateTopicTransactionBody) Mockito.when(org.mockito.Mockito.when) 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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Assertions(org.junit.jupiter.api.Assertions) ACCOUNT(com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT) 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 20 with EntityId

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

the class ContractCreateTransactionHandlerTest 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.contractCreate().transactionBody(b -> b.getAutoRenewAccountIdBuilder().setAlias(alias)).build();
    var contractId = EntityId.of(recordItem.getRecord().getReceipt().getContractID());
    var timestamp = recordItem.getConsensusTimestamp();
    var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(contractId)).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) BeforeEach(org.junit.jupiter.api.BeforeEach) Contract(com.hedera.mirror.common.domain.contract.Contract) PartialDataAction(com.hedera.mirror.importer.parser.PartialDataAction) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Descriptors(com.google.protobuf.Descriptors) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) EnumSource(org.junit.jupiter.params.provider.EnumSource) EthereumTransactionParser(com.hedera.mirror.importer.parser.record.ethereum.EthereumTransactionParser) Captor(org.mockito.Captor) EntityType(com.hedera.mirror.common.domain.entity.EntityType) Mockito.verifyNoInteractions(org.mockito.Mockito.verifyNoInteractions) RecordParserProperties(com.hedera.mirror.importer.parser.record.RecordParserProperties) ArgumentCaptor(org.mockito.ArgumentCaptor) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) AliasNotFoundException(com.hedera.mirror.importer.exception.AliasNotFoundException) TestUtils(com.hedera.mirror.importer.TestUtils) Mockito.doReturn(org.mockito.Mockito.doReturn) AccountID(com.hederahashgraph.api.proto.java.AccountID) Utility(com.hedera.mirror.importer.util.Utility) ContractResult(com.hedera.mirror.common.domain.contract.ContractResult) DomainUtils(com.hedera.mirror.common.util.DomainUtils) FileID(com.hederahashgraph.api.proto.java.FileID) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) 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) StandardCharsets(java.nio.charset.StandardCharsets) Mockito.verify(org.mockito.Mockito.verify) TransactionReceipt(com.hederahashgraph.api.proto.java.TransactionReceipt) CONTRACT(com.hedera.mirror.common.domain.entity.EntityType.CONTRACT) ByteString(com.google.protobuf.ByteString) Consumer(java.util.function.Consumer) Test(org.junit.jupiter.api.Test) BytesValue(com.google.protobuf.BytesValue) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) EntityProperties(com.hedera.mirror.importer.parser.record.entity.EntityProperties) Assertions(org.junit.jupiter.api.Assertions) Message(com.google.protobuf.Message) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) 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)

Aggregations

EntityId (com.hedera.mirror.common.domain.entity.EntityId)134 Test (org.junit.jupiter.api.Test)64 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)33 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)22 EntityType (com.hedera.mirror.common.domain.entity.EntityType)21 TokenAccount (com.hedera.mirror.common.domain.token.TokenAccount)21 Token (com.hedera.mirror.common.domain.token.Token)20 Entity (com.hedera.mirror.common.domain.entity.Entity)17 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)17 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)16 Assertions (org.junit.jupiter.api.Assertions)16 Contract (com.hedera.mirror.common.domain.contract.Contract)15 ACCOUNT (com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT)15 DomainUtils (com.hedera.mirror.common.util.DomainUtils)15 ByteString (com.google.protobuf.ByteString)14 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)14 AccountID (com.hederahashgraph.api.proto.java.AccountID)14 ContractID (com.hederahashgraph.api.proto.java.ContractID)14 Consumer (java.util.function.Consumer)13