Search in sources :

Example 6 with TopicInfoQuery

use of com.hedera.hashgraph.sdk.TopicInfoQuery in project hedera-sdk-java by hashgraph.

the class TopicInfoIntegrationTest method getCostBigMaxQueryTopicInfo.

@Test
@DisplayName("Can get cost for topic info query")
void getCostBigMaxQueryTopicInfo() throws Exception {
    var testEnv = new IntegrationTestEnv(1);
    var response = new TopicCreateTransaction().setAdminKey(testEnv.operatorKey).setTopicMemo("[e2e::TopicCreateTransaction]").execute(testEnv.client);
    var topicId = Objects.requireNonNull(response.getReceipt(testEnv.client).topicId);
    var infoQuery = new TopicInfoQuery().setTopicId(topicId).setMaxQueryPayment(new Hbar(1000));
    var cost = infoQuery.getCost(testEnv.client);
    assertThat(cost).isNotNull();
    var info = infoQuery.execute(testEnv.client);
    assertThat(info.topicMemo).isEqualTo("[e2e::TopicCreateTransaction]");
    new TopicDeleteTransaction().setTopicId(topicId).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close();
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) TopicInfoQuery(com.hedera.hashgraph.sdk.TopicInfoQuery) Hbar(com.hedera.hashgraph.sdk.Hbar) TopicDeleteTransaction(com.hedera.hashgraph.sdk.TopicDeleteTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 7 with TopicInfoQuery

use of com.hedera.hashgraph.sdk.TopicInfoQuery in project hedera-sdk-java by hashgraph.

the class TopicInfoIntegrationTest method getCostSmallMaxQueryTopicInfo.

@Test
@DisplayName("Can get cost for topic info query")
void getCostSmallMaxQueryTopicInfo() throws Exception {
    var testEnv = new IntegrationTestEnv(1);
    var response = new TopicCreateTransaction().setAdminKey(testEnv.operatorKey).setTopicMemo("[e2e::TopicCreateTransaction]").execute(testEnv.client);
    var topicId = Objects.requireNonNull(response.getReceipt(testEnv.client).topicId);
    var infoQuery = new TopicInfoQuery().setTopicId(topicId).setMaxQueryPayment(Hbar.fromTinybars(1));
    assertThatExceptionOfType(MaxQueryPaymentExceededException.class).isThrownBy(() -> {
        infoQuery.execute(testEnv.client);
    });
    new TopicDeleteTransaction().setTopicId(topicId).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close();
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) TopicInfoQuery(com.hedera.hashgraph.sdk.TopicInfoQuery) MaxQueryPaymentExceededException(com.hedera.hashgraph.sdk.MaxQueryPaymentExceededException) TopicDeleteTransaction(com.hedera.hashgraph.sdk.TopicDeleteTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 8 with TopicInfoQuery

use of com.hedera.hashgraph.sdk.TopicInfoQuery in project hedera-sdk-java by hashgraph.

the class TopicInfoIntegrationTest method getCostQueryTopicInfo.

@Test
@DisplayName("Can get cost for topic info query")
void getCostQueryTopicInfo() throws Exception {
    var testEnv = new IntegrationTestEnv(1);
    var response = new TopicCreateTransaction().setAdminKey(testEnv.operatorKey).setTopicMemo("[e2e::TopicCreateTransaction]").execute(testEnv.client);
    var topicId = Objects.requireNonNull(response.getReceipt(testEnv.client).topicId);
    var infoQuery = new TopicInfoQuery().setTopicId(topicId);
    var cost = infoQuery.getCost(testEnv.client);
    assertThat(cost).isNotNull();
    var info = infoQuery.execute(testEnv.client);
    assertThat(info.topicMemo).isEqualTo("[e2e::TopicCreateTransaction]");
    new TopicDeleteTransaction().setTopicId(topicId).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close();
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) TopicInfoQuery(com.hedera.hashgraph.sdk.TopicInfoQuery) TopicDeleteTransaction(com.hedera.hashgraph.sdk.TopicDeleteTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 9 with TopicInfoQuery

use of com.hedera.hashgraph.sdk.TopicInfoQuery in project hedera-sdk-java by hashgraph.

the class TopicInfoIntegrationTest method canQueryTopicInfo.

@Test
@DisplayName("Can query topic info")
void canQueryTopicInfo() throws Exception {
    var testEnv = new IntegrationTestEnv(1);
    var response = new TopicCreateTransaction().setAdminKey(testEnv.operatorKey).setTopicMemo("[e2e::TopicCreateTransaction]").execute(testEnv.client);
    var topicId = Objects.requireNonNull(response.getReceipt(testEnv.client).topicId);
    var info = new TopicInfoQuery().setTopicId(topicId).execute(testEnv.client);
    assertThat(info.topicMemo).isEqualTo("[e2e::TopicCreateTransaction]");
    new TopicDeleteTransaction().setTopicId(topicId).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close();
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) TopicInfoQuery(com.hedera.hashgraph.sdk.TopicInfoQuery) TopicDeleteTransaction(com.hedera.hashgraph.sdk.TopicDeleteTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 10 with TopicInfoQuery

use of com.hedera.hashgraph.sdk.TopicInfoQuery in project hedera-sdk-java by hashgraph.

the class TopicMessageSubmitIntegrationTest method canSubmitATopicMessage.

@Test
@DisplayName("Can submit a topic message")
void canSubmitATopicMessage() throws Exception {
    var testEnv = new IntegrationTestEnv(1);
    var response = new TopicCreateTransaction().setAdminKey(testEnv.operatorKey).setTopicMemo("[e2e::TopicCreateTransaction]").execute(testEnv.client);
    var topicId = Objects.requireNonNull(response.getReceipt(testEnv.client).topicId);
    @Var var info = new TopicInfoQuery().setTopicId(topicId).execute(testEnv.client);
    assertThat(info.topicId).isEqualTo(topicId);
    assertThat(info.topicMemo).isEqualTo("[e2e::TopicCreateTransaction]");
    assertThat(info.sequenceNumber).isEqualTo(0);
    assertThat(info.adminKey).isEqualTo(testEnv.operatorKey);
    new TopicMessageSubmitTransaction().setTopicId(topicId).setMessage("Hello, from HCS!").execute(testEnv.client).getReceipt(testEnv.client);
    info = new TopicInfoQuery().setTopicId(topicId).execute(testEnv.client);
    assertThat(info.topicId).isEqualTo(topicId);
    assertThat(info.topicMemo).isEqualTo("[e2e::TopicCreateTransaction]");
    assertThat(info.sequenceNumber).isEqualTo(1);
    assertThat(info.adminKey).isEqualTo(testEnv.operatorKey);
    new TopicDeleteTransaction().setTopicId(topicId).execute(testEnv.client).getReceipt(testEnv.client);
    testEnv.close();
}
Also used : TopicCreateTransaction(com.hedera.hashgraph.sdk.TopicCreateTransaction) TopicInfoQuery(com.hedera.hashgraph.sdk.TopicInfoQuery) Var(com.google.errorprone.annotations.Var) TopicMessageSubmitTransaction(com.hedera.hashgraph.sdk.TopicMessageSubmitTransaction) TopicDeleteTransaction(com.hedera.hashgraph.sdk.TopicDeleteTransaction) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

TopicInfoQuery (com.hedera.hashgraph.sdk.TopicInfoQuery)11 TopicCreateTransaction (com.hedera.hashgraph.sdk.TopicCreateTransaction)10 TopicDeleteTransaction (com.hedera.hashgraph.sdk.TopicDeleteTransaction)10 DisplayName (org.junit.jupiter.api.DisplayName)10 Test (org.junit.jupiter.api.Test)10 TopicMessageSubmitTransaction (com.hedera.hashgraph.sdk.TopicMessageSubmitTransaction)4 Var (com.google.errorprone.annotations.Var)2 TopicMessageQuery (com.hedera.hashgraph.sdk.TopicMessageQuery)2 TopicUpdateTransaction (com.hedera.hashgraph.sdk.TopicUpdateTransaction)2 Hbar (com.hedera.hashgraph.sdk.Hbar)1 KeyList (com.hedera.hashgraph.sdk.KeyList)1 MaxQueryPaymentExceededException (com.hedera.hashgraph.sdk.MaxQueryPaymentExceededException)1 PrivateKey (com.hedera.hashgraph.sdk.PrivateKey)1 TopicInfo (com.hedera.hashgraph.sdk.TopicInfo)1 TransactionResponse (com.hedera.hashgraph.sdk.TransactionResponse)1