use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionHandlerTest method updateTransactionThrowsWithAliasNotFound.
@ParameterizedTest(name = "{0}")
@EnumSource(value = PartialDataAction.class, names = { "DEFAULT", "ERROR" })
void updateTransactionThrowsWithAliasNotFound(PartialDataAction partialDataAction) {
// given
recordParserProperties.setPartialDataAction(partialDataAction);
var alias = DomainUtils.fromBytes(domainBuilder.key());
var recordItem = recordItemBuilder.tokenUpdate().transactionBody(b -> b.getAutoRenewAccountBuilder().setAlias(alias)).build();
var tokenId = EntityId.of(recordItem.getTransactionBody().getTokenUpdate().getToken());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(tokenId)).get();
when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", ACCOUNT));
// when, then
assertThrows(AliasNotFoundException.class, () -> transactionHandler.updateTransaction(transaction, recordItem));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionHandlerTest method updateTransactionUnsuccessful.
@Test
void updateTransactionUnsuccessful() {
RecordItem recordItem = recordItemBuilder.tokenUpdate().receipt(r -> r.setStatus(ResponseCodeEnum.ACCOUNT_DELETED)).build();
var transaction = new Transaction();
transactionHandler.updateTransaction(transaction, recordItem);
verifyNoInteractions(entityListener);
}
use of com.hedera.mirror.common.domain.transaction.RecordItem 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.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testSendRetries.
@Test
void testSendRetries() throws Exception {
// when
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().build()).build();
Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
pubSubProperties.setMaxSendAttempts(3);
// when
when(messageChannel.send(any())).thenThrow(MessageTimeoutException.class).thenThrow(MessageTimeoutException.class).thenReturn(true);
pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 3);
assertThat(pubSubMessage.getEntity()).isNull();
assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testPubSubMessageWithNonFeeTransferAndNullEntityId.
@Test
void testPubSubMessageWithNonFeeTransferAndNullEntityId() throws Exception {
// given
List<AccountAmount> nonFeeTransfers = new ArrayList<>();
nonFeeTransfers.add(buildAccountAmount(10L, 100L));
nonFeeTransfers.add(buildAccountAmount(11L, 111L));
CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().addAccountAmounts(nonFeeTransfers.get(0)).addAccountAmounts(nonFeeTransfers.get(1)).build()).build();
Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
var recordItem = new RecordItem(transaction, DEFAULT_RECORD);
when(nonFeeTransferExtractionStrategy.extractNonFeeTransfers(recordItem.getTransactionBody(), recordItem.getRecord())).thenReturn(cryptoTransfer.getTransfers().getAccountAmountsList());
// when
pubSubRecordItemListener.onItem(recordItem);
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
assertThat(pubSubMessage.getEntity()).isNull();
assertThat(pubSubMessage.getNonFeeTransfers()).isEqualTo(nonFeeTransfers);
}
Aggregations