Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix integration tests #1896

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/integration/ClientIntegrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ describe("ClientIntegration", function () {

let error = null;
try {
await env.client.ping("0.0.100"); // Non exist Node ID
await env.client.ping(""); // Non exist Node ID
} catch (err) {
error = err;
}
Expand Down
46 changes: 37 additions & 9 deletions test/integration/TopicMessageQueryTest.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
import { TopicMessageQuery } from "../../src/exports.js";
import { Client } from "./client/NodeIntegrationTestEnv.js";
import {
TopicMessageQuery,
TopicCreateTransaction,
TopicMessageSubmitTransaction,
} from "../../src/exports.js";
import IntegrationTestEnv from "./client/NodeIntegrationTestEnv.js";

describe("TopicMessageQuery", function () {
let client;
let env;

before(async function () {
client = Client.forNetwork({});
env = await IntegrationTestEnv.new({ throwaway: true });
});

it("should be executable", async function () {
this.timeout(60000);

client.setTransportSecurity(true);
client.setMirrorNetwork(["mainnet-public.mirrornode.hedera.com:443"]);
// client.setTransportSecurity(true);
// client.setMirrorNetwork(["mainnet-public.mirrornode.hedera.com:443"]);

const operatorId = env.operatorId;
const operatorKey = env.operatorKey.publicKey;

// Skip this test if we do not have a mirror network
if (env.client.mirrorNetwork.length == 0) {
return;
}

const response = await new TopicCreateTransaction()
.setAdminKey(operatorKey)
.setSubmitKey(operatorKey)
.setAutoRenewAccountId(operatorId)
.execute(env.client);

const topic = (await response.getReceipt(env.client)).topicId;
const contents = "Hello from Hedera SDK JS";

await (
await new TopicMessageSubmitTransaction()
.setTopicId(topic)
.setMessage(contents)
.execute(env.client)
).getReceipt(env.client);

let finished = false;
let endTime = Date.now() + 50000;

new TopicMessageQuery()
.setTopicId("0.0.3002507")
.setTopicId(topic)
// .setStartTime(0)
// .setLimit(1)
// eslint-disable-next-line no-unused-vars
.subscribe(client, (_) => {
.subscribe(env, (_) => {
finished = true;
});

Expand All @@ -37,6 +65,6 @@ describe("TopicMessageQuery", function () {
});

after(async function () {
await client.close();
await env.close();
});
});
Loading