use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class TxnFactory method defaultBodySpec.
public Consumer<TransactionBody.Builder> defaultBodySpec() {
TransactionID defaultTxnId = defaultTransactionID();
if (r.nextDouble() < TXN_ID_SAMPLE_PROBABILITY) {
sampleTxnId.set(defaultTxnId);
}
final var memoToUse = (setup.isMemoUTF8() == TRUE) ? setup.defaultUTF8memo() : setup.defaultMemo();
return builder -> builder.setTransactionID(defaultTxnId).setMemo(memoToUse).setTransactionFee(setup.defaultFee()).setTransactionValidDuration(setup.defaultValidDuration()).setNodeAccountID(setup.defaultNode());
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class HapiGetReceipt method submitWith.
@Override
protected void submitWith(HapiApiSpec spec, Transaction payment) {
TransactionID txnId = explicitTxnId.orElseGet(() -> useDefaultTxnId ? defaultTxnId : spec.registry().getTxnId(txn));
Query query = forgetOp ? Query.newBuilder().build() : txnReceiptQueryFor(txnId, requestDuplicates, getChildReceipts);
response = spec.clients().getCryptoSvcStub(targetNodeFor(spec), useTls).getTransactionReceipts(query);
childReceipts = response.getTransactionGetReceipt().getChildTransactionReceiptsList();
if (verboseLoggingOn) {
log.info("Receipt: " + response.getTransactionGetReceipt().getReceipt());
log.info(spec.logPrefix() + " And {} child receipts{}: {}", childReceipts.size(), childReceipts.size() > 1 ? "s" : "", childReceipts);
}
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.
the class HapiGetTxnRecord method getRecordQuery.
private Query getRecordQuery(HapiApiSpec spec, Transaction payment, boolean costOnly) {
TransactionID txnId = useDefaultTxnId ? defaultTxnId : explicitTxnId.orElseGet(() -> spec.registry().getTxnId(txn));
if (lookupScheduledFromRegistryId) {
txnId = spec.registry().getTxnId(correspondingScheduledTxnId(creationName.get()));
} else {
if (scheduled) {
txnId = txnId.toBuilder().setScheduled(true).build();
}
}
QueryHeader header;
if (costOnly && omitPaymentHeaderOnCostAnswer) {
header = QueryHeader.newBuilder().setResponseType(COST_ANSWER).build();
} else {
header = costOnly ? answerCostHeader(payment) : answerHeader(payment);
}
TransactionGetRecordQuery getRecordQuery = TransactionGetRecordQuery.newBuilder().setHeader(header).setTransactionID(txnId).setIncludeDuplicates(requestDuplicates).setIncludeChildRecords(requestChildRecords).build();
return Query.newBuilder().setTransactionGetRecord(getRecordQuery).build();
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTopicTest method submitMessageToInvalidTopicEntityNotCreated.
@Test
void submitMessageToInvalidTopicEntityNotCreated() {
var responseCode = ResponseCodeEnum.INVALID_TOPIC_ID;
var consensusTimestamp = 10_000_000L;
var message = "message";
var sequenceNumber = 10_000L;
var runningHash = "running-hash";
var runningHashVersion = 2;
var chunkNum = 3;
var chunkTotal = 5;
var validStartNs = 7L;
var scheduled = false;
var nonce = 0;
var topic = createTopicEntity(TOPIC_ID, null, null, null, null, "", null, null);
// Topic NOT saved in the repository.
TransactionID initialTransactionId = createTransactionID(PAYER_ACCOUNT_ID.getEntityNum(), TestUtils.toTimestamp(validStartNs), scheduled, nonce);
createTopicMessage(TOPIC_ID, message, sequenceNumber, runningHash, consensusTimestamp, runningHashVersion, chunkNum, chunkTotal, PAYER_ACCOUNT_ID, initialTransactionId);
var transaction = createSubmitMessageTransaction(TOPIC_ID, message, chunkNum, chunkTotal, initialTransactionId);
var transactionRecord = createTransactionRecord(TOPIC_ID, sequenceNumber, runningHash.getBytes(), runningHashVersion, consensusTimestamp, responseCode);
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
assertTransactionInRepository(responseCode, consensusTimestamp, TOPIC_ID.getTopicNum());
assertEquals(0, entityRepository.count());
assertEquals(0, topicMessageRepository.count());
}
use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListenerTopicTest method submitMessageTestTopicError.
@Test
void submitMessageTestTopicError() {
var responseCode = ResponseCodeEnum.INVALID_TOPIC_ID;
var consensusTimestamp = 11_000_000L;
var message = "message";
var sequenceNumber = 11_000L;
var runningHash = "running-hash";
var runningHashVersion = 2;
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(TOPIC_ID, message, chunkNum, chunkTotal, initialTransactionId);
var transactionRecord = createTransactionRecord(TOPIC_ID, sequenceNumber, runningHash.getBytes(), runningHashVersion, consensusTimestamp, responseCode);
parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
assertTransactionInRepository(responseCode, consensusTimestamp, TOPIC_ID.getTopicNum());
assertEquals(0, entityRepository.count());
assertEquals(0L, topicMessageRepository.count());
}
Aggregations