@ethersphere/bee-js 2.1.0 → 3.2.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 (160) hide show
  1. package/README.md +3 -3
  2. package/dist/index.browser.min.js +1 -1
  3. package/dist/index.browser.min.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist/src/bee-debug.d.ts +5 -1
  7. package/dist/src/bee.d.ts +23 -46
  8. package/dist/src/modules/chunk.d.ts +2 -10
  9. package/dist/src/modules/debug/status.d.ts +10 -4
  10. package/dist/src/types/debug.d.ts +19 -0
  11. package/dist/src/types/index.d.ts +31 -2
  12. package/dist/src/utils/bytes.d.ts +1 -1
  13. package/dist/src/utils/error.d.ts +21 -2
  14. package/dist/src/utils/expose.d.ts +1 -0
  15. package/dist/src/utils/http.d.ts +7 -9
  16. package/dist/src/utils/stamps.d.ts +12 -0
  17. package/dist/src/utils/type.d.ts +6 -0
  18. package/package.json +28 -27
  19. package/.babelrc.js +0 -33
  20. package/.depcheckrc.json +0 -27
  21. package/.editorconfig +0 -6
  22. package/.eslintignore +0 -1
  23. package/.eslintrc.js +0 -109
  24. package/.gitattributes +0 -1
  25. package/.github/config.yaml +0 -23
  26. package/.github/workflows/check.yaml +0 -57
  27. package/.github/workflows/publish_npmjs.yaml +0 -20
  28. package/.github/workflows/release_github.yaml +0 -20
  29. package/.github/workflows/tests.yaml +0 -128
  30. package/.huskyrc +0 -5
  31. package/.prettierrc +0 -13
  32. package/.vscode/launch.json +0 -49
  33. package/.vscode/settings.json +0 -39
  34. package/CHANGELOG.md +0 -520
  35. package/CODEOWNERS +0 -1
  36. package/CODE_OF_CONDUCT.md +0 -76
  37. package/commitlint.config.js +0 -3
  38. package/dist/src/modules/stamps.d.ts +0 -4
  39. package/jest-puppeteer.config.js +0 -5
  40. package/jest.config.ts +0 -85
  41. package/src/bee-debug.ts +0 -601
  42. package/src/bee.ts +0 -1087
  43. package/src/chunk/bmt.ts +0 -55
  44. package/src/chunk/cac.ts +0 -79
  45. package/src/chunk/serialize.ts +0 -16
  46. package/src/chunk/signer.ts +0 -141
  47. package/src/chunk/soc.ts +0 -190
  48. package/src/chunk/span.ts +0 -33
  49. package/src/feed/index.ts +0 -217
  50. package/src/feed/json.ts +0 -33
  51. package/src/feed/topic.ts +0 -23
  52. package/src/feed/type.ts +0 -12
  53. package/src/index.ts +0 -24
  54. package/src/modules/bytes.ts +0 -70
  55. package/src/modules/bzz.ts +0 -179
  56. package/src/modules/chunk.ts +0 -69
  57. package/src/modules/debug/balance.ts +0 -63
  58. package/src/modules/debug/chequebook.ts +0 -175
  59. package/src/modules/debug/chunk.ts +0 -39
  60. package/src/modules/debug/connectivity.ts +0 -61
  61. package/src/modules/debug/settlements.ts +0 -33
  62. package/src/modules/debug/stamps.ts +0 -96
  63. package/src/modules/debug/states.ts +0 -35
  64. package/src/modules/debug/status.ts +0 -34
  65. package/src/modules/debug/tag.ts +0 -19
  66. package/src/modules/debug/transactions.ts +0 -79
  67. package/src/modules/feed.ts +0 -105
  68. package/src/modules/pinning.ts +0 -74
  69. package/src/modules/pss.ts +0 -49
  70. package/src/modules/soc.ts +0 -40
  71. package/src/modules/stamps.ts +0 -59
  72. package/src/modules/status.ts +0 -13
  73. package/src/modules/stewardship.ts +0 -32
  74. package/src/modules/tag.ts +0 -83
  75. package/src/types/debug.ts +0 -204
  76. package/src/types/index.ts +0 -561
  77. package/src/types/ky-universal/common.d.ts +0 -17
  78. package/src/types/ky-universal/hooks.d.ts +0 -103
  79. package/src/types/ky-universal/index.d.ts +0 -125
  80. package/src/types/ky-universal/options.d.ts +0 -235
  81. package/src/types/ky-universal/response.d.ts +0 -38
  82. package/src/types/ky-universal/retry.d.ts +0 -39
  83. package/src/types/tar-js.d.ts +0 -1
  84. package/src/types/webpack-bundle-analyzer/index.d.ts +0 -13
  85. package/src/utils/bytes.ts +0 -144
  86. package/src/utils/collection.ts +0 -151
  87. package/src/utils/data.browser.ts +0 -68
  88. package/src/utils/data.ts +0 -48
  89. package/src/utils/error.ts +0 -23
  90. package/src/utils/eth.ts +0 -229
  91. package/src/utils/expose.ts +0 -48
  92. package/src/utils/file.ts +0 -40
  93. package/src/utils/hash.ts +0 -16
  94. package/src/utils/headers.ts +0 -63
  95. package/src/utils/hex.ts +0 -186
  96. package/src/utils/http.ts +0 -141
  97. package/src/utils/merge.ts +0 -34
  98. package/src/utils/pss.ts +0 -16
  99. package/src/utils/stream.ts +0 -146
  100. package/src/utils/tar.ts +0 -30
  101. package/src/utils/type.ts +0 -394
  102. package/src/utils/uint64.ts +0 -31
  103. package/src/utils/url.ts +0 -52
  104. package/test/bee.sh +0 -187
  105. package/test/data/1.txt +0 -1
  106. package/test/data/2.txt +0 -0
  107. package/test/data/empty +0 -0
  108. package/test/data/sub/3.txt +0 -1
  109. package/test/data/sub//303/251 +0 -0
  110. package/test/data/sub//360/237/230/216 +0 -0
  111. package/test/integration/bee-class.browser.spec.ts +0 -272
  112. package/test/integration/bee-class.spec.ts +0 -648
  113. package/test/integration/bee-debug-class.spec.ts +0 -114
  114. package/test/integration/chunk/bmt.spec.ts +0 -33
  115. package/test/integration/chunk/cac.spec.ts +0 -27
  116. package/test/integration/chunk/soc.spec.ts +0 -38
  117. package/test/integration/feed/index.spec.ts +0 -84
  118. package/test/integration/modules/bytes.spec.ts +0 -23
  119. package/test/integration/modules/bzz.spec.ts +0 -265
  120. package/test/integration/modules/chunk.spec.ts +0 -29
  121. package/test/integration/modules/debug/balance.spec.ts +0 -70
  122. package/test/integration/modules/debug/chequebook.spec.ts +0 -64
  123. package/test/integration/modules/debug/connectivity.spec.ts +0 -69
  124. package/test/integration/modules/debug/settlements.spec.ts +0 -34
  125. package/test/integration/modules/debug/states.spec.ts +0 -34
  126. package/test/integration/modules/debug/status.spec.ts +0 -65
  127. package/test/integration/modules/debug/tag.spec.ts +0 -27
  128. package/test/integration/modules/debug/transactions.spec.ts +0 -10
  129. package/test/integration/modules/feed.spec.ts +0 -61
  130. package/test/integration/modules/pinning.spec.ts +0 -155
  131. package/test/integration/modules/pss.spec.ts +0 -105
  132. package/test/integration/modules/status.spec.ts +0 -10
  133. package/test/integration/modules/stewardship.spec.ts +0 -32
  134. package/test/integration/modules/tag.spec.ts +0 -51
  135. package/test/test-type-sequencer.js +0 -36
  136. package/test/testpage/testpage.html +0 -20
  137. package/test/tests-setup.ts +0 -94
  138. package/test/unit/assertions.ts +0 -460
  139. package/test/unit/bee-class.spec.ts +0 -976
  140. package/test/unit/bee-debug-class.spec.ts +0 -435
  141. package/test/unit/chunk/bmt.spec.ts +0 -16
  142. package/test/unit/chunk/cac.spec.ts +0 -29
  143. package/test/unit/chunk/serialize.spec.ts +0 -24
  144. package/test/unit/chunk/signer.spec.ts +0 -140
  145. package/test/unit/chunk/soc.spec.ts +0 -25
  146. package/test/unit/chunk/span.spec.ts +0 -38
  147. package/test/unit/feed/json.spec.ts +0 -73
  148. package/test/unit/nock.ts +0 -151
  149. package/test/unit/utils/bytes.spec.ts +0 -32
  150. package/test/unit/utils/collection.spec.ts +0 -22
  151. package/test/unit/utils/eth.spec.ts +0 -224
  152. package/test/unit/utils/hex.spec.ts +0 -115
  153. package/test/unit/utils/stream.spec.ts +0 -30
  154. package/test/unit/utils/type.spec.ts +0 -32
  155. package/test/unit/utils/uint64.spec.ts +0 -102
  156. package/test/utils.ts +0 -426
  157. package/tsconfig.json +0 -18
  158. package/tsconfig.test.json +0 -11
  159. package/typedoc.json +0 -7
  160. package/webpack.config.ts +0 -141
