Search in sources :

Example 61 with Query

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

the class GetMerkleTopicInfoAnswerTest 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 : Query(com.hederahashgraph.api.proto.java.Query) ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) Test(org.junit.jupiter.api.Test)

Example 62 with Query

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

the class GetMerkleTopicInfoAnswerTest method syntaxCheckRequiresId.

@Test
void syntaxCheckRequiresId() {
    // given:
    ConsensusGetTopicInfoQuery op = ConsensusGetTopicInfoQuery.newBuilder().build();
    Query query = Query.newBuilder().setConsensusGetTopicInfo(op).build();
    // when:
    ResponseCodeEnum status = subject.checkValidity(query, view);
    // expect:
    assertEquals(INVALID_TOPIC_ID, status);
}
Also used : ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Query(com.hederahashgraph.api.proto.java.Query) ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) Test(org.junit.jupiter.api.Test)

Example 63 with Query

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

the class GetMerkleTopicInfoAnswerTest method requiresOkMetaValidity.

@Test
void requiresOkMetaValidity() {
    // setup:
    TopicID id = asTopic(idLit);
    // given:
    ConsensusGetTopicInfoQuery op = ConsensusGetTopicInfoQuery.newBuilder().setTopicID(id).build();
    Query query = Query.newBuilder().setConsensusGetTopicInfo(op).build();
    // when:
    Response response = subject.responseGiven(query, view, PLATFORM_NOT_ACTIVE);
    ResponseCodeEnum status = response.getConsensusGetTopicInfo().getHeader().getNodeTransactionPrecheckCode();
    // expect:
    assertEquals(PLATFORM_NOT_ACTIVE, status);
    assertEquals(id, response.getConsensusGetTopicInfo().getTopicID());
}
Also used : ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) Response(com.hederahashgraph.api.proto.java.Response) ConsensusGetTopicInfoResponse(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoResponse) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) Query(com.hederahashgraph.api.proto.java.Query) ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) TopicID(com.hederahashgraph.api.proto.java.TopicID) Test(org.junit.jupiter.api.Test)

Example 64 with Query

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

the class GetMerkleTopicInfoAnswerTest method failsAsExpectedWhenFetchingMissingTopicInfo.

@Test
void failsAsExpectedWhenFetchingMissingTopicInfo() throws Throwable {
    given(topics.get(key)).willReturn(null);
    Query query = validQuery(ANSWER_ONLY, fee, target);
    Response response = subject.responseGiven(query, view, OK, fee);
    assertTrue(response.hasConsensusGetTopicInfo());
    assertEquals(INVALID_TOPIC_ID, response.getConsensusGetTopicInfo().getHeader().getNodeTransactionPrecheckCode());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ConsensusGetTopicInfoResponse(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoResponse) Query(com.hederahashgraph.api.proto.java.Query) ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) Test(org.junit.jupiter.api.Test)

Example 65 with Query

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

the class GetMerkleTopicInfoAnswerTest method getsTopicInfoWithEmptyRunningHash.

@Test
void getsTopicInfoWithEmptyRunningHash() throws Throwable {
    // setup:
    Query query = validQuery(ANSWER_ONLY, fee, target);
    merkleTopic.setRunningHash(null);
    given(topics.get(asTopic(target))).willReturn(merkleTopic);
    // when:
    Response response = subject.responseGiven(query, view, OK, fee);
    // then:
    assertTrue(response.hasConsensusGetTopicInfo());
    // and:
    ConsensusTopicInfo info = response.getConsensusGetTopicInfo().getTopicInfo();
    assertArrayEquals(new byte[48], info.getRunningHash().toByteArray());
}
Also used : Response(com.hederahashgraph.api.proto.java.Response) ConsensusGetTopicInfoResponse(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoResponse) ConsensusTopicInfo(com.hederahashgraph.api.proto.java.ConsensusTopicInfo) Query(com.hederahashgraph.api.proto.java.Query) ConsensusGetTopicInfoQuery(com.hederahashgraph.api.proto.java.ConsensusGetTopicInfoQuery) 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