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