use of com.hederahashgraph.api.proto.java.FileUpdateTransactionBody 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.FileUpdateTransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method fileUpdateAddressBookPartial.
@Test
void fileUpdateAddressBookPartial() throws IOException {
byte[] largeAddressBook = FileUtils.readFileToByteArray(addressBookLarge);
byte[] addressBookUpdate = Arrays.copyOf(largeAddressBook, largeAddressBook.length / 2);
Transaction transaction = fileUpdateAllTransaction(ADDRESS_BOOK_FILEID, addressBookUpdate);
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));
addressBookService.getCurrent();
assertAll(() -> assertRowCountOnSuccess(ADDRESS_BOOK_FILEID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityAndData(fileUpdateTransactionBody, record.getConsensusTimestamp()), () -> assertEquals(1, addressBookRepository.count()), () -> assertEquals(TEST_INITIAL_ADDRESS_BOOK_NODE_COUNT, addressBookEntryRepository.count()), () -> assertEquals(1, fileDataRepository.count()));
}
Aggregations