Search in sources :

Example 1 with AbstractEntity

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

the class ContractCreateTransactionHandlerTest method getExpectedUpdatedEntity.

@Override
protected AbstractEntity getExpectedUpdatedEntity() {
    AbstractEntity entity = super.getExpectedUpdatedEntity();
    entity.setMaxAutomaticTokenAssociations(0);
    return entity;
}
Also used : AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity)

Example 2 with AbstractEntity

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

the class CryptoCreateTransactionHandlerTest method getUpdateEntityTestSpecsForCreateTransaction.

@Override
protected List<UpdateEntityTestSpec> getUpdateEntityTestSpecsForCreateTransaction(FieldDescriptor memoField) {
    List<UpdateEntityTestSpec> testSpecs = super.getUpdateEntityTestSpecsForCreateTransaction(memoField);
    TransactionBody body = getTransactionBodyForUpdateEntityWithoutMemo();
    Message innerBody = getInnerBody(body);
    FieldDescriptor field = getInnerBodyFieldDescriptorByName("max_automatic_token_associations");
    innerBody = innerBody.toBuilder().setField(field, 500).build();
    body = getTransactionBody(body, innerBody);
    AbstractEntity expected = getExpectedUpdatedEntity();
    expected.setMaxAutomaticTokenAssociations(500);
    expected.setMemo("");
    testSpecs.add(UpdateEntityTestSpec.builder().description("create entity with non-zero max_automatic_token_associations").expected(expected).recordItem(getRecordItem(body, getDefaultTransactionRecord().build())).build());
    return testSpecs;
}
Also used : CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Message(com.google.protobuf.Message) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor)

Example 3 with AbstractEntity

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

the class TokenUpdateTransactionHandlerTest method noTreasuryUpdate.

@Test
void noTreasuryUpdate() {
    AbstractEntity entity = getExpectedUpdatedEntity();
    TokenTransferList tokenTransferList = TokenTransferList.newBuilder().setToken(TokenID.newBuilder().setTokenNum(3L).build()).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(AccountID.newBuilder().setAccountNum(2L).build()).setSenderAccountID(AccountID.newBuilder().setAccountNum(1L).build()).setSerialNumber(// Not wildcard
    1L).build()).build();
    TransactionRecord record = getDefaultTransactionRecord().addTokenTransferLists(tokenTransferList).build();
    RecordItem recordItem = getRecordItem(getDefaultTransactionBody().build(), record);
    when(entityIdService.lookup(AccountID.newBuilder().setAccountNum(DEFAULT_AUTO_RENEW_ACCOUNT_NUM).build())).thenReturn(EntityIdEndec.decode(DEFAULT_AUTO_RENEW_ACCOUNT_NUM, EntityType.ACCOUNT));
    Transaction transaction = new Transaction();
    transaction.setEntityId(entity.toEntityId());
    transactionHandler.updateTransaction(transaction, recordItem);
    Mockito.verifyNoInteractions(nftRepository);
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hedera.mirror.common.domain.transaction.Transaction) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) 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 4 with AbstractEntity

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

the class AbstractTransactionHandlerTest method getExpectedEntityWithTimestamp.

protected AbstractEntity getExpectedEntityWithTimestamp() {
    AbstractEntity entity = getEntity();
    EntityOperation entityOperation = transactionHandler.getType().getEntityOperation();
    if (entityOperation == EntityOperation.CREATE) {
        entity.setCreatedTimestamp(CREATED_TIMESTAMP_NS);
        entity.setDeleted(false);
        entity.setTimestampLower(CREATED_TIMESTAMP_NS);
    } else if (entityOperation == EntityOperation.UPDATE) {
        entity.setDeleted(false);
        entity.setTimestampLower(MODIFIED_TIMESTAMP_NS);
    } else {
        entity.setTimestampLower(MODIFIED_TIMESTAMP_NS);
    }
    return entity;
}
Also used : EntityOperation(com.hedera.mirror.common.domain.entity.EntityOperation) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity)

Example 5 with AbstractEntity

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

the class AbstractTransactionHandlerTest method getUpdateEntityTestSpecsForUpdateTransaction.

