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