Search in sources :

Example 71 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTopicTest method createTopicTestError.

@Test
void createTopicTestError() {
    var consensusTimestamp = 3_000_000L;
    var responseCode = INSUFFICIENT_ACCOUNT_BALANCE;
    var transaction = createCreateTopicTransaction(null, null, "memo", null, null);
    var transactionRecord = createTransactionRecord(null, consensusTimestamp, responseCode);
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    assertTransactionInRepository(responseCode, consensusTimestamp, null);
    assertEquals(0L, entityRepository.count());
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 72 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTopicTest method submitMessageTestTopicNotFound.

@Test
void submitMessageTestTopicNotFound() {
    var responseCode = SUCCESS;
    var consensusTimestamp = 10_000_000L;
    var message = "message";
    var sequenceNumber = 10_000L;
    var runningHash = "running-hash";
    var runningHashVersion = 2;
    var chunkNum = 3;
    var chunkTotal = 5;
    var validStartNs = 7L;
    var scheduled = false;
    var nonce = 0;
    TransactionID initialTransactionId = createTransactionID(PAYER_ACCOUNT_ID.getEntityNum(), TestUtils.toTimestamp(validStartNs), scheduled, nonce);
    var topicMessage = createTopicMessage(TOPIC_ID, message, sequenceNumber, runningHash, consensusTimestamp, runningHashVersion, chunkNum, chunkTotal, PAYER_ACCOUNT_ID, initialTransactionId);
    var transaction = createSubmitMessageTransaction(TOPIC_ID, message, chunkNum, chunkTotal, initialTransactionId);
    var transactionRecord = createTransactionRecord(TOPIC_ID, sequenceNumber, runningHash.getBytes(), runningHashVersion, consensusTimestamp, responseCode);
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    assertTransactionInRepository(responseCode, consensusTimestamp, TOPIC_ID.getTopicNum());
    assertEquals(0L, entityRepository.count());
    assertEquals(1L, topicMessageRepository.count());
    assertThat(topicMessageRepository.findById(consensusTimestamp)).get().isEqualTo(topicMessage);
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 73 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTopicTest method updateTopicTest.

@ParameterizedTest
@CsvSource({ "11, 21, updated-admin-key, updated-submit-key, updated-memo, 1, 30", "11, 21, '', '', '', 0, 30", "11, 21, updated-admin-key, updated-submit-key, updated-memo, ," })
void updateTopicTest(long updatedExpirationTimeSeconds, int updatedExpirationTimeNanos, @ConvertWith(KeyConverter.class) Key updatedAdminKey, @ConvertWith(KeyConverter.class) Key updatedSubmitKey, String updatedMemo, Long autoRenewAccountId, Long autoRenewPeriod) {
    var topic = domainBuilder.topic().persist();
    var updateTimestamp = topic.getCreatedTimestamp() + 100L;
    var topicId = TopicID.newBuilder().setTopicNum(topic.getNum()).build();
    var transaction = createUpdateTopicTransaction(topicId, updatedExpirationTimeSeconds, updatedExpirationTimeNanos, updatedAdminKey, updatedSubmitKey, updatedMemo, autoRenewAccountId, autoRenewPeriod);
    var transactionRecord = createTransactionRecord(topicId, updateTimestamp, SUCCESS);
    var expectedAutoRenewAccountId = autoRenewAccountId == null ? topic.getAutoRenewAccountId() : autoRenewAccountId;
    var expectedAutoRenewPeriod = autoRenewPeriod == null ? topic.getAutoRenewPeriod() : autoRenewPeriod;
    var expected = createTopicEntity(topicId, updatedExpirationTimeSeconds, updatedExpirationTimeNanos, updatedAdminKey, updatedSubmitKey, updatedMemo, expectedAutoRenewAccountId, expectedAutoRenewPeriod);
    expected.setCreatedTimestamp(topic.getCreatedTimestamp());
    expected.setDeleted(false);
    expected.setTimestampLower(updateTimestamp);
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    assertTransactionInRepository(SUCCESS, updateTimestamp, topic.getId());
    assertEntity(expected);
    assertEquals(1L, entityRepository.count());
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 74 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTopicTest method deleteTopicTestTopicNotFound.

@Test
void deleteTopicTestTopicNotFound() {
    var consensusTimestamp = 10_000_000L;
    var responseCode = SUCCESS;
    // Setup expected data
    var topic = createTopicEntity(TOPIC_ID, null, null, null, null, "", null, null);
    topic.setDeleted(true);
    topic.setTimestampLower(consensusTimestamp);
    // Topic not saved to the repository.
    var transaction = createDeleteTopicTransaction(TOPIC_ID);
    var transactionRecord = createTransactionRecord(TOPIC_ID, consensusTimestamp, responseCode);
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    var entity = getTopicEntity(TOPIC_ID);
    assertTransactionInRepository(responseCode, consensusTimestamp, entity.getId());
    assertEquals(1L, entityRepository.count());
    assertThat(entity).isEqualTo(topic);
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 75 with RecordItem

use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.

the class TransactionSignatureTest method transactionSignatureEnabled.

@ParameterizedTest
@EnumSource(value = TransactionType.class, names = "UNKNOWN", mode = EXCLUDE)
void transactionSignatureEnabled(TransactionType transactionType) {
    transactionSignatures.clear();
    transactionSignatures.add(transactionType);
    RecordItem recordItem = getRecordItem(transactionType, SUCCESS);
    entityRecordItemListener.onItem(recordItem);
    assertTransactionSignatures(defaultTransactionSignatures);
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)182 Test (org.junit.jupiter.api.Test)131 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)131 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)108 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)95 Transaction (com.hederahashgraph.api.proto.java.Transaction)94 EntityId (com.hedera.mirror.common.domain.entity.EntityId)42 DomainUtils (com.hedera.mirror.common.util.DomainUtils)36 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)36 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)36 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)34 EnumSource (org.junit.jupiter.params.provider.EnumSource)34 Entity (com.hedera.mirror.common.domain.entity.Entity)31 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)31 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)29 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)29 AccountID (com.hederahashgraph.api.proto.java.AccountID)28 CryptoAddLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody)28 CryptoDeleteLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody)28 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)28