use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class HapiTxnOp method resolvedStatusOfSubmission.
private ResponseCodeEnum resolvedStatusOfSubmission(HapiApiSpec spec) throws Throwable {
long delayMS = spec.setup().statusPreResolvePauseMs();
long elapsedMS = System.currentTimeMillis() - submitTime;
if (elapsedMS <= delayMS) {
pause(delayMS - elapsedMS);
}
long beginWait = Instant.now().toEpochMilli();
Query receiptQuery = txnReceiptQueryFor(extractTxnId(txnSubmitted));
do {
Response response = statusResponse(spec, receiptQuery);
lastReceipt = response.getTransactionGetReceipt().getReceipt();
ResponseCodeEnum statusNow = lastReceipt.getStatus();
if (acceptAnyStatus) {
expectedStatus = Optional.of(statusNow);
return statusNow;
} else if (statusNow != UNKNOWN) {
if (acceptAnyKnownStatus) {
expectedStatus = Optional.of(statusNow);
}
return statusNow;
}
pause(spec.setup().statusWaitSleepMs());
} while ((Instant.now().toEpochMilli() - beginWait) < spec.setup().statusWaitTimeoutMs());
return UNKNOWN;
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetContractInfoAnswerTest method allowsQueryingDeletedContracts.
@Test
void allowsQueryingDeletedContracts() throws Throwable {
Query query = validQuery(COST_ANSWER, fee, target);
given(optionValidator.queryableContractStatus(asContract(target), contracts)).willReturn(CONTRACT_DELETED);
given(view.contracts()).willReturn(contracts);
ResponseCodeEnum validity = subject.checkValidity(query, view);
assertEquals(OK, validity);
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method answersWithAccountBalanceWhenTheAccountIDIsContractID.
@Test
void answersWithAccountBalanceWhenTheAccountIDIsContractID() {
// setup:
ContractID id = asContract(accountIdLit);
// given:
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setContractID(id).build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
// when:
Response response = subject.responseGiven(query, view, OK);
ResponseCodeEnum status = response.getCryptogetAccountBalance().getHeader().getNodeTransactionPrecheckCode();
long answer = response.getCryptogetAccountBalance().getBalance();
// expect:
assertTrue(response.getCryptogetAccountBalance().hasHeader(), "Missing response header!");
assertEquals(List.of(tokenBalanceWith(aToken, aBalance, 1), tokenBalanceWith(bToken, bBalance, 2), tokenBalanceWith(cToken, cBalance, 123), tokenBalanceWith(dToken, dBalance, 0)), response.getCryptogetAccountBalance().getTokenBalancesList());
assertEquals(OK, status);
assertEquals(balance, answer);
assertEquals(asAccount(accountIdLit), response.getCryptogetAccountBalance().getAccountID());
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method answersWithAccountBalance.
@Test
void answersWithAccountBalance() {
AccountID id = asAccount(accountIdLit);
// given:
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setAccountID(id).build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
// when:
Response response = subject.responseGiven(query, view, OK);
ResponseCodeEnum status = response.getCryptogetAccountBalance().getHeader().getNodeTransactionPrecheckCode();
long answer = response.getCryptogetAccountBalance().getBalance();
// expect:
assertTrue(response.getCryptogetAccountBalance().hasHeader(), "Missing response header!");
assertEquals(List.of(tokenBalanceWith(aToken, aBalance, 1), tokenBalanceWith(bToken, bBalance, 2), tokenBalanceWith(cToken, cBalance, 123), tokenBalanceWith(dToken, dBalance, 0)), response.getCryptogetAccountBalance().getTokenBalancesList());
assertEquals(OK, status);
assertEquals(balance, answer);
assertEquals(id, response.getCryptogetAccountBalance().getAccountID());
}
use of com.hederahashgraph.api.proto.java.ResponseCodeEnum in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method syntaxCheckValidatesCidIfPresent.
@Test
void syntaxCheckValidatesCidIfPresent() {
// setup:
ContractID cid = asContract(contractIdLit);
// given:
CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setContractID(cid).build();
Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
// and:
given(optionValidator.queryableContractStatus(cid, accounts)).willReturn(CONTRACT_DELETED);
// when:
ResponseCodeEnum status = subject.checkValidity(query, view);
// expect:
assertEquals(CONTRACT_DELETED, status);
}
Aggregations