use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetFileInfoAnswerTest method failsWhenMissingInfo.
@Test
void failsWhenMissingInfo() throws Throwable {
// setup:
Query query = validQuery(ANSWER_ONLY, fee, target);
given(view.infoForFile(asFile(target))).willReturn(Optional.empty());
// when:
Response response = subject.responseGiven(query, view, OK, fee);
// then:
assertTrue(response.hasFileGetInfo());
assertEquals(FAIL_INVALID, response.getFileGetInfo().getHeader().getNodeTransactionPrecheckCode());
assertEquals(ANSWER_ONLY, response.getFileGetInfo().getHeader().getResponseType());
assertFalse(response.getFileGetInfo().hasFileInfo());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetFileInfoAnswerTest method getsTheInfo.
@Test
void getsTheInfo() throws Throwable {
// setup:
Query query = validQuery(ANSWER_ONLY, fee, target);
given(view.infoForFile(asFile(target))).willReturn(Optional.of(expected));
// when:
Response response = subject.responseGiven(query, view, OK, fee);
// then:
assertTrue(response.hasFileGetInfo());
assertTrue(response.getFileGetInfo().hasHeader(), "Missing response header!");
assertEquals(OK, response.getFileGetInfo().getHeader().getNodeTransactionPrecheckCode());
assertEquals(ANSWER_ONLY, response.getFileGetInfo().getHeader().getResponseType());
assertEquals(fee, response.getFileGetInfo().getHeader().getCost());
// and:
var actual = response.getFileGetInfo().getFileInfo();
assertEquals(expected, actual);
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetFileInfoAnswerTest method getsValidity.
@Test
void getsValidity() {
// given:
Response response = Response.newBuilder().setFileGetInfo(FileGetInfoResponse.newBuilder().setHeader(subject.answerOnlyHeader(RESULT_SIZE_LIMIT_EXCEEDED))).build();
// expect:
assertEquals(RESULT_SIZE_LIMIT_EXCEEDED, subject.extractValidityFrom(response));
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetExecTimeAnswerTest method getsInvalidResponse.
@Test
void getsInvalidResponse() throws Throwable {
// setup:
Query query = validQuery(COST_ANSWER, fee);
// when:
Response response = subject.responseGiven(query, view, FAIL_INVALID, fee);
// then:
assertTrue(response.hasNetworkGetExecutionTime());
assertEquals(FAIL_INVALID, response.getNetworkGetExecutionTime().getHeader().getNodeTransactionPrecheckCode());
assertEquals(COST_ANSWER, response.getNetworkGetExecutionTime().getHeader().getResponseType());
assertEquals(fee, response.getNetworkGetExecutionTime().getHeader().getCost());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetExecTimeAnswerTest method getsCostAnswerResponse.
@Test
void getsCostAnswerResponse() throws Throwable {
// setup:
Query query = validQuery(COST_ANSWER, fee);
// when:
Response response = subject.responseGiven(query, view, OK, fee);
// then:
assertTrue(response.hasNetworkGetExecutionTime());
NetworkGetExecutionTimeResponse opResponse = response.getNetworkGetExecutionTime();
assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
assertEquals(COST_ANSWER, opResponse.getHeader().getResponseType());
assertEquals(fee, opResponse.getHeader().getCost());
assertEquals(OK, subject.checkValidity(query, view));
}
Aggregations