Search in sources :

Example 66 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerPerformanceCryptoTest method getCreateAccountRecordItem.

private RecordItem getCreateAccountRecordItem(int accountNum) throws Exception {
    Transaction createTransaction = cryptoCreateTransaction();
    TransactionBody createTransactionBody = getTransactionBody(createTransaction);
    TransactionRecord createRecord = transactionRecord(createTransactionBody, ResponseCodeEnum.SUCCESS.getNumber(), accountNum);
    return new RecordItem(createTransaction, createRecord);
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 67 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerPerformanceCryptoTest method getUpdateAccountRecordItem.

private RecordItem getUpdateAccountRecordItem(int accountNum) throws Exception {
    Transaction updateTransaction = cryptoUpdateTransaction(AccountID.newBuilder().setShardNum(0).setRealmNum(0).setAccountNum(accountNum).build());
    TransactionBody updateTransactionBody = getTransactionBody(updateTransaction);
    TransactionRecord createRecord = transactionRecord(updateTransactionBody, ResponseCodeEnum.SUCCESS.getNumber(), accountNum);
    return new RecordItem(updateTransaction, createRecord);
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 68 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerScheduleTest method insertScheduleCreateTransaction.

private void insertScheduleCreateTransaction(long createdTimestamp, AccountID payer, ScheduleID scheduleID) {
    Transaction createTransaction = scheduleCreateTransaction(payer);
    TransactionBody createTransactionBody = getTransactionBody(createTransaction);
    var createTransactionRecord = createTransactionRecord(createdTimestamp, scheduleID, createTransactionBody, SUCCESS, false);
    parseRecordItemAndCommit(new RecordItem(createTransaction, createTransactionRecord));
}
Also used : ScheduleCreateTransactionBody(com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ScheduleDeleteTransactionBody(com.hederahashgraph.api.proto.java.ScheduleDeleteTransactionBody) SchedulableTransactionBody(com.hederahashgraph.api.proto.java.SchedulableTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 69 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerScheduleTest method insertScheduledTransaction.

private void insertScheduledTransaction(long signTimestamp, ScheduleID scheduleID, ResponseCodeEnum responseCodeEnum) {
    Transaction scheduledTransaction = scheduledTransaction();
    TransactionBody scheduledTransactionBody = getTransactionBody(scheduledTransaction);
    var scheduledTransactionRecord = createTransactionRecord(signTimestamp, scheduleID, scheduledTransactionBody, responseCodeEnum, true);
    parseRecordItemAndCommit(new RecordItem(scheduledTransaction, scheduledTransactionRecord));
}
Also used : ScheduleCreateTransactionBody(com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ScheduleDeleteTransactionBody(com.hederahashgraph.api.proto.java.ScheduleDeleteTransactionBody) SchedulableTransactionBody(com.hederahashgraph.api.proto.java.SchedulableTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 70 with Transaction

use of com.hederahashgraph.api.proto.java.Transaction in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTokenTest method nftTransfer.

@Test
void nftTransfer() {
    createAndAssociateToken(TOKEN_ID, NON_FUNGIBLE_UNIQUE, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, 0);
    long mintTimestamp1 = 20L;
    TokenTransferList mintTransfer1 = nftTransfer(TOKEN_ID, RECEIVER, DEFAULT_ACCOUNT_ID, List.of(SERIAL_NUMBER_1));
    Transaction mintTransaction1 = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, true, 0, List.of(SERIAL_NUMBER_1));
    insertAndParseTransaction(mintTimestamp1, mintTransaction1, builder -> {
        builder.getReceiptBuilder().setNewTotalSupply(1L).addSerialNumbers(SERIAL_NUMBER_1);
        builder.addTokenTransferLists(mintTransfer1);
    });
    // approve allowance for nft 1
    long approveAllowanceTimestamp = 25L;
    var cryptoApproveAllowanceTransaction = buildTransaction(b -> b.getCryptoApproveAllowanceBuilder().addNftAllowances(NftAllowance.newBuilder().setOwner(PAYER).setTokenId(TOKEN_ID).addSerialNumbers(SERIAL_NUMBER_1).setSpender(SPENDER)));
    insertAndParseTransaction(approveAllowanceTimestamp, cryptoApproveAllowanceTransaction);
    var expectedNft1 = Nft.builder().id(new NftId(SERIAL_NUMBER_1, EntityId.of(TOKEN_ID))).accountId(EntityId.of(PAYER)).createdTimestamp(mintTimestamp1).deleted(false).metadata(METADATA.getBytes()).modifiedTimestamp(approveAllowanceTimestamp).spender(EntityId.of(SPENDER)).build();
    assertThat(nftRepository.findById(expectedNft1.getId())).get().isEqualTo(expectedNft1);
    long mintTimestamp2 = 30L;
    TokenTransferList mintTransfer2 = nftTransfer(TOKEN_ID, RECEIVER, DEFAULT_ACCOUNT_ID, List.of(SERIAL_NUMBER_2));
    Transaction mintTransaction2 = tokenSupplyTransaction(TOKEN_ID, NON_FUNGIBLE_UNIQUE, true, 0, List.of(SERIAL_NUMBER_2));
    // Verify
    insertAndParseTransaction(mintTimestamp2, mintTransaction2, builder -> {
        builder.getReceiptBuilder().setNewTotalSupply(2L).addSerialNumbers(SERIAL_NUMBER_2);
        builder.addTokenTransferLists(mintTransfer2);
    });
    // token transfer
    Transaction transaction = tokenTransferTransaction();
    TokenTransferList transferList1 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(RECEIVER).setSenderAccountID(PAYER).setSerialNumber(SERIAL_NUMBER_1).build()).build();
    TokenTransferList transferList2 = TokenTransferList.newBuilder().setToken(TOKEN_ID).addNftTransfers(NftTransfer.newBuilder().setReceiverAccountID(RECEIVER).setSenderAccountID(PAYER).setSerialNumber(SERIAL_NUMBER_2).build()).build();
    long transferTimestamp = 40L;
    insertAndParseTransaction(transferTimestamp, transaction, builder -> {
        builder.addAllTokenTransferLists(List.of(transferList1, transferList2));
    });
    expectedNft1.setAccountId(EntityId.of(RECEIVER));
    expectedNft1.setModifiedTimestamp(transferTimestamp);
    expectedNft1.setSpender(null);
    var expectedNft2 = Nft.builder().id(new NftId(SERIAL_NUMBER_2, EntityId.of(TOKEN_ID))).accountId(EntityId.of(RECEIVER)).createdTimestamp(mintTimestamp2).deleted(false).metadata(METADATA.getBytes()).modifiedTimestamp(transferTimestamp).build();
    assertThat(nftTransferRepository.count()).isEqualTo(4L);
    assertNftTransferInRepository(mintTimestamp1, SERIAL_NUMBER_1, TOKEN_ID, RECEIVER, null);
    assertNftTransferInRepository(mintTimestamp2, SERIAL_NUMBER_2, TOKEN_ID, RECEIVER, null);
    assertNftTransferInRepository(transferTimestamp, 1L, TOKEN_ID, RECEIVER, PAYER);
    assertNftTransferInRepository(transferTimestamp, 2L, TOKEN_ID, RECEIVER, PAYER);
    assertThat(nftRepository.findAll()).containsExactlyInAnyOrder(expectedNft1, expectedNft2);
}
Also used : TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hederahashgraph.api.proto.java.Transaction) NftId(com.hedera.mirror.common.domain.token.NftId) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Transaction (com.hederahashgraph.api.proto.java.Transaction)174 Test (org.junit.jupiter.api.Test)128 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)108 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)93 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)91 TransactionRecord (com.hederahashgraph.api.proto.java.TransactionRecord)84 SignedTransaction (com.hederahashgraph.api.proto.java.SignedTransaction)63 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)28 FileCreateTransactionBody (com.hederahashgraph.api.proto.java.FileCreateTransactionBody)28 FileUpdateTransactionBody (com.hederahashgraph.api.proto.java.FileUpdateTransactionBody)28 UtilityTest (com.hedera.mirror.importer.util.UtilityTest)26 CryptoUpdateTransactionBody (com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)26 CryptoAddLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody)25 CryptoCreateTransactionBody (com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody)25 CryptoDeleteLiveHashTransactionBody (com.hederahashgraph.api.proto.java.CryptoDeleteLiveHashTransactionBody)25 Entity (com.hedera.mirror.common.domain.entity.Entity)22 TokenTransferList (com.hederahashgraph.api.proto.java.TokenTransferList)21 ContractUpdateTransactionBody (com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody)18 ContractCallTransactionBody (com.hederahashgraph.api.proto.java.ContractCallTransactionBody)17 ContractCreateTransactionBody (com.hederahashgraph.api.proto.java.ContractCreateTransactionBody)17