use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class ProtoBalanceFileReaderTest method getExpectedAccountBalanceFile.
private AccountBalanceFile getExpectedAccountBalanceFile(StreamFileData streamFileData) {
Instant instant = Instant.parse(TIMESTAMP.replace("_", ":"));
long consensusTimestamp = DomainUtils.convertToNanosMax(instant);
long accountNum = 2000;
long hbarBalance = 3000;
long tokenNum = 5000;
long tokenBalance = 6000;
List<AccountBalance> accountBalances = IntStream.range(0, 10).mapToObj(i -> {
EntityId accountId = EntityId.of(0, 0, accountNum + i, EntityType.ACCOUNT);
List<TokenBalance> tokenBalances = IntStream.range(0, 5).mapToObj(j -> {
EntityId tokenId = EntityId.of(0, 0, tokenNum + i * 5 + j, EntityType.TOKEN);
return new TokenBalance(tokenBalance + i * 5 + j, new TokenBalance.Id(consensusTimestamp, accountId, tokenId));
}).collect(Collectors.toList());
return new AccountBalance(hbarBalance + i, tokenBalances, new AccountBalance.Id(consensusTimestamp, accountId));
}).collect(Collectors.toList());
return AccountBalanceFile.builder().bytes(streamFileData.getBytes()).consensusTimestamp(consensusTimestamp).fileHash("67c2fd054621366dd5a37b6ee36a51bc590361379d539fdac2265af08cb8097729218c7d9ff1f1e354c85b820c5b8cf8").items(Flux.fromIterable(accountBalances)).name(streamFileData.getFilename()).build();
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class BalanceReconciliationServiceTest method tokenTransfer.
private void tokenTransfer(long accountNum, long tokenNum, long amount) {
long timestamp = domainBuilder.timestamp();
EntityId accountId = EntityId.of(accountNum, EntityType.ACCOUNT);
EntityId tokenId = EntityId.of(tokenNum, EntityType.TOKEN);
domainBuilder.tokenTransfer().customize(c -> c.amount(amount).id(new TokenTransfer.Id(timestamp, tokenId, accountId))).persist();
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class NftRepositoryTest method updateAccountId.
@Test
void updateAccountId() {
Nft savedNft = nftRepository.save(nft("0.0.3", 2, 2));
EntityId accountId = EntityId.of("0.0.10", EntityType.ACCOUNT);
nftRepository.transferNftOwnership(savedNft.getId(), accountId, 3L);
savedNft.setAccountId(accountId);
savedNft.setModifiedTimestamp(3L);
assertThat(nftRepository.findById(savedNft.getId())).contains(savedNft);
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class NftRepositoryTest method updateTreasury.
@Test
void updateTreasury() {
long consensusTimestamp = 6L;
EntityId newAccountId = EntityId.of("0.0.2", EntityType.ACCOUNT);
Nft nft1 = nft("0.0.100", 1, 1);
Nft nft2 = nft("0.0.100", 2, 2);
Nft nft3 = nft("0.0.100", 3, 3);
// Not updated since wrong token
Nft nft4 = nft("0.0.101", 1, 4);
// Not updated since wrong account
Nft nft5 = nft("0.0.100", 4, 5);
nft5.setAccountId(newAccountId);
nftRepository.saveAll(List.of(nft1, nft2, nft3, nft4, nft5));
EntityId tokenId = nft1.getId().getTokenId();
EntityId previousAccountId = nft1.getAccountId();
nftRepository.updateTreasury(tokenId.getId(), previousAccountId.getId(), newAccountId.getId(), consensusTimestamp, EntityId.of("0.0.200", EntityType.ACCOUNT).getId(), false);
assertAccountUpdated(nft1, newAccountId);
assertAccountUpdated(nft2, newAccountId);
assertAccountUpdated(nft3, newAccountId);
assertThat(nftRepository.findById(nft4.getId())).get().isEqualTo(nft4);
assertThat(nftRepository.findById(nft5.getId())).get().isEqualTo(nft5);
IterableAssert<NftTransfer> nftTransfers = assertThat(nftTransferRepository.findAll()).hasSize(3);
nftTransfers.extracting(NftTransfer::getReceiverAccountId).containsOnly(newAccountId);
nftTransfers.extracting(NftTransfer::getSenderAccountId).containsOnly(previousAccountId);
nftTransfers.extracting(n -> n.getId().getTokenId()).containsOnly(tokenId);
nftTransfers.extracting(n -> n.getId().getConsensusTimestamp()).containsOnly(consensusTimestamp);
nftTransfers.extracting(n -> n.getId().getSerialNumber()).containsExactlyInAnyOrder(1L, 2L, 3L);
nftTransfers.extracting(NftTransfer::getIsApproval).containsExactlyInAnyOrder(false, false, false);
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionHandlerTest method updateTransactionSuccessful.
@Test
void updateTransactionSuccessful() {
RecordItem recordItem = recordItemBuilder.tokenUpdate().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(any(AccountID.class))).thenReturn(EntityIdEndec.decode(10, EntityType.ACCOUNT));
transactionHandler.updateTransaction(transaction, recordItem);
assertTokenUpdate(timestamp, tokenId, id -> assertEquals(10L, id));
}
Aggregations