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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations