use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateKeysToNew.
@Test
void fileUpdateKeysToNew() {
Transaction transaction = fileUpdateKeysTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
FileUpdateTransactionBody fileUpdateTransactionBody = transactionBody.getFileUpdate();
TransactionRecord record = transactionRecord(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity dbFileEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(// TODO: Review row count in fileDataRepository with issue #294, probably should be 0
() -> assertRowCountOnSuccess(FILE_ID), () -> assertTransactionAndRecord(transactionBody, record), // Additional entity checks
() -> assertFalse(dbFileEntity.getDeleted()), () -> assertNull(dbFileEntity.getExpirationTimestamp()), () -> assertArrayEquals(fileUpdateTransactionBody.getKeys().toByteArray(), dbFileEntity.getKey()), () -> assertNull(dbFileEntity.getAutoRenewPeriod()), () -> assertNull(dbFileEntity.getProxyAccountId()));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileCreatePersistSystemPositive.
@Test
void fileCreatePersistSystemPositive() {
entityProperties.getPersist().setFiles(false);
Transaction transaction = fileCreateTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
FileID fileID = FileID.newBuilder().setShardNum(0).setRealmNum(0).setFileNum(10).build();
TransactionRecord record = transactionRecord(transactionBody, fileID);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertRowCountOnSuccess(fileID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityAndData(transactionBody.getFileCreate(), record.getConsensusTimestamp()));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateAllToNewSystem.
@Test
void fileUpdateAllToNewSystem() {
FileID fileID = FileID.newBuilder().setShardNum(0).setRealmNum(0).setFileNum(10).build();
Transaction transaction = fileUpdateAllTransaction(fileID, FILE_CONTENTS);
TransactionBody transactionBody = getTransactionBody(transaction);
FileUpdateTransactionBody fileUpdateTransactionBody = transactionBody.getFileUpdate();
TransactionRecord record = transactionRecord(transactionBody, fileID);
entityProperties.getPersist().setFiles(true);
entityProperties.getPersist().setSystemFiles(true);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertRowCountOnSuccess(fileID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityAndData(fileUpdateTransactionBody, record.getConsensusTimestamp()));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileAppendToAddressBookInSingleRecordFile.
@Test
void fileAppendToAddressBookInSingleRecordFile() throws IOException {
entityProperties.getPersist().setFiles(true);
entityProperties.getPersist().setSystemFiles(true);
byte[] addressBookCreate = Arrays.copyOf(FileUtils.readFileToByteArray(addressBookSmall), 6144);
// Initial address book create
Transaction transactionCreate = fileUpdateAllTransaction(ADDRESS_BOOK_FILEID, addressBookCreate);
TransactionBody transactionBodyCreate = getTransactionBody(transactionCreate);
TransactionRecord recordCreate = transactionRecord(transactionBodyCreate, ADDRESS_BOOK_FILEID);
parseRecordItemAndCommit(new RecordItem(transactionCreate, recordCreate));
assertAll(() -> assertEquals(TEST_INITIAL_ADDRESS_BOOK_NODE_COUNT, addressBookEntryRepository.count()), () -> assertEquals(1, addressBookRepository.count()), // update and append
() -> assertEquals(1, fileDataRepository.count()));
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);
TransactionRecord recordUpdate = transactionRecord(transactionBodyUpdate, ADDRESS_BOOK_FILEID);
// Address book append
Transaction transactionAppend = fileAppendTransaction(ADDRESS_BOOK_FILEID, addressBookAppend);
TransactionBody transactionBodyAppend = getTransactionBody(transactionAppend);
TransactionRecord recordAppend = transactionRecord(transactionBodyAppend, ADDRESS_BOOK_FILEID);
parseRecordItemsAndCommit(List.of(new RecordItem(transactionUpdate, recordUpdate), 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()), () -> assertAddressBookData(addressBook, recordAppend.getConsensusTimestamp()), () -> assertEquals(13 + TEST_INITIAL_ADDRESS_BOOK_NODE_COUNT, addressBookEntryRepository.count()), () -> assertEquals(2, addressBookRepository.count()), // update and append
() -> assertEquals(3, fileDataRepository.count()));
}
use of com.hederahashgraph.api.proto.java.TransactionRecord in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileSystemUnDeleteFailedTransaction.
@Test
void fileSystemUnDeleteFailedTransaction() {
Transaction systemUndeleteTransaction = systemUnDeleteTransaction();
TransactionBody transactionBody = getTransactionBody(systemUndeleteTransaction);
TransactionRecord record = transactionRecord(transactionBody, ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE);
parseRecordItemAndCommit(new RecordItem(systemUndeleteTransaction, record));
assertFailedFileTransaction(transactionBody, record);
}
Aggregations