use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractUpdateAllToExisting.
@ParameterizedTest
@EnumSource(ContractIdType.class)
void contractUpdateAllToExisting(ContractIdType contractIdType) {
// first create the contract
SetupResult setupResult = setupContract(CONTRACT_ID, contractIdType, true, true, c -> c.obtainerId(null));
Contract contract = setupResult.contract;
// now update
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(contract.getCreatedTimestamp(), Contract::getCreatedTimestamp).returns(contract.getFileId(), // 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 contractCreate.
@Test
void contractCreate() {
RecordItem recordItem = recordItemBuilder.contractCreate().build();
var record = recordItem.getRecord();
var transactionBody = recordItem.getTransactionBody().getContractCreateInstance();
parseRecordItemAndCommit(recordItem);
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(2, contractRepository.count()), () -> assertEquals(0, entityRepository.count()), () -> assertEquals(1, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertContractEntity(recordItem), () -> assertThat(contractResultRepository.findAll()).hasSize(1), () -> assertContractCreateResult(transactionBody, record));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTopicTest method updateTopicTest.
@ParameterizedTest
@CsvSource({ "0.0.1300, 10, 20, admin-key, submit-key, memo, 11, 21, updated-admin-key, updated-submit-key, " + "updated-memo, 4000000, 1, 30", "0.0.1301, 10, 20, admin-key, submit-key, memo, 11, 21, '', '', '', 4000001, 1, 30", "0.0.1302, 0, 0, '', '', '', 11, 21, updated-admin-key, updated-submit-key, updated-memo, 4000002, ," })
void updateTopicTest(@ConvertWith(TopicIdArgumentConverter.class) TopicID topicId, long expirationTimeSeconds, int expirationTimeNanos, @ConvertWith(KeyConverter.class) Key adminKey, @ConvertWith(KeyConverter.class) Key submitKey, String memo, long updatedExpirationTimeSeconds, int updatedExpirationTimeNanos, @ConvertWith(KeyConverter.class) Key updatedAdminKey, @ConvertWith(KeyConverter.class) Key updatedSubmitKey, String updatedMemo, long consensusTimestamp, Long autoRenewAccountId, Long autoRenewPeriod) {
// Store topic to be updated.
var topic = createTopicEntity(topicId, expirationTimeSeconds, expirationTimeNanos, adminKey, submitKey, memo, autoRenewAccountId, autoRenewPeriod);
entityRepository.save(topic);
var responseCode = SUCCESS;
var transaction = createUpdateTopicTransaction(topicId, updatedExpirationTimeSeconds, updatedExpirationTimeNanos, updatedAdminKey, updatedSubmitKey, updatedMemo, autoRenewAccountId, autoRenewPeriod);
var transactionRecord = createTransactionRecord(topicId, consensusTimestamp, responseCode);
var expectedEntity = createTopicEntity(topicId, updatedExpirationTimeSeconds, updatedExpirationTimeNanos, updatedAdminKey, updatedSubmitKey, updatedMemo, autoRenewAccountId, autoRenewPeriod);
expectedEntity.setDeleted(false);
expectedEntity.setTimestampLower(consensusTimestamp);
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
var entity = getTopicEntity(topicId);
assertTransactionInRepository(responseCode, consensusTimestamp, entity.getId());
assertEntity(expectedEntity);
assertEquals(1L, entityRepository.count());
}
use of com.hedera.mirror.common.domain.transaction.RecordItem 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()));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractCallTokenPrecompiles.
@Test
void contractCallTokenPrecompiles() {
// given
RecordItem recordItemCall = recordItemBuilder.contractCall().build();
parseRecordItemAndCommit(recordItemCall);
var parentConsensusTimestamp = recordItemCall.getRecord().getConsensusTimestamp();
var parentTransactionId = recordItemCall.getTransactionBody().getTransactionID();
var childTransactionId = parentTransactionId.toBuilder().setNonce(1).build();
var payerAccount = recordItemCall.getPayerAccountId();
var validStart = DomainUtils.timeStampInNanos(parentTransactionId.getTransactionValidStart());
// when
RecordItem recordItemMint = recordItemBuilder.tokenMint(TokenType.FUNGIBLE_COMMON).transactionBodyWrapper(b -> b.setTransactionID(childTransactionId)).record(r -> r.setParentConsensusTimestamp(parentConsensusTimestamp)).build();
parseRecordItemAndCommit(recordItemMint);
// then
assertEquals(2, transactionRepository.count());
assertThat(transactionRepository.findById(recordItemCall.getConsensusTimestamp())).get().returns(payerAccount, com.hedera.mirror.common.domain.transaction.Transaction::getPayerAccountId).returns(validStart, com.hedera.mirror.common.domain.transaction.Transaction::getValidStartNs).returns(0, com.hedera.mirror.common.domain.transaction.Transaction::getNonce).returns(null, com.hedera.mirror.common.domain.transaction.Transaction::getParentConsensusTimestamp);
assertThat(transactionRepository.findById(recordItemMint.getConsensusTimestamp())).get().returns(payerAccount, com.hedera.mirror.common.domain.transaction.Transaction::getPayerAccountId).returns(validStart, com.hedera.mirror.common.domain.transaction.Transaction::getValidStartNs).returns(1, com.hedera.mirror.common.domain.transaction.Transaction::getNonce).returns(recordItemCall.getConsensusTimestamp(), com.hedera.mirror.common.domain.transaction.Transaction::getParentConsensusTimestamp);
}
Aggregations