use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractCallToNew.
@ParameterizedTest
@EnumSource(ContractIdType.class)
void contractCallToNew(ContractIdType contractIdType) {
// The contract is not in db, it should still work. Note for the create2 evm address,
// ContractCallTransactionHandler will get the correct plain contractId from the transaction record instead
// only cache the create2 evm address to verify it later
SetupResult setupResult = setupContract(CONTRACT_ID, contractIdType, false, contractIdType == ContractIdType.CREATE2_EVM);
Transaction transaction = contractCallTransaction(setupResult.protoContractId);
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.CALL);
ContractCallTransactionBody contractCallTransactionBody = transactionBody.getContractCall();
RecordItem recordItem = new RecordItem(transaction, record);
parseRecordItemAndCommit(recordItem);
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(1, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertEntities(EntityId.of(CREATED_CONTRACT_ID)), () -> assertTransactionAndRecord(transactionBody, record), () -> assertContractCallResult(contractCallTransactionBody, record));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractCallToExisting.
@ParameterizedTest
@EnumSource(ContractIdType.class)
void contractCallToExisting(ContractIdType contractIdType) {
SetupResult setupResult = setupContract(CONTRACT_ID, contractIdType, true, true);
// now call
Transaction transaction = contractCallTransaction(setupResult.protoContractId);
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = getContractTransactionRecord(transactionBody, ContractTransactionType.CALL);
ContractCallTransactionBody contractCallTransactionBody = transactionBody.getContractCall();
RecordItem recordItem = new RecordItem(transaction, record);
parseRecordItemAndCommit(recordItem);
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(1, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertEntities(EntityId.of(CONTRACT_ID), EntityId.of(CREATED_CONTRACT_ID)), () -> assertTransactionAndRecord(transactionBody, record), () -> assertContractCallResult(contractCallTransactionBody, record), () -> assertThat(contractRepository.findAll()).contains(setupResult.contract));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerContractTest method contractUpdateAllToExistingInvalidTransaction.
@ParameterizedTest
@EnumSource(value = ContractIdType.class)
void contractUpdateAllToExistingInvalidTransaction(ContractIdType contractIdType) {
SetupResult setupResult = setupContract(CONTRACT_ID, contractIdType, true, true);
Transaction transaction = contractUpdateAllTransaction(setupResult.protoContractId, true);
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = getContractTransactionRecord(transactionBody, ResponseCodeEnum.INSUFFICIENT_ACCOUNT_BALANCE, ContractTransactionType.UPDATE);
RecordItem recordItem = new RecordItem(transaction, record);
parseRecordItemAndCommit(recordItem);
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEquals(0, contractResultRepository.count()), () -> assertEquals(3, cryptoTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertThat(contractRepository.findAll()).containsExactly(setupResult.contract));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoTransferFailedTransaction.
@Test
void cryptoTransferFailedTransaction() {
entityProperties.getPersist().setCryptoTransferAmounts(true);
// make the transfers
Transaction transaction = cryptoTransferTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
TransactionRecord record = transactionRecord(transactionBody, ResponseCodeEnum.INVALID_ACCOUNT_ID);
parseRecordItemAndCommit(new RecordItem(transaction, record));
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(), () -> assertCryptoTransfers(3), () -> assertEquals(0, nonFeeTransferRepository.count()), () -> assertTransactionAndRecord(transactionBody, record));
}
use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerCryptoTest method cryptoAddLiveHashPersist.
@Test
void cryptoAddLiveHashPersist() {
Transaction transaction = cryptoAddLiveHashTransaction();
TransactionBody transactionBody = getTransactionBody(transaction);
CryptoAddLiveHashTransactionBody cryptoAddLiveHashTransactionBody = transactionBody.getCryptoAddLiveHash();
TransactionRecord record = transactionRecordSuccess(transactionBody);
parseRecordItemAndCommit(new RecordItem(transaction, record));
var dbTransaction = getDbTransaction(record.getConsensusTimestamp());
LiveHash dbLiveHash = liveHashRepository.findById(dbTransaction.getConsensusTimestamp()).get();
assertAll(() -> assertEquals(1, transactionRepository.count()), () -> assertEntities(), () -> assertCryptoTransfers(3), () -> assertEquals(1, liveHashRepository.count()), () -> assertTransactionAndRecord(transactionBody, record), () -> assertArrayEquals(cryptoAddLiveHashTransactionBody.getLiveHash().getHash().toByteArray(), dbLiveHash.getLivehash()));
}
Aggregations