Search in sources :

Example 41 with AddressBook

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());
}
Also used : AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) Test(org.junit.jupiter.api.Test)

Example 42 with AddressBook

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()));
}
Also used : FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 43 with AddressBook

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());
}
Also used : AddressBook(com.hedera.mirror.common.domain.addressbook.AddressBook)

Aggregations

AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)43 Test (org.junit.jupiter.api.Test)33 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)17 NodeAddressBook (com.hederahashgraph.api.proto.java.NodeAddressBook)17 AddressBookEntry (com.hedera.mirror.common.domain.addressbook.AddressBookEntry)12 GrpcIntegrationTest (com.hedera.mirror.grpc.GrpcIntegrationTest)11 ServiceEndpoint (com.hederahashgraph.api.proto.java.ServiceEndpoint)10 AddressBookServiceEndpoint (com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint)9 EntityId (com.hedera.mirror.common.domain.entity.EntityId)6 AddressBookFilter (com.hedera.mirror.grpc.domain.AddressBookFilter)6 Resource (javax.annotation.Resource)5 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 ByteString (com.google.protobuf.ByteString)4 DomainBuilder (com.hedera.mirror.common.domain.DomainBuilder)4 NodeAddress (com.hederahashgraph.api.proto.java.NodeAddress)4 StepVerifier (reactor.test.StepVerifier)4 AddressBookQuery (com.hedera.mirror.api.proto.AddressBookQuery)3 EntityType (com.hedera.mirror.common.domain.entity.EntityType)3 SignatureVerificationException (com.hedera.mirror.importer.exception.SignatureVerificationException)3