Search in sources :

Example 11 with TransactionRecord

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

the class EntityRecordItemListenerContractTest method contractDeleteToNewCreate2EvmAddress.

@Test
void contractDeleteToNewCreate2EvmAddress() {
    SetupResult setupResult = setupContract(CONTRACT_ID, ContractIdType.CREATE2_EVM, false, false);
    Transaction transaction = contractDeleteTransaction(setupResult.protoContractId, false);
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.DELETE);
    RecordItem recordItem = new RecordItem(transaction, record);
    parseRecordItemAndCommit(recordItem);
    var dbTransaction = getDbTransaction(record.getConsensusTimestamp());
    assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertEntities(setupResult.contract.toEntityId()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(dbTransaction.getEntityId()).isEqualTo(setupResult.contract.toEntityId()));
}
Also used : ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) 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 12 with TransactionRecord

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

the class EntityRecordItemListenerContractTest method contractUpdateAllToNew.

@ParameterizedTest
@EnumSource(value = ContractIdType.class, names = { "PLAIN", "PARSABLE_EVM" })
void contractUpdateAllToNew(ContractIdType contractIdType) {
    SetupResult setupResult = setupContract(CONTRACT_ID, contractIdType, false, false, c -> c.obtainerId(null));
    Transaction transaction = contractUpdateAllTransaction(setupResult.protoContractId, true);
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.UPDATE);
    ContractUpdateTransactionBody contractUpdateTransactionBody = transactionBody.getContractUpdateInstance();
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(setupResult.contract.toEntityId()), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertContractEntity(contractUpdateTransactionBody, record.getConsensusTimestamp()).returns(null, Contract::getCreatedTimestamp).returns(null, // FileId is ignored on updates by HAPI
    Contract::getFileId));
}
Also used : ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) Contract(com.hedera.mirror.common.domain.contract.Contract) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with TransactionRecord

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

the class EntityRecordItemListenerContractTest method contractUpdateAllToNewCreate2EvmAddress.

@Test
void contractUpdateAllToNewCreate2EvmAddress() {
    SetupResult setupResult = setupContract(CONTRACT_ID, ContractIdType.CREATE2_EVM, false, false);
    Transaction transaction = contractUpdateAllTransaction(setupResult.protoContractId, true);
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.UPDATE);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    var dbTransaction = getDbTransaction(record.getConsensusTimestamp());
    assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(setupResult.contract.toEntityId()), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(dbTransaction.getEntityId()).isEqualTo(setupResult.contract.toEntityId()));
}
Also used : ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) 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 14 with TransactionRecord

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

the class EntityRecordItemListenerContractTest method contractDeleteToNewInvalidTransaction.

@Test
void contractDeleteToNewInvalidTransaction() {
    Transaction transaction = contractDeleteTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = getContractTransactionRecord(transactionBody, ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE, ContractTransactionType.DELETE);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertEntities(), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(transactionBody.getContractDeleteInstance().getContractID()).isNotNull());
}
Also used : ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) 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 15 with TransactionRecord

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

the class EntityRecordItemListenerContractTest method contractUpdateAllWithMemoToNew.

@Test
void contractUpdateAllWithMemoToNew() {
    Transaction transaction = contractUpdateAllTransaction(false);
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.UPDATE);
    ContractUpdateTransactionBody contractUpdateTransactionBody = transactionBody.getContractUpdateInstance();
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(EntityId.of(CONTRACT_ID)), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertContractEntity(contractUpdateTransactionBody, record.getConsensusTimestamp()).returns(null, Contract::getCreatedTimestamp).returns(null, // FileId is ignored on updates by HAPI
    Contract::getFileId));
}
Also used : ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) Contract(com.hedera.mirror.common.domain.contract.Contract) 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