use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.
the class SqlEntityListenerTest method makeTransaction.
private Transaction makeTransaction() {
EntityId entityId = EntityId.of(10, 10, 10, ACCOUNT);
Transaction transaction = new Transaction();
transaction.setConsensusTimestamp(101L);
transaction.setEntityId(entityId);
transaction.setNodeAccountId(entityId);
transaction.setMemo("memo".getBytes());
transaction.setNonce(0);
transaction.setType(14);
transaction.setResult(22);
transaction.setTransactionHash("transaction hash".getBytes());
transaction.setTransactionBytes("transaction bytes".getBytes());
transaction.setPayerAccountId(entityId);
transaction.setValidStartNs(1L);
transaction.setValidDurationSeconds(1L);
transaction.setMaxFee(1L);
transaction.setChargedTxFee(1L);
transaction.setInitialBalance(0L);
transaction.setScheduled(true);
return transaction;
}
use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.
the class ConsensusUpdateTopicTransactionHandlerTest 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.consensusUpdateTopic().transactionBody(b -> b.getAutoRenewAccountBuilder().setAlias(alias)).build();
var topicId = EntityId.of(recordItem.getTransactionBody().getConsensusUpdateTopic().getTopicID());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(topicId)).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.Transaction in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest method updateTransactionStakedAccountId.
@Test
void updateTransactionStakedAccountId() {
// given
final AccountID accountID = AccountID.newBuilder().setAccountNum(1L).build();
var recordItem = recordItemBuilder.contractCreate().transactionBody(b -> b.clearAutoRenewAccountId().setDeclineReward(false).setStakedAccountId(accountID)).build();
// when
transactionHandler.updateTransaction(transaction(recordItem), recordItem);
// then
verify(entityListener).onContract(contracts.capture());
assertThat(contracts.getValue()).isNotNull().returns(false, Contract::isDeclineReward).returns(accountID.getAccountNum(), Contract::getStakedAccountId).returns(-1L, Contract::getStakedNodeId).returns(Utility.getEpochDay(recordItem.getConsensusTimestamp()), Contract::getStakePeriodStart);
}
use of com.hedera.mirror.common.domain.transaction.Transaction in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest 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.contractCreate().transactionBody(b -> b.getAutoRenewAccountIdBuilder().setAlias(alias)).build();
var contractId = EntityId.of(recordItem.getRecord().getReceipt().getContractID());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(contractId)).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.Transaction 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));
}
Aggregations