use of com.hederahashgraph.api.proto.java.ResponseCodeEnum 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));
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class FeesAndRatesProvider method downloadWith.
private FileGetContentsResponse downloadWith(long queryFee, boolean costOnly, FileID fid) throws Throwable {
int attemptsLeft = NUM_DOWNLOAD_ATTEMPTS;
ResponseCodeEnum status;
FileGetContentsResponse response;
do {
var payment = defaultPayerSponsored(queryFee);
var query = downloadQueryWith(payment, costOnly, fid);
response = clients.getFileSvcStub(setup.defaultNode(), setup.getConfigTLS()).getFileContent(query).getFileGetContents();
status = response.getHeader().getNodeTransactionPrecheckCode();
if (status == OK) {
break;
} else {
log.warn("'{}' download attempt paid with {} got status {}, retrying...", asFileString(fid), toReadableString(payment), status);
}
} while (--attemptsLeft > 0);
if (status != OK) {
throw new IllegalStateException(String.format("Could not download '%s' final status %s", asFileString(fid), status));
}
return response;
}
Aggregations