use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoTransferWithUnknownAliasActionError.
@Test
void cryptoTransferWithUnknownAliasActionError() {
// given
// both accounts have alias, and only account2's alias is in db
entityProperties.getPersist().setCryptoTransferAmounts(true);
entityProperties.getPersist().setNonFeeTransfers(true);
parserProperties.setPartialDataAction(PartialDataAction.ERROR);
Entity account1 = domainBuilder.entity().get();
Entity account2 = domainBuilder.entity().persist();
// crypto transfer from unknown account1 alias to account2 alias
Transaction transaction = buildTransaction(builder -> builder.getCryptoTransferBuilder().getTransfersBuilder().addAccountAmounts(accountAliasAmount(DomainUtils.fromBytes(account1.getAlias()), 100)).addAccountAmounts(accountAliasAmount(DomainUtils.fromBytes(account2.getAlias()), -100)));
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord transactionRecord = buildTransactionRecord(r -> r.getTransferListBuilder().addAccountAmounts(accountAmount(account1.getNum(), 100)).addAccountAmounts(accountAmount(account2.getNum(), -100)), transactionBody, ResponseCodeEnum.SUCCESS.getNumber());
// when, then
assertThrows(AliasNotFoundException.class, () -> parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord)));
assertAll(() -> assertEquals(0, transactionRepository.count()), () -> assertEquals(0, cryptoTransferRepository.count()), () -> assertThat(findNonFeeTransfers()).isEmpty());
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method createAccount.
private void createAccount() {
Transaction createTransaction = cryptoCreateTransaction();
TransactionBody createTransactionBody = getTransactionBody(createTransaction);
TransactionRecord createRecord = transactionRecordSuccess(createTransactionBody);
parseRecordItemAndCommit(new RecordItem(createTransaction, createRecord));
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method unknownTransactionResult.
@Test
void unknownTransactionResult() {
int unknownResult = -1000;
Transaction transaction = cryptoCreateTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody, unknownResult);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertThat(transactionRepository.findAll()).hasSize(1).extracting(com.hedera.mirror.common.domain.transaction.Transaction::getResult).containsOnly(unknownResult);
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method testRawBytes.
private void testRawBytes(Transaction transaction, byte[] expectedBytes) {
// given
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecordSuccess(transactionBody);
// when
parseRecordItemAndCommit(new RecordItem(transaction, record));
// then
var dbTransaction = getDbTransaction(record.getConsensusTimestamp());
assertArrayEquals(expectedBytes, dbTransaction.getTransactionBytes());
}
use of com.hederahashgraph.api.proto.java.TransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method samePayerAndUpdateAccount.
/**
* Github issue #483
*/
@Test
void samePayerAndUpdateAccount() {
Transaction transaction = cryptoUpdateTransaction(accountId1);
TransactionBody transactionBody = getTransactionBody(transaction);
transactionBody = TransactionBody.newBuilder().mergeFrom(transactionBody).setTransactionID(Utility.getTransactionId(accountId1)).build();
transaction = Transaction.newBuilder().setSignedTransactionBytes(SignedTransaction.newBuilder().setBodyBytes(transactionBody.toByteString()).build().toByteString()).build();
TransactionRecord record = transactionRecordSuccess(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertThat(transactionRepository.findById(DomainUtils.timestampInNanosMax(record.getConsensusTimestamp()))).get().extracting(com.hedera.mirror.common.domain.transaction.Transaction::getPayerAccountId, com.hedera.mirror.common.domain.transaction.Transaction::getEntityId).containsOnly(EntityId.of(accountId1));
}
Aggregations