Search in sources :

Example 6 with FileUpdateTransactionBody

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()));
}
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 7 with FileUpdateTransactionBody

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()));
}
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) 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)

Aggregations

FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)7 Transaction (com.hederahashgraph.api.proto.java.Transaction)7 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)7 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)6 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)6 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)6 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)6 Test (org.junit.jupiter.api.Test)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 AddressBook (com.hedera.mirror.common.domain.addressbook.AddressBook)2 Entity (com.hedera.mirror.common.domain.entity.Entity)2 FileID (com.hederahashgraph.api.proto.java.FileID)2 MoreObjects (com.google.common.base.MoreObjects)1 Files (com.google.common.io.Files)1 ByteString (com.google.protobuf.ByteString)1 StringValue (com.google.protobuf.StringValue)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 FeeCalculator (com.hedera.services.bdd.spec.fees.FeeCalculator)1 QueryVerbs.getFileContents (com.hedera.services.bdd.spec.queries.QueryVerbs.getFileContents)1 QueryVerbs.getFileInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getFileInfo)1