@@ -1,51 +0,0 @@
1
- import * as tag from '../../../src/modules/tag'
2
- import { beeKy, commonMatchers } from '../../utils'
3
-
4
- const BEE_KY = beeKy()
5
-
6
- commonMatchers()
7
-
8
- describe('modules/tag', () => {
9
- it('should list tags', async () => {
10
- await tag.createTag(BEE_KY)
11
- const tags = await tag.getAllTags(BEE_KY)
12
-
13
- expect(tags).toEqual(
14
- expect.arrayContaining([
15
- expect.objectContaining({
16
- total: expect.any(Number),
17
- processed: expect.any(Number),
18
- synced: expect.any(Number),
19
- uid: expect.any(Number),
20
- startedAt: expect.any(String),
21
- }),
22
- ]),
23
- )
24
- })
25
-
26
- it('should create empty tag', async () => {
27
- const tag1 = await tag.createTag(BEE_KY)
28
-
29
- expect(tag1.total).toBe(0)
30
- expect(tag1.processed).toBe(0)
31
- expect(tag1.synced).toBe(0)
32
- expect(Number.isInteger(tag1.uid)).toBeTruthy()
33
- expect(tag1.startedAt).toBeType('string')
34
- })
35
-
36
- it('should retrieve previously created empty tag', async () => {
37
- const tag1 = await tag.createTag(BEE_KY)
38
- const tag2 = await tag.retrieveTag(BEE_KY, tag1.uid)
39
-
40
- expect(tag1).toEqual(tag2)
41
- expect(tag1).toEqual(
42
- expect.objectContaining({
43
- total: expect.any(Number),
44
- processed: expect.any(Number),
45
- synced: expect.any(Number),
46
- uid: expect.any(Number),
47
- startedAt: expect.any(String),
48
- }),
49
- )
50
- })
51
- })
@@ -1,36 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2
- const Sequencer = require('@jest/test-sequencer').default
3
-
4
- /**
5
- * Jest Sequencer that allows to specify order of execution of tests.
6
- * We are using it to first execute unit tests and then integration when
7
- * whole test suite is run.
8
- *
9
- * https://jestjs.io/docs/next/configuration#testsequencer-string
10
- */
11
- class TestTypeSequencer extends Sequencer {
12
- order = ['unit', 'integration']
13
-
14
- getType(test) {
15
- for (const type of this.order) {
16
- if (test.path.includes(type)) {
17
- return type
18
- }
19
- }
20
- }
21
-
22
- sort(tests) {
23
- // Test structure information
24
- // https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21
25
- const copyTests = Array.from(tests)
26
-
27
- return copyTests.sort((testA, testB) => {
28
- const typeA = this.getType(testA)
29
- const typeB = this.getType(testB)
30
-
31
- return this.order.indexOf(typeA) - this.order.indexOf(typeB)
32
- })
33
- }
34
- }
35
-
36
- module.exports = TestTypeSequencer
@@ -1,20 +0,0 @@
1
- <!doctype html>
2
-
3
- <html lang="en">
4
- <head>
5
- <meta charset="utf-8">
6
- <title>BeeJS testing page - Upload</title>
7
- <script src="../../dist/index.browser.js"></script>
8
- </head>
9
-
10
- <body>
11
- <div>
12
- <!-- Upload file -->
13
- <input type="file" id="upload-file" />
14
- </div>
15
- <div>
16
- <!-- Upload directory -->
17
- <input type="file" id="upload-directory" webkitdirectory mozdirectory />
18
- </div>
19
- </body>
20
- </html>
@@ -1,94 +0,0 @@
1
- /* eslint-disable no-console */
2
- import ky from 'ky-universal'
3
- import { createPostageBatch, getPostageBatch } from '../src/modules/debug/stamps'
4
- import { BatchId, Ky } from '../src'
5
-
6
- export default async function testsSetup(): Promise<void> {
7
- try {
8
- const beeDebugKy = ky.create({
9
- prefixUrl: process.env.BEE_DEBUG_API_URL || 'http://localhost:1635',
10
- timeout: false,
11
- })
12
- const beeDebugPeerKy = ky.create({
13
- prefixUrl: process.env.BEE_PEER_DEBUG_API_URL || 'http://localhost:11635',
14
- timeout: false,
15
- })
16
-
17
- if (process.env.BEE_POSTAGE) {
18
- try {
19
- if (!(await getPostageBatch(beeDebugKy, process.env.BEE_POSTAGE as BatchId)).usable) {
20
- delete process.env.BEE_POSTAGE
21
- console.log('BEE_POSTAGE stamp was found but is not usable')
22
- } else {
23
- console.log('Using configured BEE_POSTAGE stamp.')
24
- }
25
- } catch (e) {
26
- delete process.env.BEE_POSTAGE
27
- console.log('BEE_POSTAGE stamp was not found')
28
- }
29
- }
30
-
31
- if (process.env.BEE_PEER_POSTAGE) {
32
- try {
33
- if (!(await getPostageBatch(beeDebugPeerKy, process.env.BEE_PEER_POSTAGE as BatchId)).usable) {
34
- delete process.env.BEE_PEER_POSTAGE
35
- console.log('BEE_PEER_POSTAGE stamp was found but is not usable')
36
- } else {
37
- console.log('Using configured BEE_PEER_POSTAGE stamp.')
38
- }
39
- } catch (e) {
40
- delete process.env.BEE_PEER_POSTAGE
41
- console.log('BEE_PEER_POSTAGE stamp was not found')
42
- }
43
- }
44
-
45
- if (!process.env.BEE_POSTAGE || !process.env.BEE_PEER_POSTAGE) {
46
- console.log('Creating postage stamps...')
47
-
48
- const stampsOrder: { ky: Ky; env: string }[] = []
49
-
50
- if (!process.env.BEE_POSTAGE) {
51
- stampsOrder.push({ ky: beeDebugKy, env: 'BEE_POSTAGE' })
52
- }
53
-
54
- if (!process.env.BEE_PEER_POSTAGE) {
55
- stampsOrder.push({ ky: beeDebugPeerKy, env: 'BEE_PEER_POSTAGE' })
56
- }
57
-
58
- const stamps = await Promise.all(stampsOrder.map(async order => createPostageBatch(order.ky, '1', 20)))
59
-
60
- for (let i = 0; i < stamps.length; i++) {
61
- process.env[stampsOrder[i].env] = stamps[i]
62
- console.log(`${stampsOrder[i].env}: ${stamps[i]}`)
63
- }
64
-
65
- console.log('Waiting for the stamps to be usable')
66
- let allUsable = true
67
- do {
68
- for (let i = 0; i < stamps.length; i++) {
69
- // eslint-disable-next-line max-depth
70
- try {
71
- // eslint-disable-next-line max-depth
72
- if (!(await getPostageBatch(stampsOrder[i].ky, stamps[i] as BatchId)).usable) {
73
- allUsable = false
74
- break
75
- } else {
76
- allUsable = true
77
- }
78
- } catch (e) {
79
- allUsable = false
80
- break
81
- }
82
- }
83
-
84
- // eslint-disable-next-line no-loop-func
85
- await new Promise<void>(resolve => setTimeout(() => resolve(), 1_000))
86
- } while (!allUsable)
87
- console.log('Usable, yey!')
88
- }
89
- } catch (e) {
90
- // It is possible that for unit tests the Bee nodes does not run
91
- // so we are only logging errors and not leaving them to propagate
92
- console.error(e)
93
- }
94
- }
@@ -1,460 +0,0 @@
1
- /* eslint-disable */
2
- import { BeeArgumentError, BeeOptions } from '../../src'
3
- import { makeBytes } from '../../src/utils/bytes'
4
-
5
- export function testBatchIdAssertion(executor: (input: unknown) => void): void {
6
- it('should throw exception for bad BatchId', async () => {
7
- await expect(() => executor(1)).rejects.toThrow(TypeError)
8
- await expect(() => executor(true)).rejects.toThrow(TypeError)
9
- await expect(() => executor({})).rejects.toThrow(TypeError)
10
- await expect(() => executor(null)).rejects.toThrow(TypeError)
11
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
12
- await expect(() => executor([])).rejects.toThrow(TypeError)
13
- await expect(() => executor('')).rejects.toThrow(TypeError)
14
-
15
- // Not an valid hexstring (ZZZ)
16
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
17
- TypeError,
18
- )
19
-
20
- // Prefixed hexstring is not accepted
21
- await expect(() => executor('0x634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
22
- TypeError,
23
- )
24
- })
25
- }
26
-
27
- export function testDataAssertions(executor: (input: unknown) => void): void {
28
- it('should throw exception for bad Data', async () => {
29
- await expect(() => executor(1)).rejects.toThrow(TypeError)
30
- await expect(() => executor(true)).rejects.toThrow(TypeError)
31
- await expect(() => executor(null)).rejects.toThrow(TypeError)
32
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
33
- await expect(() => executor([])).rejects.toThrow(TypeError)
34
- await expect(() => executor({})).rejects.toThrow(TypeError)
35
- })
36
- }
37
-
38
- export function testFileDataAssertions(executor: (input: unknown) => void): void {
39
- it('should throw exception for bad FileData', async () => {
40
- await expect(() => executor(1)).rejects.toThrow(TypeError)
41
- await expect(() => executor(true)).rejects.toThrow(TypeError)
42
- await expect(() => executor(null)).rejects.toThrow(TypeError)
43
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
44
- await expect(() => executor([])).rejects.toThrow(TypeError)
45
- await expect(() => executor({})).rejects.toThrow(TypeError)
46
- await expect(() => executor({ name: 'some file' })).rejects.toThrow(TypeError)
47
- // eslint-disable-next-line @typescript-eslint/no-empty-function
48
- await expect(() => executor({ pipe: () => {} })).rejects.toThrow(TypeError)
49
- })
50
- }
51
-
52
- export function testUploadOptionsAssertions(executor: (input: unknown) => void): void {
53
- it('should throw exception for bad UploadOptions', async () => {
54
- await expect(() => executor(1)).rejects.toThrow(TypeError)
55
- await expect(() => executor(true)).rejects.toThrow(TypeError)
56
- await expect(() => executor([])).rejects.toThrow(TypeError)
57
- await expect(() => executor('string')).rejects.toThrow(TypeError)
58
-
59
- await expect(() => executor({ pin: 'plur' })).rejects.toThrow(TypeError)
60
- await expect(() => executor({ pin: 1 })).rejects.toThrow(TypeError)
61
- await expect(() => executor({ pin: {} })).rejects.toThrow(TypeError)
62
- await expect(() => executor({ pin: [] })).rejects.toThrow(TypeError)
63
-
64
- await expect(() => executor({ encrypt: 'plur' })).rejects.toThrow(TypeError)
65
- await expect(() => executor({ encrypt: 1 })).rejects.toThrow(TypeError)
66
- await expect(() => executor({ encrypt: {} })).rejects.toThrow(TypeError)
67
- await expect(() => executor({ encrypt: [] })).rejects.toThrow(TypeError)
68
-
69
- await expect(() => executor({ tag: 'plur' })).rejects.toThrow(TypeError)
70
- await expect(() => executor({ tag: true })).rejects.toThrow(TypeError)
71
- await expect(() => executor({ tag: {} })).rejects.toThrow(TypeError)
72
- await expect(() => executor({ tag: [] })).rejects.toThrow(TypeError)
73
- await expect(() => executor({ tag: -1 })).rejects.toThrow(BeeArgumentError)
74
- })
75
- }
76
-
77
- export function testRequestOptionsAssertions(
78
- executor: (input: unknown, beeOptions?: BeeOptions) => void,
79
- testFetch = true,
80
- ): void {
81
- it('should throw exception for bad RequestOptions', async () => {
82
- await expect(() => executor(1)).rejects.toThrow(TypeError)
83
- await expect(() => executor(true)).rejects.toThrow(TypeError)
84
- await expect(() => executor([])).rejects.toThrow(TypeError)
85
- await expect(() => executor(() => {})).rejects.toThrow(TypeError)
86
- await expect(() => executor('string')).rejects.toThrow(TypeError)
87
-
88
- await expect(() => executor({ timeout: 'plur' })).rejects.toThrow(TypeError)
89
- await expect(() => executor({ timeout: true })).rejects.toThrow(TypeError)
90
- await expect(() => executor({ timeout: {} })).rejects.toThrow(TypeError)
91
- await expect(() => executor({ timeout: [] })).rejects.toThrow(TypeError)
92
- await expect(() => executor({ timeout: -1 })).rejects.toThrow(BeeArgumentError)
93
-
94
- await expect(() => executor({ retry: 'plur' })).rejects.toThrow(TypeError)
95
- await expect(() => executor({ retry: true })).rejects.toThrow(TypeError)
96
- await expect(() => executor({ retry: {} })).rejects.toThrow(TypeError)
97
- await expect(() => executor({ retry: [] })).rejects.toThrow(TypeError)
98
- await expect(() => executor({ retry: -1 })).rejects.toThrow(BeeArgumentError)
99
-
100
- await expect(() => executor({ fetch: 'plur' })).rejects.toThrow(TypeError)
101
- await expect(() => executor({ fetch: true })).rejects.toThrow(TypeError)
102
- await expect(() => executor({ fetch: {} })).rejects.toThrow(TypeError)
103
- await expect(() => executor({ fetch: [] })).rejects.toThrow(TypeError)
104
- await expect(() => executor({ fetch: -1 })).rejects.toThrow(TypeError)
105
- await expect(() => executor({ fetch: 1 })).rejects.toThrow(TypeError)
106
- })
107
-
108
- if (testFetch) {
109
- it('should use per-call request options instead of instance request options', async () => {
110
- const instanceFetch = jest.fn()
111
- const instanceMessage = 'instance error'
112
- const instanceError = { message: instanceMessage }
113
- instanceFetch.mockRejectedValue(instanceError)
114
- await expect(() => executor({}, { retry: 0, fetch: instanceFetch })).rejects.toThrow(instanceMessage)
115
- expect(instanceFetch.mock.calls.length).toEqual(1)
116
-
117
- const callFetch = jest.fn()
118
- const callMessage = 'call error'
119
- const callError = { message: callMessage }
120
- callFetch.mockRejectedValue(callError)
121
- await expect(() => executor({ fetch: callFetch }, { retry: 0, fetch: instanceFetch })).rejects.toThrow(
122
- callMessage,
123
- )
124
- expect(instanceFetch.mock.calls.length).toEqual(1) // The count did not change from last call
125
- expect(callFetch.mock.calls.length).toEqual(1)
126
- })
127
- }
128
- }
129
-
130
- export function testPostageBatchOptionsAssertions(executor: (input: unknown) => void): void {
131
- it('should throw exception for bad PostageBatch', async () => {
132
- await expect(() => executor(1)).rejects.toThrow(TypeError)
133
- await expect(() => executor(true)).rejects.toThrow(TypeError)
134
- await expect(() => executor([])).rejects.toThrow(TypeError)
135
- await expect(() => executor('string')).rejects.toThrow(TypeError)
136
-
137
- await expect(() => executor({ gasPrice: 'plur' })).rejects.toThrow(TypeError)
138
- await expect(() => executor({ gasPrice: true })).rejects.toThrow(TypeError)
139
- await expect(() => executor({ gasPrice: {} })).rejects.toThrow(TypeError)
140
- await expect(() => executor({ gasPrice: [] })).rejects.toThrow(TypeError)
141
- await expect(() => executor({ gasPrice: -1 })).rejects.toThrow(BeeArgumentError)
142
-
143
- await expect(() => executor({ immutableFlag: 'plur' })).rejects.toThrow(TypeError)
144
- await expect(() => executor({ immutableFlag: 1 })).rejects.toThrow(TypeError)
145
- await expect(() => executor({ immutableFlag: null })).rejects.toThrow(TypeError)
146
- await expect(() => executor({ immutableFlag: {} })).rejects.toThrow(TypeError)
147
- await expect(() => executor({ immutableFlag: [] })).rejects.toThrow(TypeError)
148
- })
149
- }
150
-
151
- export function testCashoutOptionsAssertions(executor: (input: unknown) => void): void {
152
- it('should throw exception for bad CashoutOptions', async () => {
153
- await expect(() => executor(1)).rejects.toThrow(TypeError)
154
- await expect(() => executor(true)).rejects.toThrow(TypeError)
155
- await expect(() => executor([])).rejects.toThrow(TypeError)
156
- await expect(() => executor('string')).rejects.toThrow(TypeError)
157
-
158
- await expect(() => executor({ gasPrice: 'plur' })).rejects.toThrow(TypeError)
159
- await expect(() => executor({ gasPrice: true })).rejects.toThrow(TypeError)
160
- await expect(() => executor({ gasPrice: {} })).rejects.toThrow(TypeError)
161
- await expect(() => executor({ gasPrice: [] })).rejects.toThrow(TypeError)
162
- await expect(() => executor({ gasPrice: -1 })).rejects.toThrow(BeeArgumentError)
163
-
164
- await expect(() => executor({ gasLimit: 'plur' })).rejects.toThrow(TypeError)
165
- await expect(() => executor({ gasLimit: true })).rejects.toThrow(TypeError)
166
- await expect(() => executor({ gasLimit: {} })).rejects.toThrow(TypeError)
167
- await expect(() => executor({ gasLimit: [] })).rejects.toThrow(TypeError)
168
- await expect(() => executor({ gasLimit: -1 })).rejects.toThrow(BeeArgumentError)
169
- })
170
- }
171
-
172
- export function testFileUploadOptionsAssertions(executor: (input: unknown) => void): void {
173
- it('should throw exception for bad FileUploadOptions', async () => {
174
- await expect(() => executor({ contentType: true })).rejects.toThrow(TypeError)
175
- await expect(() => executor({ contentType: 1 })).rejects.toThrow(TypeError)
176
- await expect(() => executor({ contentType: {} })).rejects.toThrow(TypeError)
177
- await expect(() => executor({ contentType: [] })).rejects.toThrow(TypeError)
178
-
179
- await expect(() => executor({ size: 'plur' })).rejects.toThrow(TypeError)
180
- await expect(() => executor({ size: true })).rejects.toThrow(TypeError)
181
- await expect(() => executor({ size: {} })).rejects.toThrow(TypeError)
182
- await expect(() => executor({ size: [] })).rejects.toThrow(TypeError)
183
- await expect(() => executor({ size: -1 })).rejects.toThrow(BeeArgumentError)
184
- })
185
- }
186
-
187
- export function testCollectionUploadOptionsAssertions(executor: (input: unknown) => void): void {
188
- it('should throw exception for bad CollectionUploadOptions', async () => {
189
- await expect(() => executor({ indexDocument: true })).rejects.toThrow(TypeError)
190
- await expect(() => executor({ indexDocument: 1 })).rejects.toThrow(TypeError)
191
- await expect(() => executor({ indexDocument: {} })).rejects.toThrow(TypeError)
192
- await expect(() => executor({ indexDocument: [] })).rejects.toThrow(TypeError)
193
-
194
- await expect(() => executor({ errorDocument: true })).rejects.toThrow(TypeError)
195
- await expect(() => executor({ errorDocument: 1 })).rejects.toThrow(TypeError)
196
- await expect(() => executor({ errorDocument: {} })).rejects.toThrow(TypeError)
197
- await expect(() => executor({ errorDocument: [] })).rejects.toThrow(TypeError)
198
- })
199
- }
200
-
201
- export function testReferenceAssertions(executor: (input: unknown) => void): void {
202
- it('should throw exception for bad Reference', async () => {
203
- await expect(() => executor(1)).rejects.toThrow(TypeError)
204
- await expect(() => executor(true)).rejects.toThrow(TypeError)
205
- await expect(() => executor({})).rejects.toThrow(TypeError)
206
- await expect(() => executor(null)).rejects.toThrow(TypeError)
207
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
208
- await expect(() => executor([])).rejects.toThrow(TypeError)
209
- await expect(() => executor('')).rejects.toThrow(TypeError)
210
-
211
- // Not an valid hexstring (ZZZ)
212
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
213
- TypeError,
214
- )
215
-
216
- // Prefixed hexstring is not accepted
217
- await expect(() => executor('0x634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
218
- TypeError,
219
- )
220
-
221
- // Length mismatch
222
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
223
- TypeError,
224
- )
225
- })
226
- }
227
-
228
- export function testAddressPrefixAssertions(executor: (input: unknown) => void): void {
229
- it('should throw exception for bad AddressPrefix', async () => {
230
- await expect(() => executor(1)).rejects.toThrow(TypeError)
231
- await expect(() => executor(true)).rejects.toThrow(TypeError)
232
- await expect(() => executor({})).rejects.toThrow(TypeError)
233
- await expect(() => executor(null)).rejects.toThrow(TypeError)
234
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
235
- await expect(() => executor([])).rejects.toThrow(TypeError)
236
- await expect(() => executor('')).rejects.toThrow(TypeError)
237
-
238
- // Not an valid hexstring (ZZZ)
239
- await expect(() => executor('ZZZf')).rejects.toThrow(TypeError)
240
-
241
- // Prefixed hexstring is not accepted
242
- await expect(() => executor('0x634f')).rejects.toThrow(TypeError)
243
-
244
- // Does not allow longer string then the PSS_TARGET_HEX_LENGTH_MAX
245
- await expect(() => executor('1236412')).rejects.toThrow(BeeArgumentError)
246
- })
247
- }
248
-
249
- export function testPublicKeyAssertions(executor: (input: unknown) => void): void {
250
- it('should throw exception for bad PublicKey', async () => {
251
- await expect(() => executor(1)).rejects.toThrow(TypeError)
252
- await expect(() => executor(true)).rejects.toThrow(TypeError)
253
- await expect(() => executor({})).rejects.toThrow(TypeError)
254
- await expect(() => executor([])).rejects.toThrow(TypeError)
255
-
256
- // Not an valid hexstring (ZZZ)
257
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
258
- TypeError,
259
- )
260
-
261
- // Prefixed hexstring is not accepted
262
- await expect(() => executor('0x634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
263
- TypeError,
264
- )
265
-
266
- // Length mismatch
267
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
268
- TypeError,
269
- )
270
- })
271
- }
272
-
273
- export function testPssMessageHandlerAssertions(executor: (input: unknown) => void): void {
274
- it('should throw exception for bad PssMessageHandler', async () => {
275
- await expect(() => executor(1)).rejects.toThrow(TypeError)
276
- await expect(() => executor(true)).rejects.toThrow(TypeError)
277
- await expect(() => executor({})).rejects.toThrow(TypeError)
278
- await expect(() => executor(null)).rejects.toThrow(TypeError)
279
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
280
- await expect(() => executor([])).rejects.toThrow(TypeError)
281
- await expect(() => executor('')).rejects.toThrow(TypeError)
282
-
283
- await expect(() => {
284
- return executor({ onMessage() {} })
285
- }).rejects.toThrow(TypeError)
286
-
287
- await expect(() => {
288
- return executor({ onMessage() {}, onError: '' })
289
- }).rejects.toThrow(TypeError)
290
-
291
- await expect(() => {
292
- return executor({ onMessage() {}, onError: [] })
293
- }).rejects.toThrow(TypeError)
294
-
295
- await expect(() => {
296
- return executor({ onMessage() {}, onError: {} })
297
- }).rejects.toThrow(TypeError)
298
-
299
- await expect(() => {
300
- return executor({ onMessage() {}, onError: true })
301
- }).rejects.toThrow(TypeError)
302
-
303
- await expect(() => {
304
- return executor({ onError() {}, onMessage: true })
305
- }).rejects.toThrow(TypeError)
306
-
307
- await expect(() => {
308
- return executor({ onError() {}, onMessage: {} })
309
- }).rejects.toThrow(TypeError)
310
-
311
- await expect(() => {
312
- return executor({ onError() {}, onMessage: [] })
313
- }).rejects.toThrow(TypeError)
314
-
315
- await expect(() => {
316
- return executor({ onError() {}, onMessage: '' })
317
- }).rejects.toThrow(TypeError)
318
-
319
- await expect(() => {
320
- return executor({ onError() {}, onMessage: 1 })
321
- }).rejects.toThrow(TypeError)
322
- })
323
- }
324
-
325
- export function testTopicAssertions(executor: (input: unknown) => void): void {
326
- it('should throw exception for bad Topic', async () => {
327
- await expect(() => executor(1)).rejects.toThrow(TypeError)
328
- await expect(() => executor(true)).rejects.toThrow(TypeError)
329
- await expect(() => executor({})).rejects.toThrow(TypeError)
330
- await expect(() => executor(null)).rejects.toThrow(TypeError)
331
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
332
- await expect(() => executor([])).rejects.toThrow(TypeError)
333
- })
334
- }
335
-
336
- export function testFeedTopicAssertions(executor: (input: unknown) => void): void {
337
- it('should throw exception for bad Topic', async () => {
338
- await expect(() => executor(1)).rejects.toThrow(TypeError)
339
- await expect(() => executor(true)).rejects.toThrow(TypeError)
340
- await expect(() => executor({})).rejects.toThrow(TypeError)
341
- await expect(() => executor(null)).rejects.toThrow(TypeError)
342
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
343
- await expect(() => executor([])).rejects.toThrow(TypeError)
344
-
345
- // Not an valid hexstring (ZZZ)
346
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
347
- TypeError,
348
- )
349
-
350
- // Length mismatch
351
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
352
- TypeError,
353
- )
354
- })
355
- }
356
-
357
- export function testEthAddressAssertions(executor: (input: unknown) => void): void {
358
- it('should throw exception for bad EthAddress', async () => {
359
- await expect(() => executor(1)).rejects.toThrow(TypeError)
360
- await expect(() => executor(true)).rejects.toThrow(TypeError)
361
- await expect(() => executor({})).rejects.toThrow(TypeError)
362
- await expect(() => executor(null)).rejects.toThrow(TypeError)
363
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
364
- await expect(() => executor([])).rejects.toThrow(TypeError)
365
-
366
- // Not an valid hexstring (ZZZ)
367
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
368
- TypeError,
369
- )
370
-
371
- // Length mismatch
372
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
373
- TypeError,
374
- )
375
-
376
- // Bytes length mismatch
377
- await expect(() => executor(makeBytes(19))).rejects.toThrow(TypeError)
378
- })
379
- }
380
-
381
- export function testMakeSignerAssertions(executor: (input: unknown) => void, optionals = true): void {
382
- it('should throw exception for bad Signer', async () => {
383
- await expect(() => executor(1)).rejects.toThrow(TypeError)
384
- await expect(() => executor(true)).rejects.toThrow(TypeError)
385
- await expect(() => executor({})).rejects.toThrow(TypeError)
386
- await expect(() => executor([])).rejects.toThrow(TypeError)
387
-
388
- if (optionals) {
389
- await expect(() => executor(null)).rejects.toThrow(TypeError)
390
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
391
- }
392
-
393
- // Not an valid hexstring (ZZZ)
394
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
395
- TypeError,
396
- )
397
-
398
- // Hex Length mismatch
399
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
400
- TypeError,
401
- )
402
-
403
- // Bytes Length mismatch
404
- await expect(() => executor(makeBytes(31))).rejects.toThrow(TypeError)
405
-
406
- await expect(() => executor({ address: makeBytes(19), sign: () => {} })).rejects.toThrow(TypeError)
407
- await expect(() => executor({ address: '', sign: () => {} })).rejects.toThrow(TypeError)
408
- await expect(() => executor({ address: undefined, sign: () => {} })).rejects.toThrow(TypeError)
409
- await expect(() => executor({ address: null, sign: () => {} })).rejects.toThrow(TypeError)
410
- await expect(() => executor({ address: [], sign: () => {} })).rejects.toThrow(TypeError)
411
- await expect(() => executor({ address: {}, sign: () => {} })).rejects.toThrow(TypeError)
412
- await expect(() => executor({ address: makeBytes(20), sign: null })).rejects.toThrow(TypeError)
413
- await expect(() => executor({ address: makeBytes(20), sign: undefined })).rejects.toThrow(TypeError)
414
- await expect(() => executor({ address: makeBytes(20), sign: 'asd' })).rejects.toThrow(TypeError)
415
- await expect(() => executor({ address: makeBytes(20), sign: [] })).rejects.toThrow(TypeError)
416
- await expect(() => executor({ address: makeBytes(20), sign: {} })).rejects.toThrow(TypeError)
417
- })
418
- }
419
-
420
- export function testFeedTypeAssertions(executor: (input: unknown) => void, optionals = true): void {
421
- it('should throw exception for bad FeedType', async () => {
422
- await expect(() => executor(1)).rejects.toThrow(TypeError)
423
- await expect(() => executor(true)).rejects.toThrow(TypeError)
424
- await expect(() => executor({})).rejects.toThrow(TypeError)
425
- await expect(() => executor([])).rejects.toThrow(TypeError)
426
- await expect(() => executor('asd')).rejects.toThrow(TypeError)
427
-
428
- if (optionals) {
429
- await expect(() => executor('')).rejects.toThrow(TypeError)
430
- await expect(() => executor(null)).rejects.toThrow(TypeError)
431
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
432
- }
433
- })
434
- }
435
-
436
- export function testAddressAssertions(executor: (input: unknown) => void, optionals = true): void {
437
- it('should throw exception for bad Address', async () => {
438
- await expect(() => executor(1)).rejects.toThrow(TypeError)
439
- await expect(() => executor(true)).rejects.toThrow(TypeError)
440
- await expect(() => executor({})).rejects.toThrow(TypeError)
441
- await expect(() => executor([])).rejects.toThrow(TypeError)
442
- await expect(() => executor('asd')).rejects.toThrow(TypeError)
443
-
444
- // Not an valid hexstring (ZZZ)
445
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
446
- TypeError,
447
- )
448
-
449
- // Hex Length mismatch
450
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
451
- TypeError,
452
- )
453
-
454
- if (optionals) {
455
- await expect(() => executor('')).rejects.toThrow(TypeError)
456
- await expect(() => executor(null)).rejects.toThrow(TypeError)
457
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
458
- }
459
- })
460
- }