Search in sources :

Example 6 with TransactionID

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());
}
Also used : CryptoDeleteTransactionBody(com.hederahashgraph.api.proto.java.CryptoDeleteTransactionBody) FileDeleteTransactionBody(com.hederahashgraph.api.proto.java.FileDeleteTransactionBody) Arrays(java.util.Arrays) TokenUnpauseTransactionBody(com.hederahashgraph.api.proto.java.TokenUnpauseTransactionBody) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) TokenDeleteTransactionBody(com.hederahashgraph.api.proto.java.TokenDeleteTransactionBody) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) ScheduleCreateTransactionBody(com.hederahashgraph.api.proto.java.ScheduleCreateTransactionBody) TokenRevokeKycTransactionBody(com.hederahashgraph.api.proto.java.TokenRevokeKycTransactionBody) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) ScheduleDeleteTransactionBody(com.hederahashgraph.api.proto.java.ScheduleDeleteTransactionBody) ConsensusDeleteTopicTransactionBody(com.hederahashgraph.api.proto.java.ConsensusDeleteTopicTransactionBody) SplittableRandom(java.util.SplittableRandom) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) Method(java.lang.reflect.Method) CryptoCreateTransactionBody(com.hederahashgraph.api.proto.java.CryptoCreateTransactionBody) CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) SystemDeleteTransactionBody(com.hederahashgraph.api.proto.java.SystemDeleteTransactionBody) CryptoTransferTransactionBody(com.hederahashgraph.api.proto.java.CryptoTransferTransactionBody) TokenPauseTransactionBody(com.hederahashgraph.api.proto.java.TokenPauseTransactionBody) ConsensusUpdateTopicTransactionBody(com.hederahashgraph.api.proto.java.ConsensusUpdateTopicTransactionBody) Instant(java.time.Instant) Collectors.joining(java.util.stream.Collectors.joining) ByteString(com.google.protobuf.ByteString) KeyFactory(com.hedera.services.bdd.spec.keys.KeyFactory) List(java.util.List) SystemUndeleteTransactionBody(com.hederahashgraph.api.proto.java.SystemUndeleteTransactionBody) Stream(java.util.stream.Stream) TokenFeeScheduleUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenFeeScheduleUpdateTransactionBody) ConsensusSubmitMessageTransactionBody(com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody) ContractDeleteTransactionBody(com.hederahashgraph.api.proto.java.ContractDeleteTransactionBody) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) TRUE(com.hedera.services.bdd.spec.HapiApiSpec.UTF8Mode.TRUE) Transaction(com.hederahashgraph.api.proto.java.Transaction) IntStream(java.util.stream.IntStream) TxnUtils.getUniqueTimestampPlusSecs(com.hedera.services.bdd.spec.transactions.TxnUtils.getUniqueTimestampPlusSecs) UncheckedSubmitBody(com.hederahashgraph.api.proto.java.UncheckedSubmitBody) TokenAssociateTransactionBody(com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody) AtomicReference(java.util.concurrent.atomic.AtomicReference) ScheduleSignTransactionBody(com.hederahashgraph.api.proto.java.ScheduleSignTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FreezeTransactionBody(com.hederahashgraph.api.proto.java.FreezeTransactionBody) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) FileCreateTransactionBody(com.hederahashgraph.api.proto.java.FileCreateTransactionBody) TokenGrantKycTransactionBody(com.hederahashgraph.api.proto.java.TokenGrantKycTransactionBody) TokenUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody) TokenCreateTransactionBody(com.hederahashgraph.api.proto.java.TokenCreateTransactionBody) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) CryptoAdjustAllowanceTransactionBody(com.hederahashgraph.api.proto.java.CryptoAdjustAllowanceTransactionBody) Consumer(java.util.function.Consumer) ConsensusCreateTopicTransactionBody(com.hederahashgraph.api.proto.java.ConsensusCreateTopicTransactionBody) Collectors.toList(java.util.stream.Collectors.toList) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) TokenUnfreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenUnfreezeAccountTransactionBody) Message(com.google.protobuf.Message) TokenWipeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenWipeAccountTransactionBody) Clock(java.time.Clock) TokenDissociateTransactionBody(com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody) TokenBurnTransactionBody(com.hederahashgraph.api.proto.java.TokenBurnTransactionBody) TokenFreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenFreezeAccountTransactionBody) CryptoApproveAllowanceTransactionBody(com.hederahashgraph.api.proto.java.CryptoApproveAllowanceTransactionBody) TransactionID(com.hederahashgraph.api.proto.java.TransactionID)

Example 7 with TransactionID

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);
    }
}
Also used : Query(com.hederahashgraph.api.proto.java.Query) TransactionID(com.hederahashgraph.api.proto.java.TransactionID)

Example 8 with TransactionID

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();
}
Also used : QueryHeader(com.hederahashgraph.api.proto.java.QueryHeader) TransactionGetRecordQuery(com.hederahashgraph.api.proto.java.TransactionGetRecordQuery) TransactionID(com.hederahashgraph.api.proto.java.TransactionID)

Example 9 with TransactionID

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());
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with TransactionID

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());
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TransactionID (com.hederahashgraph.api.proto.java.TransactionID)21 Test (org.junit.jupiter.api.Test)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)7 Instant (java.time.Instant)5 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)4 ByteString (com.google.protobuf.ByteString)3 HapiSpecSetup (com.hedera.services.bdd.spec.HapiSpecSetup)3 AccountID (com.hederahashgraph.api.proto.java.AccountID)3 List (java.util.List)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)2 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)2 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)2 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)2 QueryVerbs.getAccountInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo)2 QueryVerbs.getScheduleInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getScheduleInfo)2 QueryVerbs.getTokenInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo)2 QueryVerbs.getTopicInfo (com.hedera.services.bdd.spec.queries.QueryVerbs.getTopicInfo)2 QueryVerbs.getTxnRecord (com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord)2