Search in sources :

Example 86 with Response

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

the class GetExecTimeAnswerTest method helpersWork.

@Test
void helpersWork() throws Throwable {
    Query query = validQuery(ANSWER_ONLY, 5L);
    Response response = Response.newBuilder().setNetworkGetExecutionTime(NetworkGetExecutionTimeResponse.newBuilder().setHeader(ResponseHeader.newBuilder().setNodeTransactionPrecheckCode(INVALID_TRANSACTION_ID))).build();
    final var payment = subject.extractPaymentFrom(query);
    assertTrue(payment.isPresent());
    assertFalse(subject.needsAnswerOnlyCost(query));
    assertEquals(INVALID_TRANSACTION_ID, subject.extractValidityFrom(response));
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) NetworkGetExecutionTimeResponse(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeResponse) Query(com.hederahashgraph.api.proto.java.Query) NetworkGetExecutionTimeQuery(com.hederahashgraph.api.proto.java.NetworkGetExecutionTimeQuery) Test(org.junit.jupiter.api.Test)

Example 87 with Response

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

the class GetAccountNftInfosAnswerTest method extractsValidity.

@Test
void extractsValidity() {
    // given:
    Response response = Response.newBuilder().setTokenGetAccountNftInfos(TokenGetAccountNftInfosResponse.newBuilder().setHeader(ResponseHeader.newBuilder().setNodeTransactionPrecheckCode(FAIL_FEE))).build();
    // expect:
    assertEquals(FAIL_FEE, subject.extractValidityFrom(response));
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetAccountNftInfosResponse(com.hederahashgraph.api.proto.java.TokenGetAccountNftInfosResponse) Test(org.junit.jupiter.api.Test)

Example 88 with Response

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

the class GetTokenInfoAnswerTest method getsTheInfo.

@Test
void getsTheInfo() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, tokenId);
    given(view.infoForToken(tokenId)).willReturn(Optional.of(info));
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasTokenGetInfo());
    assertTrue(response.getTokenGetInfo().hasHeader(), "Missing response header!");
    assertEquals(OK, response.getTokenGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(ANSWER_ONLY, response.getTokenGetInfo().getHeader().getResponseType());
    assertEquals(fee, response.getTokenGetInfo().getHeader().getCost());
    // and:
    var actual = response.getTokenGetInfo().getTokenInfo();
    assertEquals(info, actual);
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetInfoResponse(com.hederahashgraph.api.proto.java.TokenGetInfoResponse) TokenGetInfoQuery(com.hederahashgraph.api.proto.java.TokenGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 89 with Response

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

the class GetTokenInfoAnswerTest method getsInvalidResponse.

@Test
void getsInvalidResponse() throws Throwable {
    // setup:
    Query query = validQuery(COST_ANSWER, fee, tokenId);
    // when:
    Response response = subject.responseGiven(query, view, INVALID_TOKEN_ID, fee);
    // then:
    assertTrue(response.hasTokenGetInfo());
    assertEquals(INVALID_TOKEN_ID, response.getTokenGetInfo().getHeader().getNodeTransactionPrecheckCode());
    assertEquals(COST_ANSWER, response.getTokenGetInfo().getHeader().getResponseType());
    assertEquals(fee, response.getTokenGetInfo().getHeader().getCost());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetInfoResponse(com.hederahashgraph.api.proto.java.TokenGetInfoResponse) TokenGetInfoQuery(com.hederahashgraph.api.proto.java.TokenGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) Test(org.junit.jupiter.api.Test)

Example 90 with Response

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

the class GetTokenInfoAnswerTest method recognizesMissingInfoWhenCtxGiven.

@Test
void recognizesMissingInfoWhenCtxGiven() throws Throwable {
    // setup:
    Query sensibleQuery = validQuery(ANSWER_ONLY, 5L, tokenId);
    // when:
    Response response = subject.responseGiven(sensibleQuery, view, OK, 0L, Collections.emptyMap());
    // then:
    TokenGetInfoResponse opResponse = response.getTokenGetInfo();
    assertTrue(opResponse.hasHeader(), "Missing response header!");
    assertEquals(INVALID_TOKEN_ID, opResponse.getHeader().getNodeTransactionPrecheckCode());
    verify(view, never()).infoForToken(any());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) TokenGetInfoResponse(com.hederahashgraph.api.proto.java.TokenGetInfoResponse) TokenGetInfoResponse(com.hederahashgraph.api.proto.java.TokenGetInfoResponse) TokenGetInfoQuery(com.hederahashgraph.api.proto.java.TokenGetInfoQuery) Query(com.hederahashgraph.api.proto.java.Query) 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