use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class ContractCallLocalAnswerTest method respectsMetaValidity.
@Test
void respectsMetaValidity() throws Throwable {
// given:
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L);
// when:
Response response = subject.responseGiven(sensibleQuery, view, INVALID_TRANSACTION, 0L);
// then:
var opResponse = response.getContractCallLocal();
assertEquals(INVALID_TRANSACTION, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetBytecodeAnswerTest method getsInvalidResponse.
@Test
void getsInvalidResponse() throws Throwable {
// setup:
Query query = validQuery(COST_ANSWER, fee, target);
// when:
Response response = subject.responseGiven(query, view, CONTRACT_DELETED, fee);
// then:
assertTrue(response.hasContractGetBytecodeResponse());
assertEquals(CONTRACT_DELETED, response.getContractGetBytecodeResponse().getHeader().getNodeTransactionPrecheckCode());
assertEquals(COST_ANSWER, response.getContractGetBytecodeResponse().getHeader().getResponseType());
assertEquals(fee, response.getContractGetBytecodeResponse().getHeader().getCost());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetBytecodeAnswerTest method getsValidity.
@Test
void getsValidity() {
// given:
Response response = Response.newBuilder().setContractGetBytecodeResponse(ContractGetBytecodeResponse.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 GetContractInfoAnswerTest method getsInfoFromCtxWhenAvailable.
@Test
void getsInfoFromCtxWhenAvailable() throws Throwable {
// setup:
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, target);
Map<String, Object> ctx = new HashMap<>();
// given:
ctx.put(GetContractInfoAnswer.CONTRACT_INFO_CTX_KEY, info);
// when:
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L, ctx);
// then:
var opResponse = response.getContractGetInfo();
assertTrue(opResponse.hasHeader(), "Missing response header!");
assertEquals(OK, opResponse.getHeader().getNodeTransactionPrecheckCode());
assertSame(info, opResponse.getContractInfo());
// and:
verify(view, never()).infoForContract(any(), any());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetContractInfoAnswerTest method recognizesMissingInfoWhenNoCtxGiven.
@Test
void recognizesMissingInfoWhenNoCtxGiven() throws Throwable {
// setup:
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, target);
given(view.infoForContract(asContract(target), aliasManager)).willReturn(Optional.empty());
// when:
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
// then:
ContractGetInfoResponse opResponse = response.getContractGetInfo();
assertTrue(opResponse.hasHeader(), "Missing response header!");
assertEquals(INVALID_CONTRACT_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
}
Aggregations