use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupAccountAliasDeleted.
@Test
void lookupAccountAliasDeleted() {
Entity account = domainBuilder.entity().customize(e -> e.deleted(true)).persist();
assertThrows(AliasNotFoundException.class, () -> entityIdService.lookup(getProtoAccountId(account)));
}
use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.
the class BatchUpserterTest method tokenDissociateTransfer.
@Test
void tokenDissociateTransfer() {
// given
EntityId accountId = EntityId.of("0.0.215", ACCOUNT);
EntityId accountId2 = EntityId.of("0.0.216", ACCOUNT);
Token nftClass1 = getDeletedNftClass(10L, 25L, EntityId.of("0.0.100", TOKEN));
Token nftClass2 = getDeletedNftClass(11L, 24L, EntityId.of("0.0.101", TOKEN));
EntityId tokenId1 = nftClass1.getTokenId().getTokenId();
// already deleted, result of wipe
Nft nft1 = getNft(tokenId1, accountId, 1L, 11L, 16L, true);
Nft nft2 = getNft(tokenId1, accountId, 2L, 11L, 11L, false);
Nft nft3 = getNft(tokenId1, accountId, 3L, 12L, 12L, false);
// different account
Nft nft4 = getNft(tokenId1, accountId2, 4L, 18L, 18L, false);
Nft nft5 = getNft(nftClass2.getTokenId().getTokenId(), accountId, 1L, 15L, 15L, false);
nftRepository.saveAll(List.of(nft1, nft2, nft3, nft4, nft5));
tokenRepository.saveAll(List.of(nftClass1, nftClass2));
long consensusTimestamp = 30L;
EntityId ftId = EntityId.of("0.0.217", TOKEN);
EntityId payerId = EntityId.of("0.0.2002", ACCOUNT);
TokenTransfer fungibleTokenTransfer = domainBuilder.tokenTransfer().customize(t -> t.amount(-10).id(new TokenTransfer.Id(consensusTimestamp, ftId, accountId)).isApproval(false).payerAccountId(payerId).tokenDissociate(true)).get();
TokenTransfer nonFungibleTokenTransfer = domainBuilder.tokenTransfer().customize(t -> t.amount(-2).id(new TokenTransfer.Id(consensusTimestamp, tokenId1, accountId)).isApproval(false).payerAccountId(payerId).tokenDissociate(true)).get();
List<TokenTransfer> tokenTransfers = List.of(fungibleTokenTransfer, nonFungibleTokenTransfer);
// when
persist(tokenDissociateTransferBatchUpserter, tokenTransfers);
// then
assertThat(nftRepository.findAll()).containsExactlyInAnyOrder(nft1, getNft(tokenId1, accountId, 2L, 11L, 30L, true), getNft(tokenId1, accountId, 3L, 12L, 30L, true), nft4, nft5);
NftTransfer serial2Transfer = getNftTransfer(tokenId1, accountId, 2L, consensusTimestamp);
serial2Transfer.setPayerAccountId(payerId);
NftTransfer serial3Transfer = getNftTransfer(tokenId1, accountId, 3L, consensusTimestamp);
serial3Transfer.setPayerAccountId(payerId);
assertThat(nftTransferRepository.findAll()).containsExactlyInAnyOrder(serial2Transfer, serial3Transfer);
assertThat(tokenTransferRepository.findAll()).usingElementComparatorIgnoringFields("tokenDissociate").containsOnly(fungibleTokenTransfer);
}
use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.
the class ConsensusUpdateTopicTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.
@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
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));
transactionHandler.updateTransaction(transaction, recordItem);
assertConsensusTopicUpdate(timestamp, topicId, Assertions::assertNull);
}
use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method onNftTransferMultiReceiverSingleTimestamp.
@Test
void onNftTransferMultiReceiverSingleTimestamp() {
var nftTransfer = domainBuilder.nftTransfer();
EntityId entity1 = EntityId.of("0.0.10", ACCOUNT);
EntityId entity2 = EntityId.of("0.0.11", ACCOUNT);
EntityId entity3 = EntityId.of("0.0.12", ACCOUNT);
EntityId entity4 = EntityId.of("0.0.13", ACCOUNT);
var nftTransfer1 = nftTransfer.customize(n -> n.senderAccountId(entity1).receiverAccountId(entity2)).get();
var nftTransfer2 = nftTransfer.customize(n -> n.senderAccountId(entity2).receiverAccountId(entity3)).get();
var nftTransfer3 = nftTransfer.customize(n -> n.senderAccountId(entity3).receiverAccountId(entity4)).get();
// when
sqlEntityListener.onNftTransfer(nftTransfer1);
sqlEntityListener.onNftTransfer(nftTransfer2);
sqlEntityListener.onNftTransfer(nftTransfer3);
completeFileAndCommit();
// then
var mergedNftTransfer = nftTransfer.customize(n -> n.senderAccountId(entity1).receiverAccountId(entity4)).get();
assertThat(nftTransferRepository.findAll()).containsExactlyInAnyOrder(mergedNftTransfer);
}
use of com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.
@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
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));
transactionHandler.updateTransaction(transaction, recordItem);
assertContract(contractId, timestamp, t -> assertThat(t).returns(null, Contract::getAutoRenewAccountId).returns(null, Contract::getEvmAddress).satisfies(c -> assertThat(c.getFileId().getId()).isPositive()).returns(null, Contract::getInitcode));
}
Aggregations