use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetTokenNftInfoAnswerTest method validatesInvalidNftIdInContext.
@Test
void validatesInvalidNftIdInContext() throws Throwable {
// setup:
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, nftId);
Map<String, Object> ctx = new HashMap<>();
// when:
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L, ctx);
// then:
var opResponse = response.getTokenGetNftInfo();
assertTrue(opResponse.hasHeader(), "Missing response header!");
assertEquals(INVALID_NFT_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
// and:
verify(view, never()).infoForNft(any());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetTokenNftInfosAnswerTest method respectsTypeOfUnsupportedQuery.
@Test
void respectsTypeOfUnsupportedQuery() {
// given:
Query costAnswer = getQuery(COST_ANSWER);
Query answerOnly = getQuery(ANSWER_ONLY);
// when:
Response costAnswerResponse = subject.responseGiven(costAnswer, StateView.EMPTY_VIEW, OK, 0L);
Response answerOnlyResponse = subject.responseGiven(answerOnly, StateView.EMPTY_VIEW, OK, 0L);
// then:
assertEquals(COST_ANSWER, costAnswerResponse.getTokenGetNftInfos().getHeader().getResponseType());
assertEquals(ANSWER_ONLY, answerOnlyResponse.getTokenGetNftInfos().getHeader().getResponseType());
// and:
assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(costAnswerResponse));
assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(answerOnlyResponse));
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetTokenNftInfosAnswerTest method extractsValidity.
@Test
void extractsValidity() {
// given:
Response response = Response.newBuilder().setTokenGetNftInfos(TokenGetNftInfosResponse.newBuilder().setHeader(ResponseHeader.newBuilder().setNodeTransactionPrecheckCode(FAIL_FEE))).build();
// expect:
assertEquals(FAIL_FEE, subject.extractValidityFrom(response));
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetFastTxnRecordAnswerTest method extractsValidity.
@Test
void extractsValidity() {
// given:
Response response = Response.newBuilder().setTransactionGetFastRecord(TransactionGetFastRecordResponse.newBuilder().setHeader(ResponseHeader.newBuilder().setNodeTransactionPrecheckCode(FAIL_FEE))).build();
// expect:
assertEquals(FAIL_FEE, subject.extractValidityFrom(response));
}
use of com.hederahashgraph.api.proto.java.Response 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());
}
Aggregations