Search in sources :

Example 16 with Query

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());
}
Also used : CryptoGetInfoQuery(com.hederahashgraph.api.proto.java.CryptoGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 17 with Query

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);
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) CryptoGetInfoQuery(com.hederahashgraph.api.proto.java.CryptoGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 18 with Query

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));
}
Also used : CryptoGetLiveHashResponse(com.hederahashgraph.api.proto.java.CryptoGetLiveHashResponse) Response(com.hederahashgraph.api.proto.java.Response) Query(com.hederahashgraph.api.proto.java.Query) CryptoGetLiveHashQuery(com.hederahashgraph.api.proto.java.CryptoGetLiveHashQuery) Test(org.junit.jupiter.api.Test)

Example 19 with Query

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);
}
Also used : ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Query(com.hederahashgraph.api.proto.java.Query) ScheduleGetInfoQuery(com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery) Test(org.junit.jupiter.api.Test)

Example 20 with Query

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);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ScheduleGetInfoResponse(com.hederahashgraph.api.proto.java.ScheduleGetInfoResponse) Query(com.hederahashgraph.api.proto.java.Query) ScheduleGetInfoQuery(com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery) Test(org.junit.jupiter.api.Test)

Aggregations

Query (com.hederahashgraph.api.proto.java.Query)152 Test (org.junit.jupiter.api.Test)108 Response (com.hederahashgraph.api.proto.java.Response)95 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)24 ContractCallLocalQuery (com.hederahashgraph.api.proto.java.ContractCallLocalQuery)13 TokenGetNftInfoQuery (com.hederahashgraph.api.proto.java.TokenGetNftInfoQuery)13 ContractGetInfoQuery (com.hederahashgraph.api.proto.java.ContractGetInfoQuery)11 ByteString (com.google.protobuf.ByteString)10 ConsensusGetTopicInfoQuery (com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery)10 ScheduleGetInfoQuery (com.hederahashgraph.api.proto.java.ScheduleGetInfoQuery)10 TokenGetInfoQuery (com.hederahashgraph.api.proto.java.TokenGetInfoQuery)10 CryptoGetAccountBalanceQuery (com.hederahashgraph.api.proto.java.CryptoGetAccountBalanceQuery)9 CryptoGetInfoQuery (com.hederahashgraph.api.proto.java.CryptoGetInfoQuery)9 FileGetInfoQuery (com.hederahashgraph.api.proto.java.FileGetInfoQuery)8 NetworkGetExecutionTimeQuery (com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery)8 HashMap (java.util.HashMap)8 ContractCallLocalResponse (com.hederahashgraph.api.proto.java.ContractCallLocalResponse)7 ContractGetBytecodeQuery (com.hederahashgraph.api.proto.java.ContractGetBytecodeQuery)7 FileGetContentsQuery (com.hederahashgraph.api.proto.java.FileGetContentsQuery)7 FileGetInfoResponse (com.hederahashgraph.api.proto.java.FileGetInfoResponse)7