use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetMerkleTopicInfoAnswerTest method getsValidity.
@Test
void getsValidity() {
// given:
Response response = Response.newBuilder().setConsensusGetTopicInfo(ConsensusGetTopicInfoResponse.newBuilder().setHeader(ResponseHeader.newBuilder().setNodeTransactionPrecheckCode(TOPIC_EXPIRED))).build();
// expect:
assertEquals(TOPIC_EXPIRED, subject.extractValidityFrom(response));
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class GetMerkleTopicInfoAnswerTest method getsTopicInfoWithEmptyRunningHash.
@Test
void getsTopicInfoWithEmptyRunningHash() throws Throwable {
// setup:
Query query = validQuery(ANSWER_ONLY, fee, target);
merkleTopic.setRunningHash(null);
given(topics.get(asTopic(target))).willReturn(merkleTopic);
// when:
Response response = subject.responseGiven(query, view, OK, fee);
// then:
assertTrue(response.hasConsensusGetTopicInfo());
// and:
ConsensusTopicInfo info = response.getConsensusGetTopicInfo().getTopicInfo();
assertArrayEquals(new byte[48], info.getRunningHash().toByteArray());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class ContractCallLocalAnswerTest 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.hasContractCallLocal());
assertEquals(FAIL_INVALID, response.getContractCallLocal().getHeader().getNodeTransactionPrecheckCode());
assertEquals(COST_ANSWER, response.getContractCallLocal().getHeader().getResponseType());
assertEquals(fee, response.getContractCallLocal().getHeader().getCost());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class ContractCallLocalAnswerTest method getsCallResponseWhenNoCtx.
@Test
void getsCallResponseWhenNoCtx() throws Throwable {
// setup:
Query sensibleQuery = validQuery(ANSWER_ONLY, 5L);
final var transactionProcessingResult = TransactionProcessingResult.failed(0, 0, 1, Optional.empty(), Optional.empty(), new TreeMap<>());
given(accountStore.loadAccount(any())).willReturn(new Account(Id.fromGrpcContract(target)));
given(accountStore.loadContract(any())).willReturn(new Account(Id.fromGrpcContract(target)));
given(evmTxProcessor.execute(any(), any(), anyLong(), anyLong(), any(), any())).willReturn(transactionProcessingResult);
Response response = subject.responseGiven(sensibleQuery, view, OK, 0L);
// then:
var opResponse = response.getContractCallLocal();
assertTrue(opResponse.hasHeader(), "Missing response header!");
assertEquals(CONTRACT_EXECUTION_EXCEPTION, opResponse.getHeader().getNodeTransactionPrecheckCode());
assertEquals(target, opResponse.getFunctionResult().getContractID());
}
use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.
the class VerifyGetAccountNftInfosNotSupported method submitOp.
@Override
protected boolean submitOp(HapiApiSpec spec) throws Throwable {
TokenGetAccountNftInfosQuery.Builder op = TokenGetAccountNftInfosQuery.newBuilder().setAccountID(asAccount("0.0.2"));
Query query = Query.newBuilder().setTokenGetAccountNftInfos(op).build();
Response response = spec.clients().getTokenSvcStub(targetNodeFor(spec), useTls).getAccountNftInfos(query);
Assertions.assertEquals(NOT_SUPPORTED, response.getTokenGetAccountNftInfos().getHeader().getNodeTransactionPrecheckCode());
return false;
}
Aggregations