use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method testGetEntityIdReceipt.
@Test
void testGetEntityIdReceipt() {
var recordItem = recordItemBuilder.contractUpdate().build();
ContractID contractIdBody = recordItem.getTransactionBody().getContractUpdateInstance().getContractID();
ContractID contractIdReceipt = recordItem.getRecord().getReceipt().getContractID();
EntityId expectedEntityId = EntityId.of(contractIdReceipt);
when(entityIdService.lookup(contractIdReceipt, contractIdBody)).thenReturn(expectedEntityId);
EntityId entityId = transactionHandler.getEntity(recordItem);
assertThat(entityId).isEqualTo(expectedEntityId);
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.
@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
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));
transactionHandler.updateTransaction(transaction, recordItem);
assertTokenUpdate(timestamp, tokenId, Assertions::assertNull);
}
use of com.hedera.mirror.common.domain.entity.EntityId 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.entity.EntityId in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testPubSubMessageNullEntityId.
@Test
void testPubSubMessageNullEntityId() throws Exception {
// given
byte[] message = new byte[] { 'a', 'b', 'c' };
TopicID topicID = TopicID.newBuilder().setTopicNum(10L).build();
EntityId topicIdEntity = EntityId.of(topicID);
ConsensusSubmitMessageTransactionBody submitMessage = ConsensusSubmitMessageTransactionBody.newBuilder().setMessage(ByteString.copyFrom(message)).setTopicID(topicID).build();
Transaction transaction = buildTransaction(builder -> builder.setConsensusSubmitMessage(submitMessage));
// when
doReturn(null).when(transactionHandler).getEntity(any());
pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
assertThat(pubSubMessage.getEntity()).isEqualTo(null);
assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class CryptoTransferRepositoryTest method findByConsensusTimestampAndEntityNum.
@Test
void findByConsensusTimestampAndEntityNum() {
EntityId entity = EntityId.of(0L, 1L, 2L, ACCOUNT);
EntityId payerEntity = EntityId.of(0L, 1L, 3L, ACCOUNT);
CryptoTransfer cryptoTransfer = new CryptoTransfer(1L, 40L, entity);
cryptoTransfer.setPayerAccountId(payerEntity);
cryptoTransferRepository.save(cryptoTransfer);
assertThat(cryptoTransferRepository.findById(cryptoTransfer.getId())).get().isEqualTo(cryptoTransfer);
}
Aggregations