Search in sources :

Example 41 with Transaction

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

the class EntityRecordItemListenerCryptoTest method cryptoAddLiveHashDoNotPersist.

@Test
void cryptoAddLiveHashDoNotPersist() {
    entityProperties.getPersist().setClaims(false);
    Transaction transaction = cryptoAddLiveHashTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecordSuccess(transactionBody);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(), () -> assertCryptoTransfers(3), () -> assertEquals(0, liveHashRepository.count()), () -> assertTransactionAndRecord(transactionBody, record));
}
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) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) 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 42 with Transaction

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

the class EntityRecordItemListenerCryptoTest method cryptoTransferWithUnknownAlias.

@ParameterizedTest
@EnumSource(value = PartialDataAction.class, names = { "DEFAULT", "SKIP" })
void cryptoTransferWithUnknownAlias(PartialDataAction partialDataAction) {
    // given
    // both accounts have alias, and only account2's alias is in db
    entityProperties.getPersist().setCryptoTransferAmounts(true);
    entityProperties.getPersist().setNonFeeTransfers(true);
    parserProperties.setPartialDataAction(partialDataAction);
    Entity account1 = domainBuilder.entity().get();
    Entity account2 = domainBuilder.entity().persist();
    // crypto transfer from unknown account1 alias to account2 alias
    Transaction transaction = buildTransaction(builder -> builder.getCryptoTransferBuilder().getTransfersBuilder().addAccountAmounts(accountAliasAmount(DomainUtils.fromBytes(account1.getAlias()), 100)).addAccountAmounts(accountAliasAmount(DomainUtils.fromBytes(account2.getAlias()), -100)));
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord transactionRecord = buildTransactionRecord(r -> r.getTransferListBuilder().addAccountAmounts(accountAmount(account1.getNum(), 100)).addAccountAmounts(accountAmount(account2.getNum(), -100)), transactionBody, ResponseCodeEnum.SUCCESS.getNumber());
    List<EntityId> expectedEntityIds = partialDataAction == PartialDataAction.DEFAULT ? Arrays.asList(account2.toEntityId(), null) : List.of(account2.toEntityId());
    // when
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    // then
    assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(5, cryptoTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, transactionRecord), () -> assertThat(findNonFeeTransfers()).extracting(NonFeeTransfer::getEntityId).containsExactlyInAnyOrderElementsOf(expectedEntityIds));
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Entity(com.hedera.mirror.common.domain.entity.Entity) 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) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) NonFeeTransfer(com.hedera.mirror.common.domain.transaction.NonFeeTransfer) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 43 with Transaction

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

the class EntityRecordItemListenerCryptoTest method cryptoTransferWithUnknownAliasActionError.

@Test
void cryptoTransferWithUnknownAliasActionError() {
    // given
    // both accounts have alias, and only account2's alias is in db
    entityProperties.getPersist().setCryptoTransferAmounts(true);
    entityProperties.getPersist().setNonFeeTransfers(true);
    parserProperties.setPartialDataAction(PartialDataAction.ERROR);
    Entity account1 = domainBuilder.entity().get();
    Entity account2 = domainBuilder.entity().persist();
    // crypto transfer from unknown account1 alias to account2 alias
    Transaction transaction = buildTransaction(builder -> builder.getCryptoTransferBuilder().getTransfersBuilder().addAccountAmounts(accountAliasAmount(DomainUtils.fromBytes(account1.getAlias()), 100)).addAccountAmounts(accountAliasAmount(DomainUtils.fromBytes(account2.getAlias()), -100)));
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord transactionRecord = buildTransactionRecord(r -> r.getTransferListBuilder().addAccountAmounts(accountAmount(account1.getNum(), 100)).addAccountAmounts(accountAmount(account2.getNum(), -100)), transactionBody, ResponseCodeEnum.SUCCESS.getNumber());
    // when, then
    assertThrows(AliasNotFoundException.class, () -> parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord)));
    assertAll(() -> assertEquals(0, transactionRepository.count()), () -> assertEquals(0, cryptoTransferRepository.count()), () -> assertThat(findNonFeeTransfers()).isEmpty());
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) 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) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) 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 44 with Transaction

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

the class EntityRecordItemListenerCryptoTest method createAccount.

private void createAccount() {
    Transaction createTransaction = cryptoCreateTransaction();
    TransactionBody createTransactionBody = getTransactionBody(createTransaction);
    TransactionRecord createRecord = transactionRecordSuccess(createTransactionBody);
    parseRecordItemAndCommit(new RecordItem(createTransaction, createRecord));
}
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) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 45 with Transaction

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

the class EntityRecordItemListenerCryptoTest method unknownTransactionResult.

@Test
void unknownTransactionResult() {
    int unknownResult = -1000;
    Transaction transaction = cryptoCreateTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecord(transactionBody, unknownResult);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertThat(transactionRepository.findAll()).hasSize(1).extracting(com.hedera.mirror.common.domain.transaction.Transaction::getResult).containsOnly(unknownResult);
}
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) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) 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)

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