use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoApproveAllowance.
@Test
void cryptoApproveAllowance() {
// given
var consensusTimestamp = recordItemBuilder.timestamp();
List<Nft> expectedNfts = new LinkedList<>();
var nftAllowances = customizeNftAllowances(consensusTimestamp, expectedNfts);
RecordItem recordItem = recordItemBuilder.cryptoApproveAllowance().transactionBody(b -> b.clearNftAllowances().addAllNftAllowances(nftAllowances)).record(r -> r.setConsensusTimestamp(consensusTimestamp)).build();
// when
parseRecordItemAndCommit(recordItem);
// then
assertAllowances(recordItem, expectedNfts);
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateKeysToExisting.
@Test
void fileUpdateKeysToExisting() {
// first create the file
Transaction fileCreateTransaction = fileCreateTransaction();
TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
TransactionRecord recordCreate = transactionRecord(createTransactionBody);
parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
// now update
Transaction transaction = fileUpdateKeysTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody);
FileUpdateTransactionBody fileUpdateTransactionBody = transactionBody.getFileUpdate();
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity dbFileEntity = 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(dbFileEntity.getDeleted()), () -> assertNotNull(dbFileEntity.getExpirationTimestamp()), () -> assertArrayEquals(fileUpdateTransactionBody.getKeys().toByteArray(), dbFileEntity.getKey()), () -> assertNull(dbFileEntity.getAutoRenewPeriod()), () -> assertNull(dbFileEntity.getProxyAccountId()));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateAllToExisting.
@Test
void fileUpdateAllToExisting() {
// first create the file
Transaction fileCreateTransaction = fileCreateTransaction();
TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
TransactionRecord recordCreate = transactionRecord(createTransactionBody);
parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
// now update
Transaction transaction = fileUpdateAllTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertRowCountOnTwoFileTransactions(), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityAndData(transactionBody.getFileUpdate(), record.getConsensusTimestamp()));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileAppendToAddressBook.
@Test
void fileAppendToAddressBook() throws IOException {
entityProperties.getPersist().setFiles(true);
entityProperties.getPersist().setSystemFiles(true);
byte[] addressBook = FileUtils.readFileToByteArray(addressBookLarge);
byte[] addressBookUpdate = Arrays.copyOf(addressBook, 6144);
byte[] addressBookAppend = Arrays.copyOfRange(addressBook, 6144, addressBook.length);
// Initial address book update
Transaction transactionUpdate = fileUpdateAllTransaction(ADDRESS_BOOK_FILEID, addressBookUpdate);
TransactionBody transactionBodyUpdate = getTransactionBody(transactionUpdate);
FileUpdateTransactionBody fileUpdateTransactionBody = transactionBodyUpdate.getFileUpdate();
TransactionRecord recordUpdate = transactionRecord(transactionBodyUpdate, ADDRESS_BOOK_FILEID);
// Address book append
Transaction transactionAppend = fileAppendTransaction(ADDRESS_BOOK_FILEID, addressBookAppend);
TransactionBody transactionBodyAppend = getTransactionBody(transactionAppend);
FileAppendTransactionBody fileAppendTransactionBody = transactionBodyAppend.getFileAppend();
TransactionRecord recordAppend = transactionRecord(transactionBodyAppend, ADDRESS_BOOK_FILEID);
parseRecordItemAndCommit(new RecordItem(transactionUpdate, recordUpdate));
parseRecordItemAndCommit(new RecordItem(transactionAppend, recordAppend));
// verify current address book is updated
AddressBook newAddressBook = addressBookService.getCurrent();
assertAll(() -> assertThat(newAddressBook.getStartConsensusTimestamp()).isEqualTo(DomainUtils.timeStampInNanos(recordAppend.getConsensusTimestamp()) + 1), () -> assertThat(newAddressBook.getEntries()).describedAs("Should overwrite address book with new update").hasSize(13), () -> assertArrayEquals(addressBook, newAddressBook.getFileData()));
assertAll(() -> assertRowCountOnAddressBookTransactions(), () -> assertTransactionAndRecord(transactionBodyUpdate, recordUpdate), () -> assertTransactionAndRecord(transactionBodyAppend, recordAppend), () -> assertFileData(fileAppendTransactionBody.getContents(), recordAppend.getConsensusTimestamp()), () -> assertFileData(fileUpdateTransactionBody.getContents(), recordUpdate.getConsensusTimestamp()), () -> assertAddressBookData(addressBook, recordAppend.getConsensusTimestamp()), () -> assertEquals(13 + TEST_INITIAL_ADDRESS_BOOK_NODE_COUNT, addressBookEntryRepository.count()), () -> assertEquals(2, addressBookRepository.count()), // update and append
() -> assertEquals(2, fileDataRepository.count()));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileAppend.
@Test
void fileAppend() {
Transaction transaction = fileAppendTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertRowCount(1, 3, 1), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileData(transactionBody.getFileAppend().getContents(), record.getConsensusTimestamp()));
}
Aggregations