Search in sources :

Example 11 with AbstractEntity

use of com.hedera.mirror.common.domain.entity.AbstractEntity 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)

Example 12 with AbstractEntity

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

the class AbstractEntityRecordItemListenerTest method assertEntity.

protected void assertEntity(AbstractEntity expected) {
    AbstractEntity actual = getEntity(expected.toEntityId());
    assertThat(actual).isEqualTo(expected);
}
Also used : AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity)

Example 13 with AbstractEntity

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

the class ContractCreateTransactionHandlerTest method getUpdateEntityTestSpecsForCreateTransaction.

@Override
protected List<UpdateEntityTestSpec> getUpdateEntityTestSpecsForCreateTransaction(Descriptors.FieldDescriptor memoField) {
    List<UpdateEntityTestSpec> testSpecs = super.getUpdateEntityTestSpecsForCreateTransaction(memoField);
    TransactionBody body = getTransactionBodyForUpdateEntityWithoutMemo();
    Message innerBody = getInnerBody(body);
    body = getTransactionBody(body, innerBody);
    byte[] evmAddress = TestUtils.generateRandomByteArray(20);
    var contractCreateResult = ContractFunctionResult.newBuilder().setEvmAddress(BytesValue.of(ByteString.copyFrom(evmAddress)));
    var recordBuilder = getDefaultTransactionRecord().setContractCreateResult(contractCreateResult);
    AbstractEntity expected = getExpectedUpdatedEntity();
    ((Contract) expected).setEvmAddress(evmAddress);
    expected.setMemo("");
    testSpecs.add(UpdateEntityTestSpec.builder().description("create contract entity with evm address in record").expected(expected).recordItem(getRecordItem(body, recordBuilder.build())).build());
    return testSpecs;
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) Message(com.google.protobuf.Message) AbstractEntity(com.hedera.mirror.common.domain.entity.AbstractEntity) Contract(com.hedera.mirror.common.domain.contract.Contract)

Example 14 with AbstractEntity

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

the class CryptoCreateTransactionHandlerTest 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)

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