use of com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse in project hedera-services by hashgraph.
the class GetTxnReceiptAnswerTest method shortCircuitsToAnswerOnly.
@Test
void shortCircuitsToAnswerOnly() {
// setup:
Query sensibleQuery = queryWith(validTxnId, ResponseType.COST_ANSWER);
given(recordCache.getPriorityReceipt(validTxnId)).willReturn(receipt);
// 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());
assertTrue(opResponse.getDuplicateTransactionReceiptsList().isEmpty());
verify(recordCache, never()).getDuplicateReceipts(any());
}
use of com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse 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.TransactionGetReceiptResponse 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.TransactionGetReceiptResponse in project hedera-services by hashgraph.
the class GetTxnReceiptAnswerTest method returnsDuplicatesIfRequested.
@Test
void returnsDuplicatesIfRequested() {
// setup:
Query sensibleQuery = queryWith(validTxnId, ANSWER_ONLY, true);
var duplicateReceipts = List.of(duplicateReceipt.toGrpc(), unclassifiableReceipt.toGrpc());
given(recordCache.getPriorityReceipt(validTxnId)).willReturn(receipt);
given(recordCache.getDuplicateReceipts(validTxnId)).willReturn(duplicateReceipts);
// 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(duplicateReceipts, opResponse.getDuplicateTransactionReceiptsList());
}
use of com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse in project hedera-services by hashgraph.
the class GetTxnReceiptAnswerTest method respectsMetaValidity.
@Test
void respectsMetaValidity() {
// given:
Query sensibleQuery = queryWith(validTxnId);
// when:
Response response = subject.responseGiven(sensibleQuery, view, INVALID_TRANSACTION, 0L);
// then:
TransactionGetReceiptResponse opResponse = response.getTransactionGetReceipt();
assertEquals(INVALID_TRANSACTION, opResponse.getHeader().getNodeTransactionPrecheckCode());
// and:
verify(recordCache, never()).isReceiptPresent(any());
}
Aggregations