use of com.hedera.mirror.common.domain.transaction.RecordItem 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));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem 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()));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem 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());
}
use of com.hedera.mirror.common.domain.transaction.RecordItem 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));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractCreateWithEvmAddress.
@Test
void contractCreateWithEvmAddress() {
// no child tx, creates a single contract with evm address set
byte[] evmAddress = domainBuilder.evmAddress();
RecordItem recordItem = recordItemBuilder.contractCreate(CONTRACT_ID).transactionBody(t -> t.setDeclineReward(false).setStakedNodeId(1L)).record(r -> r.setContractCreateResult(r.getContractCreateResultBuilder().clearCreatedContractIDs().addCreatedContractIDs(CONTRACT_ID).setEvmAddress(BytesValue.of(DomainUtils.fromBytes(evmAddress))))).hapiVersion(RecordFile.HAPI_VERSION_0_23_0).build();
var record = recordItem.getRecord();
var transactionBody = recordItem.getTransactionBody().getContractCreateInstance();
parseRecordItemAndCommit(recordItem);
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(1, contractRepository.count()), () -> assertEquals(0, entityRepository.count()), () -> assertEquals(1, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertContractEntity(recordItem), () -> assertThat(contractResultRepository.findAll()).hasSize(1), () -> assertContractCreateResult(transactionBody, record));
}
Aggregations