Search in sources :

Example 36 with TransactionRecord

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

the class EntityRecordItemListenerCryptoTest method cryptoCreateWithZeroInitialBalance.

@Test
void cryptoCreateWithZeroInitialBalance() {
    final long initialBalance = 0;
    CryptoCreateTransactionBody.Builder cryptoCreateBuilder = cryptoCreateAccountBuilderWithDefaults().setInitialBalance(initialBalance);
    Transaction transaction = cryptoCreateTransaction(cryptoCreateBuilder);
    TransactionBody transactionBody = getTransactionBody(transaction);
    CryptoCreateTransactionBody cryptoCreateTransactionBody = transactionBody.getCryptoCreateAccount();
    TransactionRecord record = transactionRecordSuccess(transactionBody);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    var accountEntityId = EntityId.of(accountId1);
    var consensusTimestamp = DomainUtils.timeStampInNanos(record.getConsensusTimestamp());
    var dbTransaction = getDbTransaction(record.getConsensusTimestamp());
    Optional<CryptoTransfer> initialBalanceTransfer = cryptoTransferRepository.findById(new CryptoTransfer.Id(initialBalance, consensusTimestamp, accountEntityId.getId()));
    assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(accountEntityId), () -> assertCryptoTransfers(3), () -> assertCryptoTransaction(transactionBody, record), () -> assertCryptoEntity(cryptoCreateTransactionBody, record.getConsensusTimestamp()), () -> assertEquals(cryptoCreateTransactionBody.getInitialBalance(), dbTransaction.getInitialBalance()), () -> assertThat(initialBalanceTransfer).isEmpty());
}
Also used : CryptoDeleteLiveHashTransactionBody(com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody) CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) CryptoAddLiveHashTransactionBody(com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody) CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) CryptoTransfer(com.hedera.mirror.common.domain.transaction.CryptoTransfer) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) UtilityTest(com.hedera.mirror.importer.util.UtilityTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 37 with TransactionRecord

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

the class EntityRecordItemListenerFileTest method fileUpdateKeysToExisting.

@Test
void fileUpdateKeysToExisting() {
    // first create the file
    Transaction fileCreateTransaction = fileCreateTransaction();
    TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
    TransactionRecord recordCreate = transactionRecord(createTransactionBody);
    parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
    // now update
    Transaction transaction = fileUpdateKeysTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecord(transactionBody);
    FileUpdateTransactionBody fileUpdateTransactionBody = transactionBody.getFileUpdate();
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    Entity dbFileEntity = getTransactionEntity(record.getConsensusTimestamp());
    assertAll(// TODO: Review row count of fileDataRepository with issue #294, probably should be 1
    () -> assertRowCountOnTwoFileTransactions(), () -> assertTransactionAndRecord(transactionBody, record), // Additional entity checks
    () -> assertFalse(dbFileEntity.getDeleted()), () -> assertNotNull(dbFileEntity.getExpirationTimestamp()), () -> assertArrayEquals(fileUpdateTransactionBody.getKeys().toByteArray(), dbFileEntity.getKey()), () -> assertNull(dbFileEntity.getAutoRenewPeriod()), () -> assertNull(dbFileEntity.getProxyAccountId()));
}
Also used : FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) 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 38 with TransactionRecord

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

the class EntityRecordItemListenerFileTest method fileUpdateAllToExisting.

@Test
void fileUpdateAllToExisting() {
    // first create the file
    Transaction fileCreateTransaction = fileCreateTransaction();
    TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
    TransactionRecord recordCreate = transactionRecord(createTransactionBody);
    parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
    // now update
    Transaction transaction = fileUpdateAllTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecord(transactionBody);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertRowCountOnTwoFileTransactions(), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileEntityAndData(transactionBody.getFileUpdate(), 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) 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 39 with TransactionRecord

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

the class EntityRecordItemListenerFileTest method fileAppendToAddressBook.

@Test
void fileAppendToAddressBook() throws IOException {
    entityProperties.getPersist().setFiles(true);
    entityProperties.getPersist().setSystemFiles(true);
    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);
    FileUpdateTransactionBody fileUpdateTransactionBody = transactionBodyUpdate.getFileUpdate();
    TransactionRecord recordUpdate = transactionRecord(transactionBodyUpdate, ADDRESS_BOOK_FILEID);
    // Address book append
    Transaction transactionAppend = fileAppendTransaction(ADDRESS_BOOK_FILEID, addressBookAppend);
    TransactionBody transactionBodyAppend = getTransactionBody(transactionAppend);
    FileAppendTransactionBody fileAppendTransactionBody = transactionBodyAppend.getFileAppend();
    TransactionRecord recordAppend = transactionRecord(transactionBodyAppend, ADDRESS_BOOK_FILEID);
    parseRecordItemAndCommit(new RecordItem(transactionUpdate, recordUpdate));
    parseRecordItemAndCommit(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()));
    assertAll(() -> assertRowCountOnAddressBookTransactions(), () -> assertTransactionAndRecord(transactionBodyUpdate, recordUpdate), () -> assertTransactionAndRecord(transactionBodyAppend, recordAppend), () -> assertFileData(fileAppendTransactionBody.getContents(), recordAppend.getConsensusTimestamp()), () -> assertFileData(fileUpdateTransactionBody.getContents(), recordUpdate.getConsensusTimestamp()), () -> assertAddressBookData(addressBook, recordAppend.getConsensusTimestamp()), () -> assertEquals(13 + TEST_INITIAL_ADDRESS_BOOK_NODE_COUNT, addressBookEntryRepository.count()), () -> assertEquals(2, addressBookRepository.count()), // update and append
    () -> assertEquals(2, 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) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) 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 40 with TransactionRecord

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

the class EntityRecordItemListenerFileTest method fileAppend.

@Test
void fileAppend() {
    Transaction transaction = fileAppendTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecord(transactionBody);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertRowCount(1, 3, 1), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileData(transactionBody.getFileAppend().getContents(), 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) 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

TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)107 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)86 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)84 Transaction (com.hederahashgraph.api.proto.java.Transaction)83 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)74 Test (org.junit.jupiter.api.Test)69 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)30 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)30 CryptoAddLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody)28 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)28 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)28 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)26 CryptoDeleteLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody)26 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)26 UtilityTest (com.hedera.mirror.importer.util.UtilityTest)23 ContractCallTransactionBody (com.hederahashgraph.api.proto.java.ContractCallTransactionBody)19 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)19 ContractUpdateTransactionBody (com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody)19 Entity (com.hedera.mirror.common.domain.entity.Entity)17 EnumSource (org.junit.jupiter.params.provider.EnumSource)13