use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoDeleteFailedTransaction.
@Test
void cryptoDeleteFailedTransaction() {
createAccount();
// now delete
Transaction transaction = cryptoDeleteTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody, ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE.getNumber(), recordBuilder -> groupCryptoTransfersByAccountId(recordBuilder, List.of()));
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity dbAccountEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(EntityId.of(accountId1)), // 3 + 3 fee transfers with only one transfer per account
() -> assertCryptoTransfers(6), () -> assertCryptoTransaction(transactionBody, record), () -> assertThat(dbAccountEntity).isNotNull().returns(false, Entity::getDeleted));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoTransferWithEvmAddressAlias.
@Test
void cryptoTransferWithEvmAddressAlias() {
Contract contract = domainBuilder.contract().persist();
assertThat(contractRepository.findByEvmAddress(contract.getEvmAddress())).isPresent();
entityProperties.getPersist().setNonFeeTransfers(true);
long transferAmount = 123;
var transfer1 = accountAliasAmount(DomainUtils.fromBytes(contract.getEvmAddress()), transferAmount).build();
Transaction transaction = buildTransaction(builder -> builder.getCryptoTransferBuilder().getTransfersBuilder().addAccountAmounts(transfer1));
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord transactionRecord = transactionRecordSuccess(transactionBody);
RecordItem recordItem = new RecordItem(transaction, transactionRecord);
parseRecordItemAndCommit(recordItem);
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(1, nonFeeTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, transactionRecord), () -> assertThat(findNonFeeTransfers()).allSatisfy(nonFeeTransfer -> {
assertThat(nonFeeTransfer.getEntityId()).isEqualTo(contract.toEntityId());
assertThat(nonFeeTransfer.getAmount()).isEqualTo(transferAmount);
assertThat(nonFeeTransfer.getPayerAccountId()).isEqualTo(recordItem.getPayerAccountId());
}));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateAddressBookComplete.
@Test
void fileUpdateAddressBookComplete() throws IOException {
byte[] addressBook = FileUtils.readFileToByteArray(addressBookSmall);
assertThat(addressBook).hasSizeLessThan(6144);
Transaction transaction = fileUpdateAllTransaction(ADDRESS_BOOK_FILEID, addressBook);
TransactionBody transactionBody = getTransactionBody(transaction);
FileUpdateTransactionBody fileUpdateTransactionBody = transactionBody.getFileUpdate();
TransactionRecord record = transactionRecord(transactionBody, ADDRESS_BOOK_FILEID);
entityProperties.getPersist().setFiles(true);
entityProperties.getPersist().setSystemFiles(true);
parseRecordItemAndCommit(new RecordItem(transaction, record));
// verify current address book is changed
AddressBook currentAddressBook = addressBookService.getCurrent();
assertAll(() -> assertRowCountOnSuccess(ADDRESS_BOOK_FILEID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityAndData(fileUpdateTransactionBody, record.getConsensusTimestamp()), () -> assertAddressBookData(addressBook, record.getConsensusTimestamp()), () -> assertThat(currentAddressBook.getStartConsensusTimestamp()).isEqualTo(DomainUtils.timeStampInNanos(record.getConsensusTimestamp()) + 1), () -> assertThat(currentAddressBook.getEntries()).hasSize(4), () -> assertEquals(2, addressBookRepository.count()), () -> assertEquals(TEST_INITIAL_ADDRESS_BOOK_NODE_COUNT + 4, addressBookEntryRepository.count()), () -> assertEquals(1, fileDataRepository.count()));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateExpiryToExisting.
@Test
void fileUpdateExpiryToExisting() {
// first create the file
Transaction fileCreateTransaction = fileCreateTransaction();
TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
TransactionRecord recordCreate = transactionRecord(createTransactionBody);
parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
// now update
Transaction transaction = fileUpdateExpiryTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity actualFile = getTransactionEntity(record.getConsensusTimestamp());
assertAll(// TODO: Review row count of fileDataRepository with issue #294, probably should be 1
() -> assertRowCountOnTwoFileTransactions(), () -> assertTransactionAndRecord(transactionBody, record), // Additional entity checks
() -> assertFalse(actualFile.getDeleted()), () -> assertEquals(DomainUtils.timeStampInNanos(transactionBody.getFileUpdate().getExpirationTime()), actualFile.getExpirationTimestamp()), () -> assertNotNull(actualFile.getKey()), () -> assertNull(actualFile.getAutoRenewPeriod()), () -> assertNull(actualFile.getProxyAccountId()));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileSystemDeleteTransaction.
@Test
void fileSystemDeleteTransaction() {
Transaction systemDeleteTransaction = systemDeleteTransaction();
TransactionBody transactionBody = getTransactionBody(systemDeleteTransaction);
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(systemDeleteTransaction, record));
Entity fileEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertRowCountOnSuccessNoData(FILE_ID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(fileEntity).isNotNull().extracting(Entity::getDeleted).isEqualTo(true));
}
Aggregations