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();
}
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());
}
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);
}
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();
}
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);
}
Aggregations