use of com.hedera.mirror.common.domain.transaction.RecordItem 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);
}
use of com.hedera.mirror.common.domain.transaction.RecordItem 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.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class AbstractTransactionHandlerTest method testGetEntityIdHelper.
protected void testGetEntityIdHelper(TransactionBody transactionBody, TransactionRecord transactionRecord, EntityId expectedEntity) {
RecordItem recordItem = new RecordItem(Transaction.newBuilder().setSignedTransactionBytes(SignedTransaction.newBuilder().setBodyBytes(transactionBody.toByteString()).setSigMap(getDefaultSigMap()).build().toByteString()).build(), transactionRecord);
assertThat(transactionHandler.getEntity(recordItem)).isEqualTo(expectedEntity);
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class CryptoUpdateTransactionHandlerTest method updateTransactionStakedNodeId.
@Test
void updateTransactionStakedNodeId() {
RecordItem withStakedNodeIdSet = recordItemBuilder.cryptoUpdate().transactionBody(body -> body.setStakedNodeId(1L)).build();
setupForCrytoUpdateTransactionTest(withStakedNodeIdSet, t -> assertThat(t).returns(1L, Entity::getStakedNodeId).returns(-1L, Entity::getStakedAccountId).returns(true, Entity::isDeclineReward).extracting(Entity::getStakePeriodStart).isNotNull());
}
use of com.hedera.mirror.common.domain.transaction.RecordItem in project hedera-mirror-node by hashgraph.
the class CryptoUpdateTransactionHandlerTest method updateTransactionDeclineReward.
@Test
void updateTransactionDeclineReward() {
RecordItem withDeclineValueSet = recordItemBuilder.cryptoUpdate().transactionBody(body -> body.clear().setDeclineReward(BoolValue.of(true))).build();
setupForCrytoUpdateTransactionTest(withDeclineValueSet, t -> assertThat(t).returns(true, Entity::isDeclineReward).returns(null, Entity::getStakedNodeId).returns(null, Entity::getStakedAccountId).extracting(Entity::getStakePeriodStart).isNotNull());
}
Aggregations