@streamr/cli-tools 0.0.1-tatum.0

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.
Files changed (142) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +6 -0
  3. package/LICENSE +661 -0
  4. package/OLD_CHANGELOG.md +141 -0
  5. package/README.md +225 -0
  6. package/bin/streamr-governance-vote.ts +51 -0
  7. package/bin/streamr-governance.ts +10 -0
  8. package/bin/streamr-mock-data-generate.ts +40 -0
  9. package/bin/streamr-mock-data.ts +10 -0
  10. package/bin/streamr-storage-node-add-stream.ts +12 -0
  11. package/bin/streamr-storage-node-list-streams.ts +20 -0
  12. package/bin/streamr-storage-node-list.ts +22 -0
  13. package/bin/streamr-storage-node-remove-stream.ts +12 -0
  14. package/bin/streamr-storage-node.ts +13 -0
  15. package/bin/streamr-stream-create.ts +29 -0
  16. package/bin/streamr-stream-grant-permission.ts +9 -0
  17. package/bin/streamr-stream-publish.ts +66 -0
  18. package/bin/streamr-stream-resend-from.ts +32 -0
  19. package/bin/streamr-stream-resend-last.ts +30 -0
  20. package/bin/streamr-stream-resend-range.ts +38 -0
  21. package/bin/streamr-stream-resend.ts +11 -0
  22. package/bin/streamr-stream-revoke-permission.ts +9 -0
  23. package/bin/streamr-stream-search.ts +61 -0
  24. package/bin/streamr-stream-show.ts +28 -0
  25. package/bin/streamr-stream-subscribe.ts +40 -0
  26. package/bin/streamr-stream.ts +17 -0
  27. package/bin/streamr-wallet-whoami.ts +10 -0
  28. package/bin/streamr-wallet.ts +10 -0
  29. package/bin/streamr.ts +14 -0
  30. package/dist/bin/streamr-governance-vote.d.ts +2 -0
  31. package/dist/bin/streamr-governance-vote.js +52 -0
  32. package/dist/bin/streamr-governance-vote.js.map +1 -0
  33. package/dist/bin/streamr-governance.d.ts +2 -0
  34. package/dist/bin/streamr-governance.js +15 -0
  35. package/dist/bin/streamr-governance.js.map +1 -0
  36. package/dist/bin/streamr-mock-data-generate.d.ts +2 -0
  37. package/dist/bin/streamr-mock-data-generate.js +40 -0
  38. package/dist/bin/streamr-mock-data-generate.js.map +1 -0
  39. package/dist/bin/streamr-mock-data.d.ts +2 -0
  40. package/dist/bin/streamr-mock-data.js +15 -0
  41. package/dist/bin/streamr-mock-data.js.map +1 -0
  42. package/dist/bin/streamr-storage-node-add-stream.d.ts +2 -0
  43. package/dist/bin/streamr-storage-node-add-stream.js +13 -0
  44. package/dist/bin/streamr-storage-node-add-stream.js.map +1 -0
  45. package/dist/bin/streamr-storage-node-list-streams.d.ts +2 -0
  46. package/dist/bin/streamr-storage-node-list-streams.js +24 -0
  47. package/dist/bin/streamr-storage-node-list-streams.js.map +1 -0
  48. package/dist/bin/streamr-storage-node-list.d.ts +2 -0
  49. package/dist/bin/streamr-storage-node-list.js +22 -0
  50. package/dist/bin/streamr-storage-node-list.js.map +1 -0
  51. package/dist/bin/streamr-storage-node-remove-stream.d.ts +2 -0
  52. package/dist/bin/streamr-storage-node-remove-stream.js +13 -0
  53. package/dist/bin/streamr-storage-node-remove-stream.js.map +1 -0
  54. package/dist/bin/streamr-storage-node.d.ts +2 -0
  55. package/dist/bin/streamr-storage-node.js +18 -0
  56. package/dist/bin/streamr-storage-node.js.map +1 -0
  57. package/dist/bin/streamr-stream-create.d.ts +2 -0
  58. package/dist/bin/streamr-stream-create.js +23 -0
  59. package/dist/bin/streamr-stream-create.js.map +1 -0
  60. package/dist/bin/streamr-stream-grant-permission.d.ts +2 -0
  61. package/dist/bin/streamr-stream-grant-permission.js +7 -0
  62. package/dist/bin/streamr-stream-grant-permission.js.map +1 -0
  63. package/dist/bin/streamr-stream-publish.d.ts +2 -0
  64. package/dist/bin/streamr-stream-publish.js +59 -0
  65. package/dist/bin/streamr-stream-publish.js.map +1 -0
  66. package/dist/bin/streamr-stream-resend-from.d.ts +2 -0
  67. package/dist/bin/streamr-stream-resend-from.js +27 -0
  68. package/dist/bin/streamr-stream-resend-from.js.map +1 -0
  69. package/dist/bin/streamr-stream-resend-last.d.ts +2 -0
  70. package/dist/bin/streamr-stream-resend-last.js +26 -0
  71. package/dist/bin/streamr-stream-resend-last.js.map +1 -0
  72. package/dist/bin/streamr-stream-resend-range.d.ts +2 -0
  73. package/dist/bin/streamr-stream-resend-range.js +33 -0
  74. package/dist/bin/streamr-stream-resend-range.js.map +1 -0
  75. package/dist/bin/streamr-stream-resend.d.ts +2 -0
  76. package/dist/bin/streamr-stream-resend.js +13 -0
  77. package/dist/bin/streamr-stream-resend.js.map +1 -0
  78. package/dist/bin/streamr-stream-revoke-permission.d.ts +2 -0
  79. package/dist/bin/streamr-stream-revoke-permission.js +7 -0
  80. package/dist/bin/streamr-stream-revoke-permission.js.map +1 -0
  81. package/dist/bin/streamr-stream-search.d.ts +2 -0
  82. package/dist/bin/streamr-stream-search.js +42 -0
  83. package/dist/bin/streamr-stream-search.js.map +1 -0
  84. package/dist/bin/streamr-stream-show.d.ts +2 -0
  85. package/dist/bin/streamr-stream-show.js +25 -0
  86. package/dist/bin/streamr-stream-show.js.map +1 -0
  87. package/dist/bin/streamr-stream-subscribe.d.ts +2 -0
  88. package/dist/bin/streamr-stream-subscribe.js +37 -0
  89. package/dist/bin/streamr-stream-subscribe.js.map +1 -0
  90. package/dist/bin/streamr-stream.d.ts +2 -0
  91. package/dist/bin/streamr-stream.js +22 -0
  92. package/dist/bin/streamr-stream.js.map +1 -0
  93. package/dist/bin/streamr-wallet-whoami.d.ts +2 -0
  94. package/dist/bin/streamr-wallet-whoami.js +11 -0
  95. package/dist/bin/streamr-wallet-whoami.js.map +1 -0
  96. package/dist/bin/streamr-wallet.d.ts +2 -0
  97. package/dist/bin/streamr-wallet.js +15 -0
  98. package/dist/bin/streamr-wallet.js.map +1 -0
  99. package/dist/bin/streamr.d.ts +2 -0
  100. package/dist/bin/streamr.js +19 -0
  101. package/dist/bin/streamr.js.map +1 -0
  102. package/dist/package.json +45 -0
  103. package/dist/src/client.d.ts +4 -0
  104. package/dist/src/client.js +36 -0
  105. package/dist/src/client.js.map +1 -0
  106. package/dist/src/command.d.ts +13 -0
  107. package/dist/src/command.js +45 -0
  108. package/dist/src/command.js.map +1 -0
  109. package/dist/src/common.d.ts +6 -0
  110. package/dist/src/common.js +32 -0
  111. package/dist/src/common.js.map +1 -0
  112. package/dist/src/config.d.ts +6 -0
  113. package/dist/src/config.js +58 -0
  114. package/dist/src/config.js.map +1 -0
  115. package/dist/src/logLevel.d.ts +1 -0
  116. package/dist/src/logLevel.js +11 -0
  117. package/dist/src/logLevel.js.map +1 -0
  118. package/dist/src/permission.d.ts +5 -0
  119. package/dist/src/permission.js +53 -0
  120. package/dist/src/permission.js.map +1 -0
  121. package/dist/src/resend.d.ts +3 -0
  122. package/dist/src/resend.js +32 -0
  123. package/dist/src/resend.js.map +1 -0
  124. package/package.json +45 -0
  125. package/src/client.ts +35 -0
  126. package/src/command.ts +51 -0
  127. package/src/common.ts +25 -0
  128. package/src/config.ts +56 -0
  129. package/src/logLevel.ts +9 -0
  130. package/src/permission.ts +53 -0
  131. package/src/resend.ts +37 -0
  132. package/test/mock-data.test.ts +19 -0
  133. package/test/storage-node.test.ts +32 -0
  134. package/test/stream-create.test.ts +26 -0
  135. package/test/stream-permission.test.ts +29 -0
  136. package/test/stream-publish-subscribe.test.ts +86 -0
  137. package/test/stream-resend.test.ts +66 -0
  138. package/test/stream-search.test.ts +24 -0
  139. package/test/stream-show.test.ts +31 -0
  140. package/test/utils.ts +85 -0
  141. package/test/wallet.test.ts +11 -0
  142. package/tsconfig.json +16 -0
