Search in sources :

Example 96 with Transaction

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

the class PubSubRecordItemListenerTest method testPubSubMessageNullEntityId.

@Test
void testPubSubMessageNullEntityId() throws Exception {
    // given
    byte[] message = new byte[] { 'a', 'b', 'c' };
    TopicID topicID = TopicID.newBuilder().setTopicNum(10L).build();
    EntityId topicIdEntity = EntityId.of(topicID);
    ConsensusSubmitMessageTransactionBody submitMessage = ConsensusSubmitMessageTransactionBody.newBuilder().setMessage(ByteString.copyFrom(message)).setTopicID(topicID).build();
    Transaction transaction = buildTransaction(builder -> builder.setConsensusSubmitMessage(submitMessage));
    // when
    doReturn(null).when(transactionHandler).getEntity(any());
    pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
    // then
    var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
    assertThat(pubSubMessage.getEntity()).isEqualTo(null);
    assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) TopicID(com.hederahashgraph.api.proto.java.TopicID) ConsensusSubmitMessageTransactionBody(com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Test(org.junit.jupiter.api.Test)

Example 97 with Transaction

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

the class RecordItemTest method testWithParentFromSiblingReference.

@Test
void testWithParentFromSiblingReference() {
    Transaction transaction = Transaction.newBuilder().setSignedTransactionBytes(SIGNED_TRANSACTION.toByteString()).build();
    var parentTransactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setSeconds(1).setNanos(2).build()).setReceipt(TransactionReceipt.newBuilder().setStatusValue(22).build()).setMemo("parent").build();
    RecordItem parentRecordItem = new RecordItem(DEFAULT_HAPI_VERSION, transaction, parentTransactionRecord);
    var siblingTransactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setSeconds(3).setNanos(4).build()).setParentConsensusTimestamp(parentTransactionRecord.getConsensusTimestamp()).setReceipt(TransactionReceipt.newBuilder().setStatusValue(22).build()).setMemo("child").build();
    RecordItem siblingRecordItem = RecordItem.builder().hapiVersion(DEFAULT_HAPI_VERSION).transaction(DEFAULT_TRANSACTION).record(siblingTransactionRecord).parent(parentRecordItem).build();
    var transactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setSeconds(5).setNanos(6).build()).setParentConsensusTimestamp(parentTransactionRecord.getConsensusTimestamp()).setReceipt(TransactionReceipt.newBuilder().setStatusValue(22).build()).setMemo("child").build();
    RecordItem recordItem = RecordItem.builder().hapiVersion(DEFAULT_HAPI_VERSION).transaction(DEFAULT_TRANSACTION).record(transactionRecord).previous(siblingRecordItem).build();
    // verify parent is picked up for a valid previous
    assertThat(recordItem).returns(parentRecordItem, RecordItem::getParent).satisfies(c -> assertThat(c.getParent()).isNotNull());
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) Test(org.junit.jupiter.api.Test)

Example 98 with Transaction

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

the class RecordItemTest method testWithBody.

@Test
void testWithBody() {
    Transaction transaction = Transaction.newBuilder().setBody(TRANSACTION_BODY).setSigMap(SIGNATURE_MAP).build();
    RecordItem recordItem = new RecordItem(DEFAULT_HAPI_VERSION, transaction, TRANSACTION_RECORD);
    assertRecordItem(transaction, recordItem);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) Test(org.junit.jupiter.api.Test)

Example 99 with Transaction

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

the class RecordItemTest method testWithNonMatchingPreviousTimestamp.

@Test
void testWithNonMatchingPreviousTimestamp() {
    Transaction transaction = Transaction.newBuilder().setSignedTransactionBytes(SIGNED_TRANSACTION.toByteString()).build();
    var parentTransactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setSeconds(1).setNanos(2).build()).setReceipt(TransactionReceipt.newBuilder().setStatusValue(22).build()).setMemo("parent").build();
    RecordItem previousRecordItem = new RecordItem(DEFAULT_HAPI_VERSION, transaction, parentTransactionRecord);
    var transactionRecord = TransactionRecord.newBuilder().setConsensusTimestamp(Timestamp.newBuilder().setSeconds(3).setNanos(4).build()).setParentConsensusTimestamp(Timestamp.newBuilder().setSeconds(5).setNanos(6).build()).setReceipt(TransactionReceipt.newBuilder().setStatusValue(22).build()).setMemo("child").build();
    RecordItem recordItem = RecordItem.builder().hapiVersion(DEFAULT_HAPI_VERSION).transaction(DEFAULT_TRANSACTION).record(transactionRecord).previous(previousRecordItem).build();
    // verify parent
    assertThat(recordItem.getParent()).isNull();
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) Test(org.junit.jupiter.api.Test)

Example 100 with Transaction

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

the class RecordItemTest method testWithBodyProto.

@Test
void testWithBodyProto() {
    // An encoded protobuf Transaction with the body set in TransactionBody, as seen in an older proto version
    byte[] transactionFromProto = Base64.decodeBase64("CgoYCjIEbWVtb3IAGhkKFwoMcHViS2V5UHJlZml4GgdlZDI1NTE5");
    Transaction expectedTransaction = Transaction.newBuilder().setBody(TRANSACTION_BODY).setSigMap(SIGNATURE_MAP).build();
    RecordItem recordItem = RecordItem.builder().hapiVersion(DEFAULT_HAPI_VERSION).transactionBytes(transactionFromProto).recordBytes(TRANSACTION_RECORD.toByteArray()).build();
    assertRecordItem(expectedTransaction, recordItem);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) SignedTransaction(com.hederahashgraph.api.proto.java.SignedTransaction) 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