Search in sources :

Example 66 with RecordItem

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

the class EntityRecordItemListenerTopicTest method updateTopicTestError.

@Test
void updateTopicTestError() {
    var topicId = TopicID.newBuilder().setTopicNum(1600).build();
    var adminKey = keyFromString("admin-key");
    var submitKey = keyFromString("submit-key");
    var updatedAdminKey = keyFromString("updated-admin-key");
    var updatedSubmitKey = keyFromString("updated-submit-key");
    var consensusTimestamp = 6_000_000L;
    var responseCode = ResponseCodeEnum.INVALID_TOPIC_ID;
    // Store topic to be updated.
    var topic = createTopicEntity(topicId, 10L, 20, adminKey, submitKey, "memo", null, 30L);
    entityRepository.save(topic);
    var transaction = createUpdateTopicTransaction(topicId, 11L, 21, updatedAdminKey, updatedSubmitKey, "updated-memo", null, 30L);
    var transactionRecord = createTransactionRecord(topicId, consensusTimestamp, responseCode);
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    var entity = getTopicEntity(topicId);
    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 67 with RecordItem

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

the class EntityRecordItemListenerTopicTest method submitMessageTestTopicError.

@Test
void submitMessageTestTopicError() {
    var responseCode = ResponseCodeEnum.INVALID_TOPIC_ID;
    var consensusTimestamp = 11_000_000L;
    var message = "message";
    var sequenceNumber = 11_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 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(0, entityRepository.count());
    assertEquals(0L, topicMessageRepository.count());
}
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 68 with RecordItem

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

the class EntityRecordItemListenerTopicTest method submitMessageDisabled.

@Test
void submitMessageDisabled() {
    // given
    entityProperties.getPersist().setTopics(false);
    var responseCode = SUCCESS;
    var topicId = TOPIC_ID;
    var consensusTimestamp = 10_000_000L;
    var message = "message";
    var sequenceNumber = 10_000L;
    var runningHash = "running-hash";
    var runningHashVersion = 1;
    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 transaction = createSubmitMessageTransaction(topicId, message, chunkNum, chunkTotal, initialTransactionId);
    var transactionRecord = createTransactionRecord(topicId, sequenceNumber, runningHash.getBytes(), runningHashVersion, consensusTimestamp, responseCode);
    // when
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    // then
    assertEquals(0L, entityRepository.count());
    assertEquals(0L, topicMessageRepository.count());
    assertTransactionInRepository(responseCode, consensusTimestamp, TOPIC_ID.getTopicNum());
    entityProperties.getPersist().setTopics(true);
}
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 69 with RecordItem

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

the class EntityRecordItemListenerTopicTest method deleteTopicTestError.

@Test
void deleteTopicTestError() {
    var consensusTimestamp = 9_000_000L;
    var responseCode = INSUFFICIENT_ACCOUNT_BALANCE;
    // Store topic to be deleted.
    var topic = createTopicEntity(TOPIC_ID, 10L, 20, null, null, "", null, null);
    entityRepository.save(topic);
    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 70 with RecordItem

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

the class EntityRecordItemListenerTopicTest method createTopicTest.

@ParameterizedTest
@CsvSource({ "0.0.65537, admin-key, submit-key, '', 1000000, 1, 30", "0.0.2147483647, admin-key, '', memo, 1000001, 1, 30", "0.0.1, '', '', memo, 1000002, , ,", "0.0.55, admin-key, submit-key, memo, 1000003, 1, 30" })
void createTopicTest(@ConvertWith(TopicIdArgumentConverter.class) TopicID topicId, @ConvertWith(KeyConverter.class) Key adminKey, @ConvertWith(KeyConverter.class) Key submitKey, String memo, long consensusTimestamp, Long autoRenewAccountNum, Long autoRenewPeriod) {
    var responseCode = SUCCESS;
    var transaction = createCreateTopicTransaction(adminKey, submitKey, memo, autoRenewAccountNum, autoRenewPeriod);
    var transactionRecord = createTransactionRecord(topicId, consensusTimestamp, responseCode);
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    var entity = getTopicEntity(topicId);
    assertTransactionInRepository(responseCode, consensusTimestamp, entity.getId());
    assertEquals(1L, entityRepository.count());
    var expectedEntity = createTopicEntity(topicId, null, null, adminKey, submitKey, memo, autoRenewAccountNum, autoRenewPeriod);
    expectedEntity.setCreatedTimestamp(consensusTimestamp);
    expectedEntity.setDeleted(false);
    expectedEntity.setTimestampLower(consensusTimestamp);
    assertThat(entity).isEqualTo(expectedEntity);
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CsvSource(org.junit.jupiter.params.provider.CsvSource) 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