private List<UpdateEntityTestSpec> getUpdateEntityTestSpecsForUpdateTransaction(FieldDescriptor memoField, FieldDescriptor memoWrapperField, FieldDescriptor maxAutomaticTokenAssociationsField, FieldDescriptor receiverSigRequiredWrapperField) {
    TransactionBody body = getTransactionBodyForUpdateEntityWithoutMemo();
    Message innerBody = getInnerBody(body);
    List<UpdateEntityTestSpec> testSpecs = new LinkedList<>();
    if (receiverSigRequiredWrapperField != null) {
        innerBody = innerBody.toBuilder().setField(receiverSigRequiredWrapperField, UPDATED_RECEIVER_SIG_REQUIRED).build();
    }
    AbstractEntity expected = getExpectedUpdatedEntity();
    Message unchangedMemoInnerBody = innerBody;
    if (receiverSigRequiredWrapperField != null && expected instanceof Entity) {
        ((Entity) expected).setReceiverSigRequired(UPDATED_RECEIVER_SIG_REQUIRED.getValue());
    }
    testSpecs.add(UpdateEntityTestSpec.builder().description("update entity without memo").expected(expected).recordItem(getRecordItem(body, unchangedMemoInnerBody)).build());
    Message updatedMemoInnerBody = innerBody;
    if (memoWrapperField != null) {
        // memo is of string type
        // non-empty string, expect memo set to non-empty string
        expected = getExpectedUpdatedEntity();
        expected.setMemo(UPDATED_MEMO);
        updatedMemoInnerBody = innerBody.toBuilder().setField(memoField, UPDATED_MEMO).build();
    }
    if (receiverSigRequiredWrapperField != null && expected instanceof Entity) {
        ((Entity) expected).setReceiverSigRequired(UPDATED_RECEIVER_SIG_REQUIRED.getValue());
    }
    testSpecs.add(UpdateEntityTestSpec.builder().description("update entity with non-empty String").expected(expected).recordItem(getRecordItem(body, updatedMemoInnerBody)).build());
    // memo is set through the StringValue field
    // there is always a StringValue field, either "memo" or "memoWrapper"
    FieldDescriptor field = memoWrapperField;
    if (field == null) {
        field = memoField;
    }
    expected = getExpectedUpdatedEntity();
    expected.setMemo("");
    Message clearedMemoInnerBody = innerBody.toBuilder().setField(field, StringValue.of("")).build();
    if (receiverSigRequiredWrapperField != null && expected instanceof Entity) {
        ((Entity) expected).setReceiverSigRequired(UPDATED_RECEIVER_SIG_REQUIRED.getValue());
    }
    testSpecs.add(UpdateEntityTestSpec.builder().description("update entity with empty StringValue memo, expect memo cleared").expected(expected).recordItem(getRecordItem(body, clearedMemoInnerBody)).build());
    // non-empty StringValue, expect memo in entity updated
    expected = getExpectedUpdatedEntity();
    expected.setMemo(UPDATED_MEMO);
    Message memoStringValueUpdatedInnerBody = innerBody.toBuilder().setField(field, StringValue.of(UPDATED_MEMO)).build();
    if (receiverSigRequiredWrapperField != null && expected instanceof Entity) {
        ((Entity) expected).setReceiverSigRequired(UPDATED_RECEIVER_SIG_REQUIRED.getValue());
    }
    testSpecs.add(UpdateEntityTestSpec.builder().description("update entity with non-empty StringValue memo, expect memo updated").expected(expected).recordItem(getRecordItem(body, memoStringValueUpdatedInnerBody)).build());
    if (maxAutomaticTokenAssociationsField != null) {
        expected = getExpectedUpdatedEntity();
        expected.setMaxAutomaticTokenAssociations(500);
        if (expected instanceof Entity) {
            ((Entity) expected).setReceiverSigRequired(true);
        }
        Message updatedInnerBody = innerBody.toBuilder().setField(maxAutomaticTokenAssociationsField, Int32Value.of(500)).build();
        testSpecs.add(UpdateEntityTestSpec.builder().description("update entity with max_automatic_token_associations").expected(expected).recordItem(getRecordItem(body, updatedInnerBody)).build());
    }
    return testSpecs;
}
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) LinkedList(java.util.LinkedList) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor)

Aggregations

AbstractEntity (com.hedera.mirror.common.domain.entity.AbstractEntity)14 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)6 Message (com.google.protobuf.Message)5 Entity (com.hedera.mirror.common.domain.entity.Entity)3 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)3 Test (org.junit.jupiter.api.Test)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)2 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)2 TokenTransferList (com.hederahashgraph.api.proto.java.TokenTransferList)2 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)2 LinkedList (java.util.LinkedList)2 ByteString (com.google.protobuf.ByteString)1 Contract (com.hedera.mirror.common.domain.contract.Contract)1 EntityId (com.hedera.mirror.common.domain.entity.EntityId)1 EntityOperation (com.hedera.mirror.common.domain.entity.EntityOperation)1 EntityType (com.hedera.mirror.common.domain.entity.EntityType)1 AccountID (com.hederahashgraph.api.proto.java.AccountID)1 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)1 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)1