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));
}
Aggregations