use of com.hedera.mirror.common.domain.addressbook.AddressBook in project hedera-mirror-node by hashgraph.
the class AddressBookRepositoryTest method save.
@Test
void save() {
AddressBook addressBook = addressBookRepository.save(addressBook(null, 4, 4));
addressBooksMatch(addressBook, addressBookRepository.findById(addressBook.getStartConsensusTimestamp()).get());
}
use of com.hedera.mirror.common.domain.addressbook.AddressBook 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.hedera.mirror.common.domain.addressbook.AddressBook in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerFileTest method assertAddressBookData.
private void assertAddressBookData(byte[] expected, Timestamp consensusTimestamp) {
// addressBook.getStartConsensusTimestamp = transaction.consensusTimestamp + 1ns
AddressBook actualAddressBook = addressBookRepository.findById(DomainUtils.timeStampInNanos(consensusTimestamp) + 1).get();
assertArrayEquals(expected, actualAddressBook.getFileData());
}
Aggregations