use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class HapiMessageSubmit method resolveTopicId.
private TopicID resolveTopicId(HapiApiSpec spec) {
if (topicFn.isPresent()) {
TopicID topicID = topicFn.get().apply(spec);
topic = Optional.of(HapiPropertySource.asTopicString(topicID));
return topicID;
}
if (topic.isPresent()) {
return asTopicId(topic.get(), spec);
}
return TopicID.getDefaultInstance();
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class HapiMessageSubmit method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
TopicID id = resolveTopicId(spec);
ConsensusSubmitMessageTransactionBody opBody = spec.txns().<ConsensusSubmitMessageTransactionBody, ConsensusSubmitMessageTransactionBody.Builder>body(ConsensusSubmitMessageTransactionBody.class, b -> {
b.setTopicID(id);
message.ifPresent(m -> b.setMessage(m));
if (clearMessage) {
b.clearMessage();
}
if (totalChunks.isPresent() && chunkNumber.isPresent()) {
ConsensusMessageChunkInfo chunkInfo = ConsensusMessageChunkInfo.newBuilder().setInitialTransactionID(initialTransactionID.orElse(asTransactionID(spec, initialTransactionPayer.isPresent() ? initialTransactionPayer : payer))).setTotal(totalChunks.getAsInt()).setNumber(chunkNumber.getAsInt()).build();
b.setChunkInfo(chunkInfo);
spec.registry().saveTimestamp(txnName, chunkInfo.getInitialTransactionID().getTransactionValidStart());
}
});
return b -> b.setConsensusSubmitMessage(opBody);
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-services by hashgraph.
the class HapiTopicDelete method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
TopicID id = resolveTopicId(spec);
ConsensusDeleteTopicTransactionBody opBody = spec.txns().<ConsensusDeleteTopicTransactionBody, ConsensusDeleteTopicTransactionBody.Builder>body(ConsensusDeleteTopicTransactionBody.class, b -> {
b.setTopicID(id);
});
return b -> b.setConsensusDeleteTopic(opBody);
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTopicTest method submitMessageTestFiltered.
@Test
void submitMessageTestFiltered() {
// given
var responseCode = SUCCESS;
var topicId = (TopicID) new TopicIdArgumentConverter().convert("0.0.999", // excluded in application-default.yml
null);
var consensusTimestamp = 10_000_000L;
var message = "message";
var sequenceNumber = 10_000L;
var runningHash = "running-hash";
var runningHashVersion = 1;
var chunkNum = 3;
var chunkTotal = 5;
var validStartNs = 7L;
var scheduled = false;
var nonce = 0;
TransactionID initialTransactionId = createTransactionID(PAYER_ACCOUNT_ID.getEntityNum(), TestUtils.toTimestamp(validStartNs), scheduled, nonce);
var transaction = createSubmitMessageTransaction(topicId, message, chunkNum, chunkTotal, initialTransactionId);
var transactionRecord = createTransactionRecord(topicId, sequenceNumber, runningHash.getBytes(), runningHashVersion, consensusTimestamp, responseCode);
// when
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
// then
// if the transaction is filtered out, nothing in it should affect the state
assertEquals(0L, entityRepository.count());
assertEquals(0L, topicMessageRepository.count());
}
use of com.hederahashgraph.api.proto.java.TopicID in project hedera-mirror-node by hashgraph.
the class PubSubRecordItemListenerTest method testPubSubMessage.
@Test
void testPubSubMessage() 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(topicIdEntity).when(transactionHandler).getEntity(any());
pubSubRecordItemListener.onItem(new RecordItem(transaction, DEFAULT_RECORD));
// then
var pubSubMessage = assertPubSubMessage(buildPubSubTransaction(transaction), 1);
assertThat(pubSubMessage.getEntity()).isEqualTo(topicIdEntity);
assertThat(pubSubMessage.getNonFeeTransfers()).isNull();
}
Aggregations