@streamr/cli-tools 8.5.5 → 100.0.0-pretestnet.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/streamr-storage-node-add-stream.ts +1 -1
- package/bin/streamr-storage-node-list-streams.ts +1 -1
- package/bin/streamr-storage-node-remove-stream.ts +1 -1
- package/bin/streamr-stream-create.ts +1 -1
- package/bin/streamr-stream-resend-from.ts +1 -1
- package/bin/streamr-stream-resend-last.ts +1 -1
- package/bin/streamr-stream-search.ts +1 -1
- package/bin/streamr-stream-show.ts +1 -1
- package/bin/streamr-stream-subscribe.ts +7 -5
- package/bin/streamr-stream.ts +1 -1
- package/bin/streamr-wallet-whoami.ts +1 -1
- package/dist/bin/streamr-stream-subscribe.js +6 -4
- package/dist/bin/streamr-stream-subscribe.js.map +1 -1
- package/dist/bin/streamr-stream.js +1 -1
- package/dist/package.json +10 -10
- package/package.json +10 -10
- package/test/stream-publish-subscribe.test.ts +30 -6
- package/test/stream-resend.test.ts +2 -2
- package/test/stream-search.test.ts +5 -1
- package/test/stream-show.test.ts +2 -1
- package/test/utils.ts +12 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
|
-
import StreamrClient from 'streamr-client'
|
|
3
|
+
import { StreamrClient } from 'streamr-client'
|
|
4
4
|
import { createClientCommand } from '../src/command'
|
|
5
5
|
|
|
6
6
|
createClientCommand(async (client: StreamrClient, storageNodeAddress: string, streamId: string) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import EasyTable from 'easy-table'
|
|
4
|
-
import StreamrClient from 'streamr-client'
|
|
4
|
+
import { StreamrClient } from 'streamr-client'
|
|
5
5
|
import { createClientCommand } from '../src/command'
|
|
6
6
|
|
|
7
7
|
createClientCommand((async (client: StreamrClient, storageNodeAddress: string) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
|
-
import StreamrClient from 'streamr-client'
|
|
3
|
+
import { StreamrClient } from 'streamr-client'
|
|
4
4
|
import { createClientCommand } from '../src/command'
|
|
5
5
|
|
|
6
6
|
createClientCommand(async (client: StreamrClient, storageNodeAddress: string, streamId: string) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
|
-
import StreamrClient from 'streamr-client'
|
|
3
|
+
import { StreamrClient } from 'streamr-client'
|
|
4
4
|
import { createFnParseInt } from '../src/common'
|
|
5
5
|
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
|
-
import StreamrClient,
|
|
3
|
+
import { StreamrClient, SearchStreamsPermissionFilter, StreamPermission } from 'streamr-client'
|
|
4
4
|
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
5
5
|
import { Option } from 'commander'
|
|
6
6
|
import { getPermission, PERMISSIONS } from '../src/permission'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import '../src/logLevel'
|
|
3
|
-
import StreamrClient from 'streamr-client'
|
|
3
|
+
import { StreamrClient } from 'streamr-client'
|
|
4
4
|
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
5
5
|
import { getPermissionId } from '../src/permission'
|
|
6
6
|
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import '../src/logLevel'
|
|
3
3
|
import omit from 'lodash/omit'
|
|
4
4
|
import isString from 'lodash/isString'
|
|
5
|
-
import StreamrClient,
|
|
5
|
+
import { StreamrClient, MessageMetadata } from 'streamr-client'
|
|
6
6
|
import { createClientCommand, Options as BaseOptions } from '../src/command'
|
|
7
7
|
import { createFnParseInt } from '../src/common'
|
|
8
|
+
import { binaryToHex } from '@streamr/utils'
|
|
8
9
|
|
|
9
10
|
interface Options extends BaseOptions {
|
|
10
11
|
partition: number
|
|
@@ -14,15 +15,16 @@ interface Options extends BaseOptions {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
createClientCommand(async (client: StreamrClient, streamId: string, options: Options) => {
|
|
18
|
+
const formContent = (content: unknown) => options.raw ? binaryToHex(content as Uint8Array) : content
|
|
17
19
|
const formMessage = options.withMetadata
|
|
18
|
-
? (
|
|
19
|
-
: (
|
|
20
|
+
? (content: unknown, metadata: MessageMetadata) => ({ content: formContent(content), metadata: omit(metadata, 'streamMessage') })
|
|
21
|
+
: (content: unknown) => formContent(content)
|
|
20
22
|
await client.subscribe({
|
|
21
23
|
streamId,
|
|
22
24
|
partition: options.partition,
|
|
23
25
|
raw: options.raw
|
|
24
|
-
}, (
|
|
25
|
-
const output = formMessage(
|
|
26
|
+
}, (content, metadata) => {
|
|
27
|
+
const output = formMessage(content, metadata)
|
|
26
28
|
console.info(isString(output) ? output : JSON.stringify(output))
|
|
27
29
|
})
|
|
28
30
|
}, {
|
package/bin/streamr-stream.ts
CHANGED
|
@@ -10,7 +10,7 @@ program
|
|
|
10
10
|
.command('publish', 'publish to a stream')
|
|
11
11
|
.command('search', 'search for streams')
|
|
12
12
|
.command('show', 'info about a stream')
|
|
13
|
-
.command(
|
|
13
|
+
.command('create', 'create a new stream')
|
|
14
14
|
.command('resend', 'request resend of a stream')
|
|
15
15
|
.command('grant-permission', 'grant permission')
|
|
16
16
|
.command('revoke-permission', 'revoke permission')
|
|
@@ -9,16 +9,18 @@ const omit_1 = __importDefault(require("lodash/omit"));
|
|
|
9
9
|
const isString_1 = __importDefault(require("lodash/isString"));
|
|
10
10
|
const command_1 = require("../src/command");
|
|
11
11
|
const common_1 = require("../src/common");
|
|
12
|
+
const utils_1 = require("@streamr/utils");
|
|
12
13
|
(0, command_1.createClientCommand)(async (client, streamId, options) => {
|
|
14
|
+
const formContent = (content) => options.raw ? (0, utils_1.binaryToHex)(content) : content;
|
|
13
15
|
const formMessage = options.withMetadata
|
|
14
|
-
? (
|
|
15
|
-
: (
|
|
16
|
+
? (content, metadata) => ({ content: formContent(content), metadata: (0, omit_1.default)(metadata, 'streamMessage') })
|
|
17
|
+
: (content) => formContent(content);
|
|
16
18
|
await client.subscribe({
|
|
17
19
|
streamId,
|
|
18
20
|
partition: options.partition,
|
|
19
21
|
raw: options.raw
|
|
20
|
-
}, (
|
|
21
|
-
const output = formMessage(
|
|
22
|
+
}, (content, metadata) => {
|
|
23
|
+
const output = formMessage(content, metadata);
|
|
22
24
|
console.info((0, isString_1.default)(output) ? output : JSON.stringify(output));
|
|
23
25
|
});
|
|
24
26
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-subscribe.js","sourceRoot":"","sources":["../../bin/streamr-stream-subscribe.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AACxB,uDAA8B;AAC9B,+DAAsC;AAEtC,4CAA4E;AAC5E,0CAAgD;
|
|
1
|
+
{"version":3,"file":"streamr-stream-subscribe.js","sourceRoot":"","sources":["../../bin/streamr-stream-subscribe.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AACxB,uDAA8B;AAC9B,+DAAsC;AAEtC,4CAA4E;AAC5E,0CAAgD;AAChD,0CAA4C;AAS5C,IAAA,6BAAmB,EAAC,KAAK,EAAE,MAAqB,EAAE,QAAgB,EAAE,OAAgB,EAAE,EAAE;IACpF,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,OAAqB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IACpG,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY;QACpC,CAAC,CAAC,CAAC,OAAgB,EAAE,QAAyB,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAA,cAAI,EAAC,QAAQ,EAAE,eAAe,CAAC,EAAE,CAAC;QACjI,CAAC,CAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IAChD,MAAM,MAAM,CAAC,SAAS,CAAC;QACnB,QAAQ;QACR,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,GAAG,EAAE,OAAO,CAAC,GAAG;KACnB,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC7C,OAAO,CAAC,IAAI,CAAC,IAAA,kBAAQ,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;AACN,CAAC,EAAE;IACC,iBAAiB,EAAE,KAAK;IACxB,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,aAAa,EAAE,CAAC,OAAO,CAAC,eAAe;KAC1C,CAAC;CACL,CAAC;KACG,SAAS,CAAC,YAAY,CAAC;KACvB,WAAW,CAAC,oEAAoE,CAAC;KACjF,MAAM,CAAC,6BAA6B,EAAE,WAAW,EAAE,IAAA,yBAAgB,EAAC,aAAa,CAAC,EAAE,CAAC,CAAC;KACtF,MAAM,CAAC,wBAAwB,EAAE,8CAA8C,EAAE,KAAK,CAAC;KACvF,MAAM,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,CAAC;KAC3C,MAAM,CAAC,qBAAqB,EAAE,+CAA+C,EAAE,KAAK,CAAC;KACrF,UAAU,EAAE,CAAA"}
|
|
@@ -14,7 +14,7 @@ commander_1.program
|
|
|
14
14
|
.command('publish', 'publish to a stream')
|
|
15
15
|
.command('search', 'search for streams')
|
|
16
16
|
.command('show', 'info about a stream')
|
|
17
|
-
.command(
|
|
17
|
+
.command('create', 'create a new stream')
|
|
18
18
|
.command('resend', 'request resend of a stream')
|
|
19
19
|
.command('grant-permission', 'grant permission')
|
|
20
20
|
.command('revoke-permission', 'revoke permission')
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/cli-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "100.0.0-pretestnet.2",
|
|
4
4
|
"description": "Command line tools for Streamr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"check": "tsc -p ./tsconfig.json --noEmit",
|
|
16
16
|
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
17
17
|
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
18
|
-
"test": "npm run build && jest --forceExit"
|
|
18
|
+
"test": "npm run build && jest --bail --forceExit"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"streamr",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"license": "AGPL-3.0",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ethersproject/wallet": "^5.5.0",
|
|
30
|
-
"@snapshot-labs/snapshot.js": "^0.
|
|
31
|
-
"@streamr/utils": "
|
|
32
|
-
"commander": "^11.
|
|
30
|
+
"@snapshot-labs/snapshot.js": "^0.7.8",
|
|
31
|
+
"@streamr/utils": "100.0.0-pretestnet.2",
|
|
32
|
+
"commander": "^11.1.0",
|
|
33
33
|
"easy-table": "^1.1.1",
|
|
34
34
|
"event-stream": "^4.0.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
|
-
"streamr-client": "
|
|
36
|
+
"streamr-client": "100.0.0-pretestnet.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@streamr/test-utils": "
|
|
40
|
-
"@types/event-stream": "^4.0.
|
|
41
|
-
"@types/lodash": "^4.14.
|
|
42
|
-
"@types/merge2": "^1.4.
|
|
39
|
+
"@streamr/test-utils": "100.0.0-pretestnet.2",
|
|
40
|
+
"@types/event-stream": "^4.0.3",
|
|
41
|
+
"@types/lodash": "^4.14.200",
|
|
42
|
+
"@types/merge2": "^1.4.3",
|
|
43
43
|
"merge2": "^1.4.1"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/cli-tools",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "100.0.0-pretestnet.2",
|
|
4
4
|
"description": "Command line tools for Streamr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"check": "tsc -p ./tsconfig.json --noEmit",
|
|
16
16
|
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
17
17
|
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
18
|
-
"test": "npm run build && jest --forceExit"
|
|
18
|
+
"test": "npm run build && jest --bail --forceExit"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"streamr",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"license": "AGPL-3.0",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ethersproject/wallet": "^5.5.0",
|
|
30
|
-
"@snapshot-labs/snapshot.js": "^0.
|
|
31
|
-
"@streamr/utils": "
|
|
32
|
-
"commander": "^11.
|
|
30
|
+
"@snapshot-labs/snapshot.js": "^0.7.8",
|
|
31
|
+
"@streamr/utils": "100.0.0-pretestnet.2",
|
|
32
|
+
"commander": "^11.1.0",
|
|
33
33
|
"easy-table": "^1.1.1",
|
|
34
34
|
"event-stream": "^4.0.1",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
|
-
"streamr-client": "
|
|
36
|
+
"streamr-client": "100.0.0-pretestnet.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@streamr/test-utils": "
|
|
40
|
-
"@types/event-stream": "^4.0.
|
|
41
|
-
"@types/lodash": "^4.14.
|
|
42
|
-
"@types/merge2": "^1.4.
|
|
39
|
+
"@streamr/test-utils": "100.0.0-pretestnet.2",
|
|
40
|
+
"@types/event-stream": "^4.0.3",
|
|
41
|
+
"@types/lodash": "^4.14.200",
|
|
42
|
+
"@types/merge2": "^1.4.3",
|
|
43
43
|
"merge2": "^1.4.1"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -4,6 +4,8 @@ import { collect } from '@streamr/utils'
|
|
|
4
4
|
import { StreamPermission } from 'streamr-client'
|
|
5
5
|
import { createTestClient, runCommand, startCommand } from './utils'
|
|
6
6
|
|
|
7
|
+
const TIMEOUT = 30 * 1000
|
|
8
|
+
|
|
7
9
|
describe('publish and subscribe', () => {
|
|
8
10
|
|
|
9
11
|
let publisherPrivateKey: string
|
|
@@ -21,7 +23,7 @@ describe('publish and subscribe', () => {
|
|
|
21
23
|
})
|
|
22
24
|
streamId = stream.id
|
|
23
25
|
await client.destroy()
|
|
24
|
-
},
|
|
26
|
+
}, TIMEOUT)
|
|
25
27
|
|
|
26
28
|
function publishViaCliCommand() {
|
|
27
29
|
setImmediate(async () => {
|
|
@@ -44,7 +46,7 @@ describe('publish and subscribe', () => {
|
|
|
44
46
|
expect(JSON.parse(receivedMessage)).toEqual({
|
|
45
47
|
foo: 123
|
|
46
48
|
})
|
|
47
|
-
},
|
|
49
|
+
}, TIMEOUT)
|
|
48
50
|
|
|
49
51
|
it('raw subscription', async () => {
|
|
50
52
|
const subscriberAbortController = new AbortController()
|
|
@@ -56,7 +58,7 @@ describe('publish and subscribe', () => {
|
|
|
56
58
|
const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
|
|
57
59
|
subscriberAbortController.abort()
|
|
58
60
|
expect(receivedMessage).toMatch(/^[0-9a-fA-F]+$/)
|
|
59
|
-
})
|
|
61
|
+
}, TIMEOUT)
|
|
60
62
|
|
|
61
63
|
it('with metadata', async () => {
|
|
62
64
|
const subscriberAbortController = new AbortController()
|
|
@@ -68,7 +70,7 @@ describe('publish and subscribe', () => {
|
|
|
68
70
|
const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
|
|
69
71
|
subscriberAbortController.abort()
|
|
70
72
|
expect(JSON.parse(receivedMessage)).toMatchObject({
|
|
71
|
-
|
|
73
|
+
content: {
|
|
72
74
|
foo: 123
|
|
73
75
|
},
|
|
74
76
|
metadata: {
|
|
@@ -76,9 +78,31 @@ describe('publish and subscribe', () => {
|
|
|
76
78
|
streamPartition: 0,
|
|
77
79
|
timestamp: expect.any(Number),
|
|
78
80
|
sequenceNumber: 0,
|
|
79
|
-
publisherId:
|
|
81
|
+
publisherId: new Wallet(publisherPrivateKey).address.toLowerCase(),
|
|
82
|
+
msgChainId: expect.stringMatching(/[0-9a-zA-Z]+/)
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
}, TIMEOUT)
|
|
86
|
+
|
|
87
|
+
it('with metadata and raw', async () => {
|
|
88
|
+
const subscriberAbortController = new AbortController()
|
|
89
|
+
const subscriberOutputIterable = startCommand(`stream subscribe ${streamId} --with-metadata --raw`, {
|
|
90
|
+
privateKey: subscriberPrivateKey,
|
|
91
|
+
abortSignal: subscriberAbortController.signal,
|
|
92
|
+
})
|
|
93
|
+
publishViaCliCommand()
|
|
94
|
+
const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
|
|
95
|
+
subscriberAbortController.abort()
|
|
96
|
+
expect(JSON.parse(receivedMessage)).toMatchObject({
|
|
97
|
+
content: expect.stringMatching(/^[0-9a-fA-F]+$/),
|
|
98
|
+
metadata: {
|
|
99
|
+
streamId,
|
|
100
|
+
streamPartition: 0,
|
|
101
|
+
timestamp: expect.any(Number),
|
|
102
|
+
sequenceNumber: 0,
|
|
103
|
+
publisherId: new Wallet(publisherPrivateKey).address.toLowerCase(),
|
|
80
104
|
msgChainId: expect.stringMatching(/[0-9a-zA-Z]+/)
|
|
81
105
|
}
|
|
82
106
|
})
|
|
83
|
-
})
|
|
107
|
+
}, TIMEOUT)
|
|
84
108
|
})
|
|
@@ -24,9 +24,9 @@ describe('resend stream', () => {
|
|
|
24
24
|
const msg = await stream.publish({ msgId })
|
|
25
25
|
messages.push(msg)
|
|
26
26
|
}
|
|
27
|
-
await wait(
|
|
27
|
+
await wait(10000)
|
|
28
28
|
await client.destroy()
|
|
29
|
-
},
|
|
29
|
+
}, 30 * 1000)
|
|
30
30
|
|
|
31
31
|
it('last', async () => {
|
|
32
32
|
const outputLines = await runCommand(`stream resend last 3 ${stream.id}`, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
|
|
2
2
|
import { randomString } from '@streamr/utils'
|
|
3
|
-
import { createTestClient, runCommand } from './utils'
|
|
3
|
+
import { createTestClient, runCommand, waitForTheGraphToHaveIndexed } from './utils'
|
|
4
4
|
|
|
5
5
|
describe('search streams', () => {
|
|
6
6
|
|
|
@@ -9,6 +9,10 @@ describe('search streams', () => {
|
|
|
9
9
|
const client = createTestClient(await fetchPrivateKeyWithGas())
|
|
10
10
|
const stream1 = await client.createStream(`/${testId}-1`)
|
|
11
11
|
const stream2 = await client.createStream(`/${testId}-2`)
|
|
12
|
+
await Promise.all([
|
|
13
|
+
waitForTheGraphToHaveIndexed(stream1, client),
|
|
14
|
+
waitForTheGraphToHaveIndexed(stream2, client)
|
|
15
|
+
])
|
|
12
16
|
await client.destroy()
|
|
13
17
|
const outputLines = await runCommand(`stream search ${testId}`)
|
|
14
18
|
expect(outputLines).toEqual([
|
package/test/stream-show.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Wallet } from '@ethersproject/wallet'
|
|
2
2
|
import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
|
|
3
|
-
import { createTestClient, runCommand } from './utils'
|
|
3
|
+
import { createTestClient, runCommand, waitForTheGraphToHaveIndexed } from './utils'
|
|
4
4
|
|
|
5
5
|
describe('show stream', () => {
|
|
6
6
|
|
|
@@ -8,6 +8,7 @@ describe('show stream', () => {
|
|
|
8
8
|
const creatorPrivateKey = await fetchPrivateKeyWithGas()
|
|
9
9
|
const client = createTestClient(creatorPrivateKey)
|
|
10
10
|
const stream = await client.createStream(`/${Date.now()}`)
|
|
11
|
+
await waitForTheGraphToHaveIndexed(stream, client)
|
|
11
12
|
await client.destroy()
|
|
12
13
|
const outputLines = await runCommand(`stream show ${stream.id} --include-permissions`)
|
|
13
14
|
const outputJson = JSON.parse(outputLines.join(''))
|
package/test/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { collect } from '@streamr/utils'
|
|
1
|
+
import { collect, waitForCondition } from '@streamr/utils'
|
|
2
2
|
import { spawn } from 'child_process'
|
|
3
3
|
import merge2 from 'merge2'
|
|
4
|
-
import { CONFIG_TEST, StreamrClient } from 'streamr-client'
|
|
4
|
+
import { CONFIG_TEST, Stream, StreamrClient } from 'streamr-client'
|
|
5
5
|
|
|
6
6
|
export const DOCKER_DEV_STORAGE_NODE = '0xde1112f631486CfC759A50196853011528bC5FA0'
|
|
7
7
|
|
|
@@ -73,3 +73,13 @@ export const createTestClient = (privateKey?: string): StreamrClient => {
|
|
|
73
73
|
auth: (privateKey !== undefined) ? { privateKey } : undefined
|
|
74
74
|
})
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
export const waitForTheGraphToHaveIndexed = async (stream: Stream, client: StreamrClient): Promise<void> => {
|
|
78
|
+
await waitForCondition(async () => {
|
|
79
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
80
|
+
for await (const _msg of client.searchStreams(stream.id, undefined)) {
|
|
81
|
+
return true
|
|
82
|
+
}
|
|
83
|
+
return false
|
|
84
|
+
}, 15 * 1000, 600)
|
|
85
|
+
}
|