use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoTransferFailedTransactionErrata.
@Test
void cryptoTransferFailedTransactionErrata() {
entityProperties.getPersist().setCryptoTransferAmounts(true);
Transaction transaction = cryptoTransferTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = buildTransactionRecord(r -> {
for (int i = 0; i < additionalTransfers.length; i++) {
// Add non-fee transfers to record
var accountAmount = accountAmount(additionalTransfers[i], additionalTransferAmounts[i]);
r.getTransferListBuilder().addAccountAmounts(accountAmount);
}
}, transactionBody, ResponseCodeEnum.INVALID_ACCOUNT_ID.getNumber());
var recordItem = new RecordItem(transaction, record);
parseRecordItemAndCommit(recordItem);
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(), () -> assertEquals(4, cryptoTransferRepository.count(), "Node, network fee & errata"), () -> assertEquals(0, nonFeeTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), () -> {
for (int i = 0; i < additionalTransfers.length; i++) {
var id = new CryptoTransfer.Id(additionalTransferAmounts[i], recordItem.getConsensusTimestamp(), additionalTransfers[i]);
assertThat(cryptoTransferRepository.findById(id)).get().extracting(CryptoTransfer::getErrata).isEqualTo(ErrataType.DELETE);
}
});
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoDeleteLiveHash.
@Test
void cryptoDeleteLiveHash() {
Transaction transactionAddLiveHash = cryptoAddLiveHashTransaction();
parseRecordItemAndCommit(new RecordItem(transactionAddLiveHash, transactionRecordSuccess(getTransactionBody(transactionAddLiveHash))));
// now delete the live hash
Transaction transaction = cryptoDeleteLiveHashTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
CryptoDeleteLiveHashTransactionBody deleteLiveHashTransactionBody = transactionBody.getCryptoDeleteLiveHash();
TransactionRecord record = transactionRecordSuccess(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(), () -> assertCryptoTransfers(6), () -> assertEquals(1, liveHashRepository.count()), () -> assertTransactionAndRecord(transactionBody, record));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoUpdateFailedTransaction.
@Test
void cryptoUpdateFailedTransaction() {
Transaction createTransaction = cryptoCreateTransaction();
TransactionRecord createRecord = transactionRecordSuccess(getTransactionBody(createTransaction));
parseRecordItemAndCommit(new RecordItem(createTransaction, createRecord));
// now update
Transaction transaction = cryptoUpdateTransaction(accountId1);
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody, ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity dbAccountEntityBefore = getTransactionEntity(createRecord.getConsensusTimestamp());
Entity dbAccountEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(EntityId.of(accountId1)), // 3 + 3 fee transfers with one transfer per account
() -> assertCryptoTransfers(6), () -> assertTransactionAndRecord(transactionBody, record), () -> assertAccount(record.getReceipt().getAccountID(), dbAccountEntity), // no changes to entity
() -> assertEquals(dbAccountEntityBefore, dbAccountEntity));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoUpdateSuccessfulTransaction.
@Test
void cryptoUpdateSuccessfulTransaction() {
createAccount();
// now update
Transaction transaction = cryptoUpdateTransaction(accountId1);
TransactionBody transactionBody = getTransactionBody(transaction);
CryptoUpdateTransactionBody cryptoUpdateTransactionBody = transactionBody.getCryptoUpdateAccount();
TransactionRecord record = transactionRecordSuccess(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
Entity dbAccountEntity = getTransactionEntity(record.getConsensusTimestamp());
assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(EntityId.of(accountId1)), () -> assertEquals(6, cryptoTransferRepository.count()), () -> assertCryptoTransaction(transactionBody, record), // transaction body inputs
() -> assertEquals(cryptoUpdateTransactionBody.getAutoRenewPeriod().getSeconds(), dbAccountEntity.getAutoRenewPeriod()), () -> assertEquals(DomainUtils.getPublicKey(cryptoUpdateTransactionBody.getKey().toByteArray()), dbAccountEntity.getPublicKey()), () -> assertEquals(EntityId.of(cryptoUpdateTransactionBody.getProxyAccountID()), dbAccountEntity.getProxyAccountId()), () -> assertArrayEquals(cryptoUpdateTransactionBody.getKey().toByteArray(), dbAccountEntity.getKey()), () -> assertEquals(cryptoUpdateTransactionBody.getMaxAutomaticTokenAssociations().getValue(), dbAccountEntity.getMaxAutomaticTokenAssociations()), () -> assertEquals(cryptoUpdateTransactionBody.getMemo().getValue(), dbAccountEntity.getMemo()), () -> assertEquals(DomainUtils.timeStampInNanos(cryptoUpdateTransactionBody.getExpirationTime()), dbAccountEntity.getExpirationTimestamp()), () -> assertEquals(DomainUtils.timestampInNanosMax(record.getConsensusTimestamp()), dbAccountEntity.getTimestampLower()), () -> assertFalse(dbAccountEntity.getReceiverSigRequired()), () -> assertFalse(dbAccountEntity.isDeclineReward()), () -> assertEquals(cryptoUpdateTransactionBody.getStakedNodeId(), dbAccountEntity.getStakedNodeId()), () -> assertEquals(-1L, dbAccountEntity.getStakedAccountId()), () -> assertEquals(Utility.getEpochDay(DomainUtils.timestampInNanosMax(record.getConsensusTimestamp())), dbAccountEntity.getStakePeriodStart()));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoTransferPersistRawBytesDefault.
@Test
void cryptoTransferPersistRawBytesDefault() {
// Use the default properties for record parsing - the raw bytes should NOT be stored in the db
Transaction transaction = cryptoTransferTransaction();
testRawBytes(transaction, null);
}
Aggregations