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);
}
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);
}
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());
}
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);
}
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());
}
Aggregations