use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetTxnReceiptAnswerTest method expectsNonDefaultTransactionId.
@Test
void expectsNonDefaultTransactionId() {
// setup:
Query nonsenseQuery = queryWith(TransactionID.getDefaultInstance());
Query sensibleQuery = queryWith(validTxnId);
// expect:
assertEquals(OK, subject.checkValidity(sensibleQuery, view));
assertEquals(INVALID_TRANSACTION_ID, subject.checkValidity(nonsenseQuery, view));
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetTxnReceiptAnswerTest method returnsChildrenIfRequested.
@Test
void returnsChildrenIfRequested() {
// setup:
Query sensibleQuery = queryWith(validTxnId, ANSWER_ONLY, false, true);
var childReceipts = List.of(duplicateReceipt.toGrpc(), unclassifiableReceipt.toGrpc());
given(recordCache.getPriorityReceipt(validTxnId)).willReturn(receipt);
given(recordCache.getChildReceipts(validTxnId)).willReturn(childReceipts);
// when:
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
// then:
TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
assertTrue(opResponse.hasHeader(), "Missing response header!");
assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
assertEquals(ANSWER_ONLY, opResponse.getHeader().getResponseType());
assertEquals(receipt.toGrpc(), opResponse.getReceipt());
assertEquals(childReceipts, opResponse.getChildTransactionReceiptsList());
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetTxnReceiptAnswerTest method rejectsQueryForMissingReceipt.
@Test
void rejectsQueryForMissingReceipt() {
// setup:
Query sensibleQuery = queryWith(validTxnId);
given(recordCache.getPriorityReceipt(validTxnId)).willReturn(null);
// when:
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
// then:
TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
assertEquals(RECEIPT_NOT_FOUND, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method requiresNothing.
@Test
void requiresNothing() {
// setup:
CryptoGetAccountBalanceQuery costAnswerOp = CryptoGetAccountBalanceQuery.newBuilder().setHeader(QueryHeader.newBuilder().setResponseType(ResponseType.COST_ANSWER)).build();
Query costAnswerQuery = Query.newBuilder().setCryptogetAccountBalance(costAnswerOp).build();
CryptoGetAccountBalanceQuery answerOnlyOp = CryptoGetAccountBalanceQuery.newBuilder().setHeader(QueryHeader.newBuilder().setResponseType(ResponseType.ANSWER_ONLY)).build();
Query answerOnlyQuery = Query.newBuilder().setCryptogetAccountBalance(answerOnlyOp).build();
// expect:
assertFalse(subject.requiresNodePayment(costAnswerQuery));
assertFalse(subject.requiresNodePayment(answerOnlyQuery));
assertFalse(subject.needsAnswerOnlyCost(answerOnlyQuery));
assertFalse(subject.needsAnswerOnlyCost(costAnswerQuery));
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetAccountBalanceAnswerTest method requiresOkMetaValidity.
@Test
void requiresOkMetaValidity() {
// setup:
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, PLATFORM_NOT_ACTIVE);
ResponseCodeEnum status = response.getCryptogetAccountBalance().getHeader().getNodeTransactionPrecheckCode();
// expect:
assertEquals(PLATFORM_NOT_ACTIVE, status);
assertEquals(id, response.getCryptogetAccountBalance().getAccountID());
}
Aggregations