Search in sources :

Example 11 with SignedTxnAccessor

use of com.hedera.services.utils.SignedTxnAccessor 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)

Aggregations

SignedTxnAccessor (com.hedera.services.utils.SignedTxnAccessor)11 Test (org.junit.jupiter.api.Test)8 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)3 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)3 TransactionID (com.hederahashgraph.api.proto.java.TransactionID)3 Instant (java.time.Instant)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 TxnValidityAndFeeReq (com.hedera.services.context.domain.process.TxnValidityAndFeeReq)1 StateView (com.hedera.services.context.primitives.StateView)1 HbarCentExchange (com.hedera.services.fees.HbarCentExchange)1 PricedUsageCalculator (com.hedera.services.fees.calculation.utils.PricedUsageCalculator)1 RecordCache (com.hedera.services.records.RecordCache)1 MiscSpeedometers (com.hedera.services.stats.MiscSpeedometers)1 HederaFunctionality (com.hederahashgraph.api.proto.java.HederaFunctionality)1 Query (com.hederahashgraph.api.proto.java.Query)1 FeeObject (com.hederahashgraph.fee.FeeObject)1 Platform (com.swirlds.common.Platform)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1