use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetAccountInfoAnswerTest method getsExpectedPayment.
@Test
void getsExpectedPayment() throws Throwable {
// given:
Query query = validQuery(COST_ANSWER, fee, target);
// expect:
assertEquals(paymentTxn, subject.extractPaymentFrom(query).get().getSignedTxnWrapper());
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetAccountInfoAnswerTest method usesValidator.
@Test
void usesValidator() throws Throwable {
// setup:
Query query = validQuery(COST_ANSWER, fee, target);
given(optionValidator.queryableAccountStatus(EntityNum.fromAccountId(payerId), accounts)).willReturn(ACCOUNT_DELETED);
// when:
ResponseCodeEnum validity = subject.checkValidity(query, view);
// then:
assertEquals(ACCOUNT_DELETED, validity);
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetLiveHashAnswerTest method respectsTypeOfUnsupportedQuery.
@Test
void respectsTypeOfUnsupportedQuery() {
// given:
Query costAnswer = getLiveHashQuery(COST_ANSWER);
Query answerOnly = getLiveHashQuery(ANSWER_ONLY);
// when:
Response costAnswerResponse = subject.responseGiven(costAnswer, StateView.EMPTY_VIEW, OK, 0L);
Response answerOnlyResponse = subject.responseGiven(answerOnly, StateView.EMPTY_VIEW, OK, 0L);
// then:
assertEquals(COST_ANSWER, costAnswerResponse.getCryptoGetLiveHash().getHeader().getResponseType());
assertEquals(ANSWER_ONLY, answerOnlyResponse.getCryptoGetLiveHash().getHeader().getResponseType());
// and:
assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(costAnswerResponse));
assertEquals(NOT_SUPPORTED, subject.extractValidityFrom(answerOnlyResponse));
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetScheduleInfoAnswerTest method usesViewToValidate.
@Test
void usesViewToValidate() throws Throwable {
// setup:
Query query = validQuery(COST_ANSWER, fee, scheduleID);
given(view.scheduleExists(scheduleID)).willReturn(false);
// when:
ResponseCodeEnum validity = subject.checkValidity(query, view);
// then:
assertEquals(INVALID_SCHEDULE_ID, validity);
}
use of com.hederahashgraph.api.proto.java.Query in project hedera-services by hashgraph.
the class GetScheduleInfoAnswerTest method getsTheInfo.
@Test
void getsTheInfo() throws Throwable {
// setup:
Query query = validQuery(ANSWER_ONLY, fee, scheduleID);
given(view.infoForSchedule(scheduleID)).willReturn(Optional.of(info));
// when:
Response response = subject.responseGiven(query, view, OK, fee);
// then:
assertTrue(response.hasScheduleGetInfo());
assertTrue(response.getScheduleGetInfo().hasHeader(), "Missing response header!");
assertEquals(OK, response.getScheduleGetInfo().getHeader().getNodeTransactionPrecheckCode());
assertEquals(ANSWER_ONLY, response.getScheduleGetInfo().getHeader().getResponseType());
assertEquals(fee, response.getScheduleGetInfo().getHeader().getCost());
// and:
var actual = response.getScheduleGetInfo().getScheduleInfo();
assertEquals(info, actual);
}
Aggregations