Search in sources :

Example 66 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class HapiGetTxnRecord method lookupCostWith.

@Override
protected long lookupCostWith(HapiApiSpec spec, Transaction payment) throws Throwable {
    Query query = getRecordQuery(spec, payment, true);
    Response response = spec.clients().getCryptoSvcStub(targetNodeFor(spec), useTls).getTxRecordByTxID(query);
    return costFrom(response);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TransactionGetRecordQuery(com.hederahashgraph.api.proto.java.TransactionGetRecordQuery) Query(com.hederahashgraph.api.proto.java.Query)

Example 67 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class HapiGetScheduleInfo method lookupCostWith.

@Override
protected long lookupCostWith(HapiApiSpec spec, Transaction payment) throws Throwable {
    Query query = getScheduleInfoQuery(spec, payment, true);
    Response response = spec.clients().getScheduleSvcStub(targetNodeFor(spec), useTls).getScheduleInfo(query);
    return costFrom(response);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) ScheduleGetInfoQuery(com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)

Example 68 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetContractInfoAnswerTest 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.hasContractGetInfo());
    assertEquals(CONTRACT_DELETED, response.getContractGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, response.getContractGetInfo().getHeader().getResponseType());
    assertEquals(fee, response.getContractGetInfo().getHeader().getCost());
}
Also used : ContractGetInfoResponse(com.hederahashgraph.api.proto.java.ContractGetInfoResponse) Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) ContractGetInfoQuery(com.hederahashgraph.api.proto.java.ContractGetInfoQuery) Test(org.junit.jupiter.api.Test)

Example 69 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetContractInfoAnswerTest method getsTheInfo.

@Test
void getsTheInfo() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, target);
    given(view.infoForContract(asContract(target), aliasManager)).willReturn(Optional.of(info));
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasContractGetInfo());
    assertTrue(response.getContractGetInfo().hasHeader(), "Missing response header!");
    assertEquals(OK, response.getContractGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, response.getContractGetInfo().getHeader().getResponseType());
    assertEquals(fee, response.getContractGetInfo().getHeader().getCost());
    // and:
    var actual = response.getContractGetInfo().getContractInfo();
    assertEquals(info, actual);
}
Also used : ContractGetInfoResponse(com.hederahashgraph.api.proto.java.ContractGetInfoResponse) Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) ContractGetInfoQuery(com.hederahashgraph.api.proto.java.ContractGetInfoQuery) Test(org.junit.jupiter.api.Test)

Example 70 with Response

use of com.hederahashgraph.api.proto.java.Response in project hedera-services by hashgraph.

the class GetAccountBalanceAnswerTest method answersWithAccountBalanceWhenTheAccountIDIsContractID.

@Test
void answersWithAccountBalanceWhenTheAccountIDIsContractID() {
    // setup:
    ContractID id = asContract(accountIdLit);
    // given:
    CryptoGetAccountBalanceQuery op = CryptoGetAccountBalanceQuery.newBuilder().setContractID(id).build();
    Query query = Query.newBuilder().setCryptogetAccountBalance(op).build();
    // when:
    Response response = subject.responseGiven(query, view, OK);
    ResponseCodeEnum status = response.getCryptogetAccountBalance().getHeader().getNodeTransactionPrecheckCode();
    long answer = response.getCryptogetAccountBalance().getBalance();
    // expect:
    assertTrue(response.getCryptogetAccountBalance().hasHeader(), "Missing response header!");
    assertEquals(List.of(tokenBalanceWith(aToken, aBalance, 1), tokenBalanceWith(bToken, bBalance, 2), tokenBalanceWith(cToken, cBalance, 123), tokenBalanceWith(dToken, dBalance, 0)), response.getCryptogetAccountBalance().getTokenBalancesList());
    assertEquals(OK, status);
    assertEquals(balance, answer);
    assertEquals(asAccount(accountIdLit), response.getCryptogetAccountBalance().getAccountID());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) CryptoGetAccountBalanceResponse(com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceResponse) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) CryptoGetAccountBalanceQuery(com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery) Query(com.hederahashgraph.api.proto.java.Query) CryptoGetAccountBalanceQuery(com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery) ContractID(com.hederahashgraph.api.proto.java.ContractID) Test(org.junit.jupiter.api.Test)

Aggregations

Response (com.hederahashgraph.api.proto.java.Response)114 Query (com.hederahashgraph.api.proto.java.Query)96 Test (org.junit.jupiter.api.Test)87 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)9 ByteString (com.google.protobuf.ByteString)8 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)8 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)8 TokenGetNftInfoResponse (com.hederahashgraph.api.proto.java.TokenGetNftInfoResponse)8 TransactionGetReceiptResponse (com.hederahashgraph.api.proto.java.TransactionGetReceiptResponse)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)7 ContractGetInfoResponse (com.hederahashgraph.api.proto.java.ContractGetInfoResponse)7 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)7 NetworkGetExecutionTimeResponse (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse)7 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)7 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)7 ScheduleGetInfoResponse (com.hederahashgraph.api.proto.java.ScheduleGetInfoResponse)7 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)7 TokenGetInfoResponse (com.hederahashgraph.api.proto.java.TokenGetInfoResponse)7 HashMap (java.util.HashMap)7