Search in sources :

Example 91 with Transaction

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

the class EntityRecordItemListenerTokenTest method tokenDissociate.

@Test
void tokenDissociate() {
    createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
    Transaction dissociateTransaction = tokenDissociate(List.of(TOKEN_ID), PAYER2);
    long dissociateTimeStamp = 10L;
    insertAndParseTransaction(dissociateTimeStamp, dissociateTransaction);
    EntityId tokenId = EntityId.of(TOKEN_ID);
    EntityId accountId = EntityId.of(PAYER2);
    TokenAccount expected = new TokenAccount(tokenId, accountId, dissociateTimeStamp);
    expected.setCreatedTimestamp(ASSOCIATE_TIMESTAMP);
    expected.setAssociated(false);
    expected.setAutomaticAssociation(false);
    expected.setFreezeStatus(TokenFreezeStatusEnum.NOT_APPLICABLE);
    expected.setKycStatus(TokenKycStatusEnum.NOT_APPLICABLE);
    assertThat(latestTokenAccount(TOKEN_ID, PAYER2)).get().isEqualTo(expected);
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Transaction(com.hederahashgraph.api.proto.java.Transaction) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 92 with Transaction

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

the class TransactionSignatureTest method getRecordItem.

private RecordItem getRecordItem(TransactionType transactionType, ResponseCodeEnum responseCode, SignatureMap signatureMap) {
    TransactionBody transactionBody = getTransactionBody(transactionType);
    Transaction transaction = Transaction.newBuilder().setSignedTransactionBytes(SignedTransaction.newBuilder().setBodyBytes(transactionBody.toByteString()).setSigMap(signatureMap).build().toByteString()).build();
    TransactionRecord transactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Utility.instantToTimestamp(Instant.ofEpochSecond(0, CONSENSUS_TIMESTAMP))).setReceipt(TransactionReceipt.newBuilder().setStatus(responseCode).build()).build();
    return new RecordItem(transaction, transactionRecord);
}
Also used : TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem)

Example 93 with Transaction

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

the class PubSubRecordItemListenerTest method testSendRetries.

@Test
void testSendRetries() throws Exception {
    // when
    CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().build()).build();
    Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
    pubSubProperties.setMaxSendAttempts(3);
    // when
    when(messageChannel.send(any())).thenThrow(MessageTimeoutException.class).thenThrow(MessageTimeoutException.class).thenReturn(true);
    pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
    // then
    var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 3);
    assertThat(pubSubMessage.getEntity()).isNull();
    assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) MessageTimeoutException(org.springframework.integration.MessageTimeoutException) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) Test(org.junit.jupiter.api.Test)

Example 94 with Transaction

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

the class PubSubRecordItemListenerTest method testPubSubMessageWithNonFeeTransferAndNullEntityId.

@Test
void testPubSubMessageWithNonFeeTransferAndNullEntityId() throws Exception {
    // given
    List<AccountAmount> nonFeeTransfers = new ArrayList<>();
    nonFeeTransfers.add(buildAccountAmount(10L, 100L));
    nonFeeTransfers.add(buildAccountAmount(11L, 111L));
    CryptoTransferTransactionBody cryptoTransfer = CryptoTransferTransactionBody.newBuilder().setTransfers(TransferList.newBuilder().addAccountAmounts(nonFeeTransfers.get(0)).addAccountAmounts(nonFeeTransfers.get(1)).build()).build();
    Transaction transaction = buildTransaction(builder -> builder.setCryptoTransfer(cryptoTransfer));
    var recordItem = new RecordItem(transaction, DEFAULT_RECORD);
    when(nonFeeTransferExtractionStrategy.extractNonFeeTransfers(recordItem.getTransactionBody(), recordItem.getRecord())).thenReturn(cryptoTransfer.getTransfers().getAccountAmountsList());
    // when
    pubSubRecordItemListener.onItem(recordItem);
    // then
    var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
    assertThat(pubSubMessage.getEntity()).isNull();
    assertThat(pubSubMessage.getNonFeeTransfers()).isEqualTo(nonFeeTransfers);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) ArrayList(java.util.ArrayList) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) Test(org.junit.jupiter.api.Test)

Example 95 with Transaction

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

the class PubSubRecordItemListenerTest method testNetworkAddressBookUpdate.

@Test
void testNetworkAddressBookUpdate() throws Exception {
    // given
    byte[] fileContents = UPDATED.toByteArray();
    var fileUpdate = FileUpdateTransactionBody.newBuilder().setFileID(ADDRESS_BOOK_FILE_ID).setContents(ByteString.copyFrom(fileContents)).build();
    Transaction transaction = buildTransaction(builder -> builder.setFileUpdate(fileUpdate));
    // when
    doReturn(EntityId.of(ADDRESS_BOOK_FILE_ID)).when(transactionHandler).getEntity(any());
    pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
    // then
    FileData fileData = new FileData(100L, fileContents, EntityId.of(ADDRESS_BOOK_FILE_ID), TransactionType.FILEUPDATE.getProtoId());
    verify(addressBookService).update(fileData);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) FileData(com.hedera.mirror.common.domain.file.FileData) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test)

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