Search in sources :

Example 16 with TransactionID

use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.

the class ScheduleSignResourceUsageTest method returnsDefaultIfInfoMissing.

@Test
void returnsDefaultIfInfoMissing() throws Exception {
    // setup:
    long start = 1_234_567L;
    TransactionID txnId = TransactionID.newBuilder().setTransactionValidStart(Timestamp.newBuilder().setSeconds(start)).build();
    given(scheduleSignTxn.getTransactionID()).willReturn(txnId);
    given(view.infoForSchedule(target)).willReturn(Optional.empty());
    given(scheduleOpsUsage.scheduleSignUsage(scheduleSignTxn, sigUsage, start + 1800)).willReturn(expected);
    // expect:
    assertEquals(expected, subject.usageGiven(scheduleSignTxn, obj, view));
    // and:
    verify(view).infoForSchedule(target);
}
Also used : TransactionID(com.hederahashgraph.api.proto.java.TransactionID) Test(org.junit.jupiter.api.Test)

Example 17 with TransactionID

use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.

the class ContextOptionValidatorTest method recognizesExpiredCondition.

@Test
void recognizesExpiredCondition() {
    SignedTxnAccessor accessor = mock(SignedTxnAccessor.class);
    // given:
    long validDuration = 1_000L;
    Instant validStart = Instant.ofEpochSecond(1_234_567L);
    Instant consensusTime = Instant.ofEpochSecond(validStart.getEpochSecond() + validDuration + 1);
    // and:
    TransactionID txnId = TransactionID.newBuilder().setTransactionValidStart(Timestamp.newBuilder().setSeconds(validStart.getEpochSecond())).build();
    TransactionBody txn = TransactionBody.newBuilder().setTransactionID(txnId).setTransactionValidDuration(Duration.newBuilder().setSeconds(validDuration)).build();
    // and:
    given(accessor.getTxn()).willReturn(txn);
    given(accessor.getTxnId()).willReturn(txnId);
    // when:
    ResponseCodeEnum status = subject.chronologyStatus(accessor, consensusTime);
    // then:
    assertEquals(TRANSACTION_EXPIRED, status);
    // and:
    assertEquals(TRANSACTION_EXPIRED, subject.chronologyStatusForTxn(validStart, validDuration, consensusTime));
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) Instant(java.time.Instant) SignedTxnAccessor(com.hedera.services.utils.SignedTxnAccessor) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) Test(org.junit.jupiter.api.Test)

Example 18 with TransactionID

use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-services by hashgraph.

the class HapiSpecOperation method registerTxnSubmitted.

private void registerTxnSubmitted(HapiApiSpec spec) throws Throwable {
    if (txnSubmitted != Transaction.getDefaultInstance()) {
        spec.registry().saveBytes(txnName, txnSubmitted.toByteString());
        TransactionID txnId = extractTxnId(txnSubmitted);
        spec.registry().saveTxnId(txnName, txnId);
    }
}
Also used : TransactionID(com.hederahashgraph.api.proto.java.TransactionID)

Example 19 with TransactionID

use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTopicTest method submitMessageTestInvalidChunkInfo.

@Test
void submitMessageTestInvalidChunkInfo() {
    // given
    var id = 10_000_000L;
    var topicId = TopicID.newBuilder().setTopicNum(9000).build();
    var scheduled = false;
    var nonce = 0;
    TransactionID initialTransactionId = createTransactionID(null, TestUtils.toTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE), scheduled, nonce);
    var transaction = createSubmitMessageTransaction(topicId, "message", 3, 5, initialTransactionId);
    var transactionRecord = createTransactionRecord(topicId, 10_000L, "running-hash".getBytes(), 2, id, SUCCESS);
    // when
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    // then
    assertEquals(0L, entityRepository.count());
    assertEquals(1L, topicMessageRepository.count());
    assertThat(topicMessageRepository.findById(id)).get().extracting(TopicMessage::getValidStartTimestamp, TopicMessage::getPayerAccountId).containsExactly(null, PAYER_ACCOUNT_ID);
}
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 20 with TransactionID

use of com.hederahashgraph.api.proto.java.TransactionID in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTopicTest method submitMessageTest.

@ParameterizedTest
@CsvSource({ "0.0.9000, test-message0, 9000000, runninghash, 1, 1, , , , false, 0", "0.0.9001, test-message1, 9000001, runninghash1, 9223372036854775807, 2, 1, 1, 89999999, false, 0", "0.0.9001, test-message2, 9000001, runninghash2, 9223372036854775807, 2, 2, 4, 89999999, false, 0", "0.0.9001, test-message3, 9000001, runninghash3, 9223372036854775807, 2, 4, 4, 89999999, false, 0", "0.0.9001, test-message4, 9000001, runninghash3, 9223372036854775807, 2, 4, 4, 89999999, true, 7" })
void submitMessageTest(@ConvertWith(TopicIdArgumentConverter.class) TopicID topicId, String message, long consensusTimestamp, String runningHash, long sequenceNumber, int runningHashVersion, Integer chunkNum, Integer chunkTotal, Long validStartNs, Boolean scheduled, Integer nonce) {
    var responseCode = SUCCESS;
    TransactionID initialTransactionId = null;
    if (chunkNum != null) {
        initialTransactionId = createTransactionID(PAYER_ACCOUNT_ID.getEntityNum(), TestUtils.toTimestamp(validStartNs), scheduled, nonce);
    }
    var topicMessage = createTopicMessage(topicId, message, sequenceNumber, runningHash, consensusTimestamp, runningHashVersion, chunkNum, chunkTotal, PAYER_ACCOUNT_ID, initialTransactionId);
    var transaction = createSubmitMessageTransaction(topicId, message, chunkNum, chunkTotal, initialTransactionId);
    var transactionRecord = createTransactionRecord(topicId, sequenceNumber, runningHash.getBytes(), runningHashVersion, consensusTimestamp, responseCode);
    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));
    assertTransactionInRepository(responseCode, consensusTimestamp, topicId.getTopicNum());
    assertEquals(0L, entityRepository.count());
    assertThat(topicMessageRepository.findById(consensusTimestamp)).get().isEqualTo(topicMessage);
}
Also used : RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) TransactionID(com.hederahashgraph.api.proto.java.TransactionID) CsvSource(org.junit.jupiter.params.provider.CsvSource) 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