Search in sources :

Example 71 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileSystemDeleteTransaction.

@Test
void fileSystemDeleteTransaction() {
    Transaction systemDeleteTransaction = systemDeleteTransaction();
    TransactionBody transactionBody = getTransactionBody(systemDeleteTransaction);
    TransactionRecord record = transactionRecord(transactionBody);
    parseRecordItemAndCommit(new RecordItem(systemDeleteTransaction, record));
    Entity fileEntity = getTransactionEntity(record.getConsensusTimestamp());
    assertAll(() -> assertRowCountOnSuccessNoData(FILE_ID), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(fileEntity).isNotNull().extracting(Entity::getDeleted).isEqualTo(true));
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 72 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileDeleteToExisting.

@Test
void fileDeleteToExisting() {
    // first create the file
    Transaction fileCreateTransaction = fileCreateTransaction();
    TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
    TransactionRecord recordCreate = transactionRecord(createTransactionBody);
    parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
    // now update
    Transaction transaction = fileDeleteTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecord(transactionBody);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    Entity dbFileEntity = getTransactionEntity(record.getConsensusTimestamp());
    assertAll(() -> assertEquals(2, transactionRepository.count()), () -> assertEntities(EntityId.of(FILE_ID)), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(6, cryptoTransferRepository.count()), () -> assertEquals(0, liveHashRepository.count()), () -> assertEquals(1, fileDataRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), // Additional entity checks
    () -> assertTrue(dbFileEntity.getDeleted()), () -> assertNotNull(dbFileEntity.getKey()), () -> assertNotNull(dbFileEntity.getExpirationTimestamp()), () -> assertNull(dbFileEntity.getAutoRenewPeriod()), () -> assertNull(dbFileEntity.getProxyAccountId()));
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 73 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileUpdateExpiryToNew.

@Test
void fileUpdateExpiryToNew() {
    Transaction transaction = fileUpdateExpiryTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecord(transactionBody);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    Entity actualFile = getTransactionEntity(record.getConsensusTimestamp());
    assertAll(// TODO: Review row count in fileDataRepository with issue #294, probably should be 0
    () -> assertRowCountOnSuccess(FILE_ID), () -> assertTransactionAndRecord(transactionBody, record), // Additional entity checks
    () -> assertFalse(actualFile.getDeleted()), () -> assertEquals(DomainUtils.timeStampInNanos(transactionBody.getFileUpdate().getExpirationTime()), actualFile.getExpirationTimestamp()), () -> assertNull(actualFile.getKey()), () -> assertNull(actualFile.getAutoRenewPeriod()), () -> assertNull(actualFile.getProxyAccountId()));
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 74 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerFileTest method fileUpdateContentsToExisting.

@Test
void fileUpdateContentsToExisting() {
    // first create the file
    Transaction fileCreateTransaction = fileCreateTransaction();
    TransactionBody createTransactionBody = getTransactionBody(fileCreateTransaction);
    TransactionRecord recordCreate = transactionRecord(createTransactionBody);
    parseRecordItemAndCommit(new RecordItem(fileCreateTransaction, recordCreate));
    // now update
    Transaction transaction = fileUpdateContentsTransaction();
    TransactionBody transactionBody = getTransactionBody(transaction);
    TransactionRecord record = transactionRecord(transactionBody);
    parseRecordItemAndCommit(new RecordItem(transaction, record));
    Entity actualFile = getTransactionEntity(record.getConsensusTimestamp());
    assertAll(() -> assertRowCountOnTwoFileTransactions(), () -> assertTransactionAndRecord(transactionBody, record), () -> assertFileData(transactionBody.getFileUpdate().getContents(), record.getConsensusTimestamp()), // Additional entity checks
    () -> assertFalse(actualFile.getDeleted()), () -> assertNotNull(actualFile.getExpirationTimestamp()), () -> assertNotNull(actualFile.getKey()), () -> assertNull(actualFile.getAutoRenewPeriod()), () -> assertNull(actualFile.getProxyAccountId()));
}
Also used : Entity(com.hedera.mirror.common.domain.entity.Entity) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 75 with Entity

use of com.hedera.mirror.common.domain.entity.Entity in project hedera-mirror-node by hashgraph.

the class AbstractTransactionHandlerTest method getExpectedUpdatedEntity.

protected AbstractEntity getExpectedUpdatedEntity() {
    AbstractEntity entity = getExpectedEntityWithTimestamp();
    TransactionBody defaultBody = getDefaultTransactionBody().build();
    Message innerBody = getInnerBody(defaultBody);
    List<String> fieldNames = innerBody.getDescriptorForType().getFields().stream().map(FieldDescriptor::getName).collect(Collectors.toList());
    for (String fieldName : fieldNames) {
        switch(fieldName) {
            case "adminKey":
                entity.setKey(DEFAULT_KEY.toByteArray());
                break;
            case "autoRenewPeriod":
                entity.setAutoRenewPeriod(DEFAULT_AUTO_RENEW_PERIOD.getSeconds());
                break;
            case "expiry":
            case "expirationTime":
                entity.setExpirationTimestamp(DomainUtils.timestampInNanosMax(DEFAULT_EXPIRATION_TIME));
                break;
            case "keys":
                entity.setKey(DEFAULT_KEY_LIST.toByteArray());
                break;
            case "receiverSigRequired":
                if (entity instanceof Entity) {
                    ((Entity) entity).setReceiverSigRequired(DEFAULT_RECEIVER_SIG_REQUIRED);
                }
                break;
            case "submitKey":
                if (entity instanceof Entity) {
                    ((Entity) entity).setSubmitKey(DEFAULT_SUBMIT_KEY.toByteArray());
                }
                break;
            default:
                break;
        }
    }
    return entity;
}
Also used : AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Entity(com.hedera.mirror.common.domain.entity.Entity) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Message(com.google.protobuf.Message) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) ByteString(com.google.protobuf.ByteString)

Aggregations

Entity (com.hedera.mirror.common.domain.entity.Entity)78 Test (org.junit.jupiter.api.Test)52 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)40 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)23 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)22 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)21 Transaction (com.hederahashgraph.api.proto.java.Transaction)19 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)16 AbstractEntity (com.hedera.mirror.common.domain.entity.AbstractEntity)15 EntityId (com.hedera.mirror.common.domain.entity.EntityId)15 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)14 AccountID (com.hederahashgraph.api.proto.java.AccountID)11 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)10 ByteString (com.google.protobuf.ByteString)9 Contract (com.hedera.mirror.common.domain.contract.Contract)9 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)9 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)9 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)9 Resource (javax.annotation.Resource)9 Assertions (org.junit.jupiter.api.Assertions)9