Skip to content

Commit 7e72bd0

Browse files
committed
fixing integration test and small
1 parent 5d59105 commit 7e72bd0

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

jest.setupAfterEnv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
jest.setTimeout(60000);
1+
jest.setTimeout(80000);

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"build:dev": "tsc --sourceMap -w",
2020
"start": "node dist/index.js",
2121
"start:dev": "nodemon --inspect dist/index.js",
22-
"test": "jest",
22+
"test": "jest --detectOpenHandles --forceExit",
2323
"test:unit": "jest --testPathPattern=test/unit",
24-
"test:integration": "jest --testPathPattern=test/integration"
24+
"test:integration": "jest --testPathPattern=test/integration --detectOpenHandles --forceExit"
2525
},
2626
"repository": {
2727
"type": "git",

src/identity/hcs/did/hcs-did-topic-listener.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export class HcsDidTopicListener {
2727
this.topicId = topicId;
2828
this.query = new TopicMessageQuery().setTopicId(topicId).setStartTime(startTime);
2929

30-
this.query.setMaxBackoff(3000);
31-
this.query.setMaxAttempts(10);
30+
this.query.setMaxBackoff(2000);
31+
this.query.setMaxAttempts(15);
3232

3333
this.ignoreErrors = false;
3434
}

test/integration/hcs-did.test.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AccountId, Client, PrivateKey, Timestamp, TopicMessageQuery } from "@hashgraph/sdk";
1+
import { AccountId, Client, PrivateKey, Timestamp, TopicMessage, TopicMessageQuery } from "@hashgraph/sdk";
22
import { DidError, Hashing, HcsDid } from "../../dist";
33

44
const TOPIC_REGEXP = /^0\.0\.[0-9]{3,}/;
@@ -1034,22 +1034,26 @@ describe("HcsDid", () => {
10341034
*/
10351035

10361036
async function readTopicMessages(topicId, client, timeout = null) {
1037-
const messages = [];
1037+
const messages: TopicMessage[] = [];
10381038

10391039
const query = new TopicMessageQuery()
10401040
.setTopicId(topicId)
10411041
.setStartTime(new Timestamp(0, 0))
1042-
.setEndTime(Timestamp.fromDate(new Date()))
1043-
.subscribe(client, null, (msg) => {
1044-
messages.push(msg);
1045-
});
1042+
.setEndTime(Timestamp.fromDate(new Date()));
1043+
1044+
query.setMaxBackoff(2000);
1045+
query.setMaxAttempts(15);
1046+
1047+
const querySubcription = query.subscribe(client, null, (msg) => {
1048+
messages.push(msg);
1049+
});
10461050

10471051
/**
10481052
* wait for READ_MESSAGES_TIMEOUT seconds and assume all messages were read
10491053
*/
10501054
await delay(timeout || process.env.WAIT_BEFORE_RESOLVE_DID_FOR);
10511055

1052-
query.unsubscribe();
1056+
querySubcription.unsubscribe();
10531057

10541058
return messages;
10551059
}

0 commit comments

Comments
 (0)