@@ -0,0 +1,32 @@
1
+ import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
2
+ import 'jest-extended'
3
+ import { StreamID } from 'streamr-client'
4
+ import { DOCKER_DEV_STORAGE_NODE, createTestClient, runCommand } from './utils'
5
+
6
+ const isStored = async (streamId: StreamID): Promise<boolean> => {
7
+ const output = await runCommand(`storage-node list-streams ${DOCKER_DEV_STORAGE_NODE}`)
8
+ return output.join().includes(streamId)
9
+ }
10
+
11
+ describe('storage node', () => {
12
+
13
+ it('add and remove stream', async () => {
14
+ const privateKey = await fetchPrivateKeyWithGas()
15
+ const client = createTestClient(privateKey)
16
+ const stream = await client.createStream(`/${Date.now()}`)
17
+ await client.destroy()
18
+ await runCommand(`storage-node add-stream ${DOCKER_DEV_STORAGE_NODE} ${stream.id}`, {
19
+ privateKey
20
+ })
21
+ expect(await isStored(stream.id)).toBeTrue()
22
+ await runCommand(`storage-node remove-stream ${DOCKER_DEV_STORAGE_NODE} ${stream.id}`, {
23
+ privateKey
24
+ })
25
+ expect(await isStored(stream.id)).toBeFalse()
26
+ }, 80 * 1000)
27
+
28
+ it('list nodes', async () => {
29
+ const outputLines = await runCommand('storage-node list')
30
+ expect(outputLines.join()).toMatch(DOCKER_DEV_STORAGE_NODE.toLowerCase())
31
+ })
32
+ })
@@ -0,0 +1,26 @@
1
+ import { Wallet } from '@ethersproject/wallet'
2
+ import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
3
+ import { createTestClient, runCommand } from './utils'
4
+
5
+ describe('create stream', () => {
6
+
7
+ it('happy path', async () => {
8
+ const privateKey = await fetchPrivateKeyWithGas()
9
+ const address = new Wallet(privateKey).address.toLowerCase()
10
+ const path = `/${Date.now()}`
11
+ const streamId = `${address}${path}`
12
+ const outputLines = await runCommand(`stream create ${path}`, {
13
+ privateKey
14
+ })
15
+ const outputJson = JSON.parse(outputLines.join(''))
16
+ expect(outputJson).toMatchObject({
17
+ id: streamId,
18
+ partitions: 1
19
+ })
20
+ const client = createTestClient()
21
+ const stream = await client.getStream(streamId)
22
+ expect(stream.getMetadata().partitions).toBe(1)
23
+ await client.destroy()
24
+ }, 20 * 1000)
25
+
26
+ })
@@ -0,0 +1,29 @@
1
+ import { fetchPrivateKeyWithGas, randomEthereumAddress } from '@streamr/test-utils'
2
+ import 'jest-extended'
3
+ import { StreamPermission } from 'streamr-client'
4
+ import { createTestClient, runCommand } from './utils'
5
+
6
+ describe('permission', () => {
7
+
8
+ it('grant and revoke', async () => {
9
+ const privateKey = await fetchPrivateKeyWithGas()
10
+ const client = createTestClient(privateKey)
11
+ const stream = await client.createStream(`/${Date.now()}`)
12
+ const otherUser = randomEthereumAddress()
13
+ const hasPermission = () => client.hasPermission({
14
+ user: otherUser,
15
+ permission: StreamPermission.PUBLISH,
16
+ streamId: stream.id,
17
+ allowPublic: false
18
+ })
19
+ await runCommand(`stream grant-permission ${stream.id} ${otherUser} publish`, {
20
+ privateKey
21
+ })
22
+ expect(await hasPermission()).toBeTrue()
23
+ await runCommand(`stream revoke-permission ${stream.id} ${otherUser} publish`, {
24
+ privateKey
25
+ })
26
+ expect(await hasPermission()).toBeFalse()
27
+ await client.destroy()
28
+ }, 40 * 1000)
29
+ })
@@ -0,0 +1,86 @@
1
+ import { Wallet } from '@ethersproject/wallet'
2
+ import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
3
+ import { collect } from '@streamr/utils'
4
+ import { StreamPermission } from 'streamr-client'
5
+ import { createTestClient, runCommand, startCommand } from './utils'
6
+
7
+ const TIMEOUT = 30 * 1000
8
+
9
+ describe('publish and subscribe', () => {
10
+
11
+ let publisherPrivateKey: string
12
+ let subscriberPrivateKey: string
13
+ let streamId: string
14
+
15
+ beforeAll(async () => {
16
+ publisherPrivateKey = await fetchPrivateKeyWithGas()
17
+ subscriberPrivateKey = await fetchPrivateKeyWithGas()
18
+ const client = createTestClient(publisherPrivateKey)
19
+ const stream = await client.createStream(`/${Date.now()}`)
20
+ await stream.grantPermissions({
21
+ user: new Wallet(subscriberPrivateKey).address,
22
+ permissions: [StreamPermission.SUBSCRIBE]
23
+ })
24
+ streamId = stream.id
25
+ await client.destroy()
26
+ }, TIMEOUT)
27
+
28
+ function publishViaCliCommand() {
29
+ setImmediate(async () => {
30
+ await runCommand(`stream publish ${streamId}`, {
31
+ inputLines: [JSON.stringify({ foo: 123 })],
32
+ privateKey: publisherPrivateKey
33
+ })
34
+ })
35
+ }
36
+
37
+ it('happy path', async () => {
38
+ const subscriberAbortController = new AbortController()
39
+ const subscriberOutputIterable = startCommand(`stream subscribe ${streamId}`, {
40
+ privateKey: subscriberPrivateKey,
41
+ abortSignal: subscriberAbortController.signal
42
+ })
43
+ publishViaCliCommand()
44
+ const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
45
+ subscriberAbortController.abort()
46
+ expect(JSON.parse(receivedMessage)).toEqual({
47
+ foo: 123
48
+ })
49
+ }, TIMEOUT)
50
+
51
+ it('raw subscription', async () => {
52
+ const subscriberAbortController = new AbortController()
53
+ const subscriberOutputIterable = startCommand(`stream subscribe ${streamId} --raw`, {
54
+ privateKey: subscriberPrivateKey,
55
+ abortSignal: subscriberAbortController.signal,
56
+ })
57
+ publishViaCliCommand()
58
+ const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
59
+ subscriberAbortController.abort()
60
+ expect(receivedMessage).toMatch(/^[0-9a-fA-F]+$/)
61
+ }, TIMEOUT)
62
+
63
+ it('with metadata', async () => {
64
+ const subscriberAbortController = new AbortController()
65
+ const subscriberOutputIterable = startCommand(`stream subscribe ${streamId} --with-metadata`, {
66
+ privateKey: subscriberPrivateKey,
67
+ abortSignal: subscriberAbortController.signal,
68
+ })
69
+ publishViaCliCommand()
70
+ const receivedMessage = (await collect(subscriberOutputIterable, 1))[0]
71
+ subscriberAbortController.abort()
72
+ expect(JSON.parse(receivedMessage)).toMatchObject({
73
+ message: {
74
+ foo: 123
75
+ },
76
+ metadata: {
77
+ streamId,
78
+ streamPartition: 0,
79
+ timestamp: expect.any(Number),
80
+ sequenceNumber: 0,
81
+ publisherId: new Wallet(publisherPrivateKey).address.toLowerCase(),
82
+ msgChainId: expect.stringMatching(/[0-9a-zA-Z]+/)
83
+ }
84
+ })
85
+ }, TIMEOUT)
86
+ })
@@ -0,0 +1,66 @@
1
+ import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
2
+ import range from 'lodash/range'
3
+ import { Message, Stream } from 'streamr-client'
4
+ import { DOCKER_DEV_STORAGE_NODE, createTestClient, runCommand } from './utils'
5
+ import { wait } from '@streamr/utils'
6
+
7
+ const parseJSONs = (lines: string[]): any[] => {
8
+ return lines.map((line) => JSON.parse(line))
9
+ }
10
+
11
+ describe('resend stream', () => {
12
+
13
+ let privateKey: string
14
+ let stream: Stream
15
+ const messages: Message[] = []
16
+
17
+ beforeAll(async () => {
18
+ privateKey = await fetchPrivateKeyWithGas()
19
+ const client = createTestClient(privateKey)
20
+ stream = await client.createStream(`/${Date.now()}`)
21
+ await stream.addToStorageNode(DOCKER_DEV_STORAGE_NODE)
22
+ for (const msgId of range(10)) {
23
+ await wait(10) // to prevent duplicate timestamps (to make test assertions simpler)
24
+ const msg = await stream.publish({ msgId })
25
+ messages.push(msg)
26
+ }
27
+ await wait(10000)
28
+ await client.destroy()
29
+ }, 30 * 1000)
30
+
31
+ it('last', async () => {
32
+ const outputLines = await runCommand(`stream resend last 3 ${stream.id}`, {
33
+ privateKey
34
+ })
35
+ expect(parseJSONs(outputLines)).toEqual([
36
+ { msgId: 7 },
37
+ { msgId: 8 },
38
+ { msgId: 9 }
39
+ ])
40
+ }, 20 * 1000)
41
+
42
+ it('from', async () => {
43
+ const minTimestamp = new Date(messages[8].timestamp).toISOString()
44
+ const outputLines = await runCommand(`stream resend from ${minTimestamp} ${stream.id}`, {
45
+ privateKey
46
+ })
47
+ expect(parseJSONs(outputLines)).toEqual([
48
+ { msgId: 8 },
49
+ { msgId: 9 }
50
+ ])
51
+ }, 20 * 1000)
52
+
53
+ it('range', async () => {
54
+ const minTimestamp = new Date(messages[2].timestamp).toISOString()
55
+ const maxTimestamp = new Date(messages[4].timestamp).toISOString()
56
+ const outputLines = await runCommand(`stream resend range ${minTimestamp} ${maxTimestamp} ${stream.id}`, {
57
+ privateKey
58
+ })
59
+ expect(parseJSONs(outputLines)).toEqual([
60
+ { msgId: 2 },
61
+ { msgId: 3 },
62
+ { msgId: 4 }
63
+ ])
64
+ }, 20 * 1000)
65
+
66
+ })
@@ -0,0 +1,24 @@
1
+ import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
2
+ import { randomString } from '@streamr/utils'
3
+ import { createTestClient, runCommand, waitForTheGraphToHaveIndexed } from './utils'
4
+
5
+ describe('search streams', () => {
6
+
7
+ it('happy path', async () => {
8
+ const testId = randomString(10)
9
+ const client = createTestClient(await fetchPrivateKeyWithGas())
10
+ const stream1 = await client.createStream(`/${testId}-1`)
11
+ const stream2 = await client.createStream(`/${testId}-2`)
12
+ await Promise.all([
13
+ waitForTheGraphToHaveIndexed(stream1, client),
14
+ waitForTheGraphToHaveIndexed(stream2, client)
15
+ ])
16
+ await client.destroy()
17
+ const outputLines = await runCommand(`stream search ${testId}`)
18
+ expect(outputLines).toEqual([
19
+ stream1.id,
20
+ stream2.id
21
+ ])
22
+ }, 20 * 1000)
23
+
24
+ })
@@ -0,0 +1,31 @@
1
+ import { Wallet } from '@ethersproject/wallet'
2
+ import { fetchPrivateKeyWithGas } from '@streamr/test-utils'
3
+ import { createTestClient, runCommand, waitForTheGraphToHaveIndexed } from './utils'
4
+
5
+ describe('show stream', () => {
6
+
7
+ it('happy path', async () => {
8
+ const creatorPrivateKey = await fetchPrivateKeyWithGas()
9
+ const client = createTestClient(creatorPrivateKey)
10
+ const stream = await client.createStream(`/${Date.now()}`)
11
+ await waitForTheGraphToHaveIndexed(stream, client)
12
+ await client.destroy()
13
+ const outputLines = await runCommand(`stream show ${stream.id} --include-permissions`)
14
+ const outputJson = JSON.parse(outputLines.join(''))
15
+ expect(outputJson).toMatchObject({
16
+ id: stream.id,
17
+ partitions: 1,
18
+ permissions: [{
19
+ permissions: [
20
+ 'edit',
21
+ 'delete',
22
+ 'publish',
23
+ 'subscribe',
24
+ 'grant'
25
+ ],
26
+ user: new Wallet(creatorPrivateKey).address.toLowerCase()
27
+ }]
28
+ })
29
+ }, 20 * 1000)
30
+
31
+ })
package/test/utils.ts ADDED
@@ -0,0 +1,85 @@
1
+ import { collect, waitForCondition } from '@streamr/utils'
2
+ import { spawn } from 'child_process'
3
+ import merge2 from 'merge2'
4
+ import { CONFIG_TEST, Stream, StreamrClient } from 'streamr-client'
5
+
6
+ export const DOCKER_DEV_STORAGE_NODE = '0xde1112f631486CfC759A50196853011528bC5FA0'
7
+
8
+ export interface StartCommandOptions {
9
+ privateKey?: string
10
+ devEnvironment?: boolean
11
+ inputLines?: string[]
12
+ abortSignal?: AbortSignal
13
+ }
14
+
15
+ export const runCommand = async (commandLine: string, opts?: StartCommandOptions): Promise<string[]> => {
16
+ const lines = startCommand(commandLine, opts)
17
+ return await collect(lines)
18
+ }
19
+
20
+ export async function* startCommand(commandLine: string, opts?: StartCommandOptions): AsyncGenerator<string> {
21
+ const args: string[] = ['dist/bin/streamr.js']
22
+ args.push(...commandLine.split(' '))
23
+ if (opts?.privateKey !== undefined) {
24
+ args.push('--private-key', opts.privateKey)
25
+ }
26
+ if (opts?.devEnvironment !== false) {
27
+ args.push('--dev')
28
+ }
29
+ const executable = spawn(`node`, args, {
30
+ signal: opts?.abortSignal,
31
+ env: {
32
+ PATH: process.env.PATH,
33
+ STREAMR_DOCKER_DEV_HOST: process.env.STREAMR_DOCKER_DEV_HOST
34
+ }
35
+ })
36
+ executable.on('error', (err: any) => {
37
+ // expected error when AbortSignal#abort is called
38
+ if (err.code !== 'ABORT_ERR') {
39
+ console.error(err)
40
+ }
41
+ })
42
+ const outputs = merge2(executable.stdout, executable.stderr)
43
+ if (opts?.inputLines !== undefined) {
44
+ setImmediate(() => {
45
+ executable.stdin.write(opts.inputLines!.join('\n') + '\n')
46
+ })
47
+ }
48
+ yield* lines(outputs[Symbol.asyncIterator]())
49
+ }
50
+
51
+ async function* lines(src: AsyncIterable<Buffer>): AsyncGenerator<string, any, any> {
52
+ let buffer = ''
53
+ for await (const chunk of src) {
54
+ buffer += chunk.toString('utf-8')
55
+ while (true) {
56
+ const delimeterPos = buffer.indexOf('\n')
57
+ if (delimeterPos === -1) {
58
+ break
59
+ }
60
+ const line = buffer.substring(0, delimeterPos)
61
+ yield line
62
+ buffer = buffer.substring(delimeterPos + 1)
63
+ }
64
+ }
65
+ if (buffer !== '') {
66
+ yield buffer
67
+ }
68
+ }
69
+
70
+ export const createTestClient = (privateKey?: string): StreamrClient => {
71
+ return new StreamrClient({
72
+ ...CONFIG_TEST,
73
+ auth: (privateKey !== undefined) ? { privateKey } : undefined
74
+ })
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
+ }
@@ -0,0 +1,11 @@
1
+ import { runCommand } from './utils'
2
+
3
+ describe('wallet', () => {
4
+
5
+ it('whoami', async () => {
6
+ const outputLines = await runCommand('wallet whoami')
7
+ expect(outputLines.length).toBe(1)
8
+ expect(outputLines[0]).toMatch(/^0x[0-9a-f]{40}$/)
9
+ })
10
+
11
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "../../tsconfig.node.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "outDir": "dist"
6
+ },
7
+ "include": [
8
+ "package.json",
9
+ "src/**/*",
10
+ "bin/**/*"
11
+ ],
12
+ "references": [
13
+ { "path": "../utils/tsconfig.node.json" },
14
+ { "path": "../client/tsconfig.node.json" }
15
+ ]
16
+ }