use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetExecTimeAnswerTest method helpersWork.
@Test
void helpersWork() throws Throwable {
Query query = validQuery(ANSWER_ONLY, 5L);
Response response = Response.newBuilder().setNetworkGetExecutionTime(NetworkGetExecutionTimeResponse.newBuilder().setHeader(ResponseHeader.newBuilder().setNodeTransactionPrecheckCode(INVALID_TRANSACTION_ID))).build();
final var payment = subject.extractPaymentFrom(query);
assertTrue(payment.isPresent());
assertFalse(subject.needsAnswerOnlyCost(query));
assertEquals(INVALID_TRANSACTION_ID, subject.extractValidityFrom(response));
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetAccountNftInfosAnswerTest method extractsValidity.
@Test
void extractsValidity() {
// given:
Response response = Response.newBuilder().setTokenGetAccountNftInfos(TokenGetAccountNftInfosResponse.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 GetTokenInfoAnswerTest method getsTheInfo.
@Test
void getsTheInfo() throws Throwable {
// setup:
Query query = validQuery(ANSWER_ONLY, fee, tokenId);
given(view.infoForToken(tokenId)).willReturn(Optional.of(info));
// when:
Response response = subject.responseGiven(query, view, OK, fee);
// then:
assertTrue(response.hasTokenGetInfo());
assertTrue(response.getTokenGetInfo().hasHeader(), "Missing response header!");
assertEquals(OK, response.getTokenGetInfo().getHeader().getNodeTransactionPrecheckCode());
assertEquals(ANSWER_ONLY, response.getTokenGetInfo().getHeader().getResponseType());
assertEquals(fee, response.getTokenGetInfo().getHeader().getCost());
// and:
var actual = response.getTokenGetInfo().getTokenInfo();
assertEquals(info, actual);
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetTokenInfoAnswerTest method getsInvalidResponse.
@Test
void getsInvalidResponse() throws Throwable {
// setup:
Query query = validQuery(COST_ANSWER, fee, tokenId);
// when:
Response response = subject.responseGiven(query, view, INVALID_TOKEN_ID, fee);
// then:
assertTrue(response.hasTokenGetInfo());
assertEquals(INVALID_TOKEN_ID, response.getTokenGetInfo().getHeader().getNodeTransactionPrecheckCode());
assertEquals(COST_ANSWER, response.getTokenGetInfo().getHeader().getResponseType());
assertEquals(fee, response.getTokenGetInfo().getHeader().getCost());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetTokenInfoAnswerTest method recognizesMissingInfoWhenCtxGiven.
@Test
void recognizesMissingInfoWhenCtxGiven() throws Throwable {
// setup:
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, tokenId);
// when:
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L, Collections.emptyMap());
// then:
TokenGetInfoResponse opResponse = response.getTokenGetInfo();
assertTrue(opResponse.hasHeader(), "Missing response header!");
assertEquals(INVALID_TOKEN_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
verify(view, never()).infoForToken(any());
}
Aggregations