use of com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery in project hedera-services by hashgraph.
the class GetTxnReceiptAnswer method responseGiven.
@Override
public Response responseGiven(Query query, StateView view, ResponseCodeEnum validity, long cost) {
TransactionGetReceiptQuery op = query.getTransactionGetReceipt();
TransactionGetReceiptResponse.Builder opResponse = TransactionGetReceiptResponse.newBuilder();
if (validity == OK) {
var txnId = op.getTransactionID();
var receipt = recordCache.getPriorityReceipt(txnId);
if (receipt == null) {
validity = RECEIPT_NOT_FOUND;
} else {
opResponse.setReceipt(receipt.toGrpc());
if (op.getIncludeDuplicates()) {
opResponse.addAllDuplicateTransactionReceipts(recordCache.getDuplicateReceipts(txnId));
}
if (op.getIncludeChildReceipts()) {
opResponse.addAllChildTransactionReceipts(recordCache.getChildReceipts(txnId));
}
}
}
opResponse.setHeader(answerOnlyHeader(validity));
return Response.newBuilder().setTransactionGetReceipt(opResponse).build();
}
use of com.hederahashgraph.api.proto.java.TransactionGetReceiptQuery in project hedera-services by hashgraph.
the class GetTxnReceiptAnswerTest method requiresNothing.
@Test
void requiresNothing() {
// setup:
TransactionGetReceiptQuery costAnswerOp = TransactionGetReceiptQuery.newBuilder().setHeader(QueryHeader.newBuilder().setResponseType(ResponseType.COST_ANSWER)).build();
Query costAnswerQuery = Query.newBuilder().setTransactionGetReceipt(costAnswerOp).build();
TransactionGetReceiptQuery answerOnlyOp = TransactionGetReceiptQuery.newBuilder().setHeader(QueryHeader.newBuilder().setResponseType(ANSWER_ONLY)).build();
Query answerOnlyQuery = Query.newBuilder().setTransactionGetReceipt(answerOnlyOp).build();
// expect:
assertFalse(subject.requiresNodePayment(costAnswerQuery));
assertFalse(subject.requiresNodePayment(answerOnlyQuery));
assertFalse(subject.needsAnswerOnlyCost(answerOnlyQuery));
assertFalse(subject.needsAnswerOnlyCost(costAnswerQuery));
}
Aggregations