Search in sources :

Example 56 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction 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()));
}
Also used : 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 57 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction 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);
}
Also used : 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)

Example 58 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileDeleteToNew.

@Test
void fileDeleteToNew() {
    Transaction fileDeleteTransaction = fileDeleteTransaction();
    TransactionBody transactionBody = getTransactionBody(fileDeleteTransaction);
    TransactionRecord record = transactionRecord(transactionBody);
    parseRecordItemAndCommit(new RecordItem(fileDeleteTransaction, record));
    Entity fileEntity = getTransactionEntity(record.getConsensusTimestamp());
    assertAll(() -> assertRowCountOnSuccessNoData(FILE_ID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityHasNullFields(record.getConsensusTimestamp()), () -> assertTrue(fileEntity.getDeleted()));
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) 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)

Example 59 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileUpdateContentsToNew.

@Test
void fileUpdateContentsToNew() {
    Transaction transaction = fileUpdateContentsTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecord(transactionBody);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    Entity actualFile = getTransactionEntity(record.getConsensusTimestamp());
    assertAll(() -> assertRowCountOnSuccess(FILE_ID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileData(transactionBody.getFileUpdate().getContents(), record.getConsensusTimestamp()), // Additional entity checks
    () -> assertFalse(actualFile.getDeleted()), () -> assertNull(actualFile.getKey()), () -> assertNull(actualFile.getAutoRenewPeriod()), () -> assertNull(actualFile.getProxyAccountId()));
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) 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)

Example 60 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileCreatePersistSystemNegative.

@Test
void fileCreatePersistSystemNegative() {
    entityProperties.getPersist().setFiles(false);
    Transaction transaction = fileCreateTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    FileID fileID = FileID.newBuilder().setShardNum(0).setRealmNum(0).setFileNum(2000).build();
    TransactionRecord record = transactionRecord(transactionBody, fileID);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertRowCountOnSuccessNoData(fileID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntity(transactionBody.getFileCreate(), record.getConsensusTimestamp()));
}
Also used : 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) FileID(com.hederahashgraph.api.proto.java.FileID) 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

Transaction (com.hederahashgraph.api.proto.java.Transaction)174 Test (org.junit.jupiter.api.Test)128 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)108 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)93 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)91 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)84 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)63 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)28 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)28 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)28 UtilityTest (com.hedera.mirror.importer.util.UtilityTest)26 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)26 CryptoAddLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody)25 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)25 CryptoDeleteLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody)25 Entity (com.hedera.mirror.common.domain.entity.Entity)22 TokenTransferList (com.hederahashgraph.api.proto.java.TokenTransferList)21 ContractUpdateTransactionBody (com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody)18 ContractCallTransactionBody (com.hederahashgraph.api.proto.java.ContractCallTransactionBody)17 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)17