use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method updateTransactionStakedNodeId.
@Test
void updateTransactionStakedNodeId() {
RecordItem withStakedNodeIdSet = recordItemBuilder.contractUpdate().transactionBody(body -> body.setStakedNodeId(1L)).build();
setupForContractUpdateTransactionTest(withStakedNodeIdSet, t -> assertThat(t).returns(1L, Contract::getStakedNodeId).returns(-1L, Contract::getStakedAccountId).returns(true, Contract::isDeclineReward).returns(Utility.getEpochDay(withStakedNodeIdSet.getConsensusTimestamp()), Contract::getStakePeriodStart));
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class CryptoApproveAllowanceTransactionHandlerTest 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.cryptoApproveAllowance().transactionBody(b -> {
b.getCryptoAllowancesBuilderList().forEach(builder -> builder.getOwnerBuilder().setAlias(alias));
b.getNftAllowancesBuilderList().forEach(builder -> builder.getOwnerBuilder().setAlias(alias));
b.getTokenAllowancesBuilderList().forEach(builder -> builder.getOwnerBuilder().setAlias(alias));
}).build();
var transaction = domainBuilder.transaction().get();
when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", EntityType.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 CryptoApproveAllowanceTransactionHandlerTest method updateTransactionUnsuccessful.
@Test
void updateTransactionUnsuccessful() {
var transaction = new Transaction();
RecordItem recordItem = recordItemBuilder.cryptoApproveAllowance().receipt(r -> r.setStatus(ResponseCodeEnum.ACCOUNT_DELETED)).build();
transactionHandler.updateTransaction(transaction, recordItem);
verifyNoInteractions(entityListener);
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class CryptoCreateTransactionHandlerTest method updateTransactionStakedAccountId.
@Test
void updateTransactionStakedAccountId() {
// given
final AccountID accountId = AccountID.newBuilder().setAccountNum(1L).build();
var recordItem = recordItemBuilder.cryptoCreate().transactionBody(b -> b.setDeclineReward(false).setStakedAccountId(accountId)).build();
// when
transactionHandler.updateTransaction(transaction(recordItem), recordItem);
// then
verify(entityListener).onEntity(entities.capture());
assertThat(entities.getValue()).isNotNull().returns(false, Entity::isDeclineReward).returns(accountId.getAccountNum(), Entity::getStakedAccountId).returns(Utility.getEpochDay(recordItem.getConsensusTimestamp()), Entity::getStakePeriodStart);
}
use of com.hedera.mirror.common.domain.transaction.RecordItem 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);
}
Aggregations