@ethersphere/bee-js 1.2.1 → 3.0.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 (181) hide show
  1. package/CHANGELOG.md +135 -2
  2. package/README.md +3 -1
  3. package/dist/index.browser.min.js +1 -1
  4. package/dist/index.browser.min.js.LICENSE.txt +51 -0
  5. package/dist/index.browser.min.js.map +1 -1
  6. package/dist/index.min.js +1 -1
  7. package/dist/index.min.js.LICENSE.txt +42 -0
  8. package/dist/index.min.js.map +1 -1
  9. package/dist/src/bee-debug.d.ts +75 -38
  10. package/dist/src/bee.d.ts +88 -82
  11. package/dist/src/chunk/soc.d.ts +6 -6
  12. package/dist/src/feed/index.d.ts +7 -7
  13. package/dist/src/feed/json.d.ts +2 -2
  14. package/dist/src/modules/bytes.d.ts +8 -11
  15. package/dist/src/modules/bzz.d.ts +9 -14
  16. package/dist/src/modules/chunk.d.ts +7 -11
  17. package/dist/src/modules/debug/balance.d.ts +9 -9
  18. package/dist/src/modules/debug/chequebook.d.ts +17 -18
  19. package/dist/src/modules/debug/chunk.d.ts +5 -5
  20. package/dist/src/modules/debug/connectivity.d.ts +7 -7
  21. package/dist/src/modules/debug/settlements.d.ts +5 -5
  22. package/dist/src/modules/debug/stamps.d.ts +7 -5
  23. package/dist/src/modules/debug/states.d.ts +5 -5
  24. package/dist/src/modules/debug/status.d.ts +5 -4
  25. package/dist/src/modules/debug/tag.d.ts +3 -3
  26. package/dist/src/modules/debug/transactions.d.ts +9 -9
  27. package/dist/src/modules/feed.d.ts +5 -5
  28. package/dist/src/modules/pinning.d.ts +9 -9
  29. package/dist/src/modules/pss.d.ts +4 -3
  30. package/dist/src/modules/soc.d.ts +3 -3
  31. package/dist/src/modules/status.d.ts +3 -2
  32. package/dist/src/modules/stewardship.d.ts +4 -4
  33. package/dist/src/modules/tag.d.ts +6 -6
  34. package/dist/src/types/debug.d.ts +4 -2
  35. package/dist/src/types/index.d.ts +71 -19
  36. package/dist/src/utils/bytes.d.ts +1 -1
  37. package/dist/src/utils/data.browser.d.ts +3 -1
  38. package/dist/src/utils/data.d.ts +7 -4
  39. package/dist/src/utils/expose.d.ts +6 -9
  40. package/dist/src/utils/headers.d.ts +3 -3
  41. package/dist/src/utils/http.d.ts +25 -0
  42. package/dist/src/utils/merge.d.ts +8 -0
  43. package/dist/src/utils/pss.d.ts +9 -0
  44. package/dist/src/utils/stream.d.ts +37 -0
  45. package/dist/src/utils/type.d.ts +19 -9
  46. package/package.json +15 -8
  47. package/.babelrc.js +0 -33
  48. package/.depcheckrc.json +0 -27
  49. package/.editorconfig +0 -6
  50. package/.eslintignore +0 -1
  51. package/.eslintrc.js +0 -108
  52. package/.gitattributes +0 -1
  53. package/.github/config.yaml +0 -23
  54. package/.github/workflows/check.yaml +0 -57
  55. package/.github/workflows/publish_npmjs.yaml +0 -20
  56. package/.github/workflows/release_github.yaml +0 -20
  57. package/.github/workflows/tests.yaml +0 -128
  58. package/.huskyrc +0 -5
  59. package/.prettierrc +0 -13
  60. package/.vscode/launch.json +0 -49
  61. package/.vscode/settings.json +0 -39
  62. package/CODEOWNERS +0 -1
  63. package/CODE_OF_CONDUCT.md +0 -76
  64. package/commitlint.config.js +0 -3
  65. package/dist/src/modules/stamps.d.ts +0 -4
  66. package/dist/src/utils/hooks.d.ts +0 -31
  67. package/dist/src/utils/safe-axios.d.ts +0 -8
  68. package/jest-puppeteer.config.js +0 -5
  69. package/jest.config.ts +0 -170
  70. package/src/bee-debug.ts +0 -440
  71. package/src/bee.ts +0 -941
  72. package/src/chunk/bmt.ts +0 -55
  73. package/src/chunk/cac.ts +0 -79
  74. package/src/chunk/serialize.ts +0 -16
  75. package/src/chunk/signer.ts +0 -141
  76. package/src/chunk/soc.ts +0 -190
  77. package/src/chunk/span.ts +0 -33
  78. package/src/feed/index.ts +0 -221
  79. package/src/feed/json.ts +0 -32
  80. package/src/feed/topic.ts +0 -23
  81. package/src/feed/type.ts +0 -12
  82. package/src/index.ts +0 -24
  83. package/src/modules/bytes.ts +0 -75
  84. package/src/modules/bzz.ts +0 -184
  85. package/src/modules/chunk.ts +0 -75
  86. package/src/modules/debug/balance.ts +0 -63
  87. package/src/modules/debug/chequebook.ts +0 -174
  88. package/src/modules/debug/chunk.ts +0 -39
  89. package/src/modules/debug/connectivity.ts +0 -61
  90. package/src/modules/debug/settlements.ts +0 -33
  91. package/src/modules/debug/stamps.ts +0 -69
  92. package/src/modules/debug/states.ts +0 -35
  93. package/src/modules/debug/status.ts +0 -34
  94. package/src/modules/debug/tag.ts +0 -19
  95. package/src/modules/debug/transactions.ts +0 -79
  96. package/src/modules/feed.ts +0 -92
  97. package/src/modules/pinning.ts +0 -74
  98. package/src/modules/pss.ts +0 -48
  99. package/src/modules/soc.ts +0 -41
  100. package/src/modules/stamps.ts +0 -59
  101. package/src/modules/status.ts +0 -13
  102. package/src/modules/stewardship.ts +0 -21
  103. package/src/modules/tag.ts +0 -83
  104. package/src/types/axios/index.d.ts +0 -18
  105. package/src/types/debug.ts +0 -204
  106. package/src/types/index.ts +0 -497
  107. package/src/types/tar-js.d.ts +0 -1
  108. package/src/types/webpack-bundle-analyzer/index.d.ts +0 -13
  109. package/src/utils/bytes.ts +0 -144
  110. package/src/utils/collection.ts +0 -151
  111. package/src/utils/data.browser.ts +0 -24
  112. package/src/utils/data.ts +0 -35
  113. package/src/utils/error.ts +0 -23
  114. package/src/utils/eth.ts +0 -229
  115. package/src/utils/expose.ts +0 -10
  116. package/src/utils/file.ts +0 -40
  117. package/src/utils/hash.ts +0 -16
  118. package/src/utils/headers.ts +0 -63
  119. package/src/utils/hex.ts +0 -186
  120. package/src/utils/hooks.ts +0 -89
  121. package/src/utils/safe-axios.ts +0 -98
  122. package/src/utils/tar.ts +0 -30
  123. package/src/utils/type.ts +0 -302
  124. package/src/utils/uint64.ts +0 -31
  125. package/src/utils/url.ts +0 -52
  126. package/test/bee.sh +0 -187
  127. package/test/data/1.txt +0 -1
  128. package/test/data/2.txt +0 -0
  129. package/test/data/empty +0 -0
  130. package/test/data/sub/3.txt +0 -1
  131. package/test/data/sub//303/251 +0 -0
  132. package/test/data/sub//360/237/230/216 +0 -0
  133. package/test/integration/bee-class.browser.spec.ts +0 -215
  134. package/test/integration/bee-class.spec.ts +0 -595
  135. package/test/integration/bee-debug-class.spec.ts +0 -85
  136. package/test/integration/chunk/bmt.spec.ts +0 -33
  137. package/test/integration/chunk/cac.spec.ts +0 -27
  138. package/test/integration/chunk/soc.spec.ts +0 -38
  139. package/test/integration/feed/index.spec.ts +0 -84
  140. package/test/integration/modules/bytes.spec.ts +0 -23
  141. package/test/integration/modules/bzz.spec.ts +0 -270
  142. package/test/integration/modules/chunk.spec.ts +0 -29
  143. package/test/integration/modules/debug/balance.spec.ts +0 -70
  144. package/test/integration/modules/debug/chequebook.spec.ts +0 -64
  145. package/test/integration/modules/debug/connectivity.spec.ts +0 -69
  146. package/test/integration/modules/debug/settlements.spec.ts +0 -34
  147. package/test/integration/modules/debug/states.spec.ts +0 -34
  148. package/test/integration/modules/debug/status.spec.ts +0 -65
  149. package/test/integration/modules/debug/tag.spec.ts +0 -27
  150. package/test/integration/modules/feed.spec.ts +0 -61
  151. package/test/integration/modules/pinning.spec.ts +0 -155
  152. package/test/integration/modules/pss.spec.ts +0 -92
  153. package/test/integration/modules/status.spec.ts +0 -10
  154. package/test/integration/modules/stewardship.spec.ts +0 -32
  155. package/test/integration/modules/tag.spec.ts +0 -51
  156. package/test/test-type-sequencer.js +0 -36
  157. package/test/testpage/testpage.html +0 -20
  158. package/test/unit/assertions.ts +0 -376
  159. package/test/unit/bee-class.spec.ts +0 -685
  160. package/test/unit/bee-debug-class.spec.ts +0 -365
  161. package/test/unit/chunk/bmt.spec.ts +0 -16
  162. package/test/unit/chunk/cac.spec.ts +0 -29
  163. package/test/unit/chunk/serialize.spec.ts +0 -24
  164. package/test/unit/chunk/signer.spec.ts +0 -140
  165. package/test/unit/chunk/soc.spec.ts +0 -25
  166. package/test/unit/chunk/span.spec.ts +0 -38
  167. package/test/unit/feed/json.spec.ts +0 -73
  168. package/test/unit/nock.ts +0 -134
  169. package/test/unit/utils/bytes.spec.ts +0 -32
  170. package/test/unit/utils/collection.spec.ts +0 -22
  171. package/test/unit/utils/eth.spec.ts +0 -224
  172. package/test/unit/utils/hex.spec.ts +0 -115
  173. package/test/unit/utils/hooks.spec.ts +0 -179
  174. package/test/unit/utils/safe-axios.spec.ts +0 -20
  175. package/test/unit/utils/type.spec.ts +0 -32
  176. package/test/unit/utils/uint64.spec.ts +0 -102
  177. package/test/utils.ts +0 -292
  178. package/tsconfig.json +0 -18
  179. package/tsconfig.test.json +0 -11
  180. package/typedoc.json +0 -7
  181. package/webpack.config.ts +0 -141
@@ -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,376 +0,0 @@
1
- /* eslint-disable */
2
- import { BeeArgumentError } 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
- await expect(() => executor({ axiosOptions: 'plur' })).rejects.toThrow(TypeError)
76
- await expect(() => executor({ axiosOptions: true })).rejects.toThrow(TypeError)
77
- await expect(() => executor({ axiosOptions: [] })).rejects.toThrow(TypeError)
78
- await expect(() => executor({ axiosOptions: -1 })).rejects.toThrow(TypeError)
79
- })
80
- }
81
-
82
- export function testFileUploadOptionsAssertions(executor: (input: unknown) => void): void {
83
- it('should throw exception for bad FileUploadOptions', async () => {
84
- await expect(() => executor({ contentType: true })).rejects.toThrow(TypeError)
85
- await expect(() => executor({ contentType: 1 })).rejects.toThrow(TypeError)
86
- await expect(() => executor({ contentType: {} })).rejects.toThrow(TypeError)
87
- await expect(() => executor({ contentType: [] })).rejects.toThrow(TypeError)
88
-
89
- await expect(() => executor({ size: 'plur' })).rejects.toThrow(TypeError)
90
- await expect(() => executor({ size: true })).rejects.toThrow(TypeError)
91
- await expect(() => executor({ size: {} })).rejects.toThrow(TypeError)
92
- await expect(() => executor({ size: [] })).rejects.toThrow(TypeError)
93
- await expect(() => executor({ size: -1 })).rejects.toThrow(BeeArgumentError)
94
- })
95
- }
96
-
97
- export function testCollectionUploadOptionsAssertions(executor: (input: unknown) => void): void {
98
- it('should throw exception for bad CollectionUploadOptions', async () => {
99
- await expect(() => executor({ indexDocument: true })).rejects.toThrow(TypeError)
100
- await expect(() => executor({ indexDocument: 1 })).rejects.toThrow(TypeError)
101
- await expect(() => executor({ indexDocument: {} })).rejects.toThrow(TypeError)
102
- await expect(() => executor({ indexDocument: [] })).rejects.toThrow(TypeError)
103
-
104
- await expect(() => executor({ errorDocument: true })).rejects.toThrow(TypeError)
105
- await expect(() => executor({ errorDocument: 1 })).rejects.toThrow(TypeError)
106
- await expect(() => executor({ errorDocument: {} })).rejects.toThrow(TypeError)
107
- await expect(() => executor({ errorDocument: [] })).rejects.toThrow(TypeError)
108
- })
109
- }
110
-
111
- export function testReferenceAssertions(executor: (input: unknown) => void): void {
112
- it('should throw exception for bad Reference', async () => {
113
- await expect(() => executor(1)).rejects.toThrow(TypeError)
114
- await expect(() => executor(true)).rejects.toThrow(TypeError)
115
- await expect(() => executor({})).rejects.toThrow(TypeError)
116
- await expect(() => executor(null)).rejects.toThrow(TypeError)
117
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
118
- await expect(() => executor([])).rejects.toThrow(TypeError)
119
- await expect(() => executor('')).rejects.toThrow(TypeError)
120
-
121
- // Not an valid hexstring (ZZZ)
122
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
123
- TypeError,
124
- )
125
-
126
- // Prefixed hexstring is not accepted
127
- await expect(() => executor('0x634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
128
- TypeError,
129
- )
130
-
131
- // Length mismatch
132
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
133
- TypeError,
134
- )
135
- })
136
- }
137
-
138
- export function testAddressPrefixAssertions(executor: (input: unknown) => void): void {
139
- it('should throw exception for bad AddressPrefix', async () => {
140
- await expect(() => executor(1)).rejects.toThrow(TypeError)
141
- await expect(() => executor(true)).rejects.toThrow(TypeError)
142
- await expect(() => executor({})).rejects.toThrow(TypeError)
143
- await expect(() => executor(null)).rejects.toThrow(TypeError)
144
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
145
- await expect(() => executor([])).rejects.toThrow(TypeError)
146
- await expect(() => executor('')).rejects.toThrow(TypeError)
147
-
148
- // Not an valid hexstring (ZZZ)
149
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
150
- TypeError,
151
- )
152
-
153
- // Prefixed hexstring is not accepted
154
- await expect(() => executor('0x634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
155
- TypeError,
156
- )
157
-
158
- // Too long hexstring
159
- await expect(() => executor('123634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
160
- BeeArgumentError,
161
- )
162
- })
163
- }
164
-
165
- export function testPublicKeyAssertions(executor: (input: unknown) => void): void {
166
- it('should throw exception for bad PublicKey', async () => {
167
- await expect(() => executor(1)).rejects.toThrow(TypeError)
168
- await expect(() => executor(true)).rejects.toThrow(TypeError)
169
- await expect(() => executor({})).rejects.toThrow(TypeError)
170
- await expect(() => executor([])).rejects.toThrow(TypeError)
171
-
172
- // Not an valid hexstring (ZZZ)
173
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
174
- TypeError,
175
- )
176
-
177
- // Prefixed hexstring is not accepted
178
- await expect(() => executor('0x634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
179
- TypeError,
180
- )
181
-
182
- // Length mismatch
183
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
184
- TypeError,
185
- )
186
- })
187
- }
188
-
189
- export function testPssMessageHandlerAssertions(executor: (input: unknown) => void): void {
190
- it('should throw exception for bad PssMessageHandler', async () => {
191
- await expect(() => executor(1)).rejects.toThrow(TypeError)
192
- await expect(() => executor(true)).rejects.toThrow(TypeError)
193
- await expect(() => executor({})).rejects.toThrow(TypeError)
194
- await expect(() => executor(null)).rejects.toThrow(TypeError)
195
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
196
- await expect(() => executor([])).rejects.toThrow(TypeError)
197
- await expect(() => executor('')).rejects.toThrow(TypeError)
198
-
199
- await expect(() => {
200
- return executor({ onMessage() {} })
201
- }).rejects.toThrow(TypeError)
202
-
203
- await expect(() => {
204
- return executor({ onMessage() {}, onError: '' })
205
- }).rejects.toThrow(TypeError)
206
-
207
- await expect(() => {
208
- return executor({ onMessage() {}, onError: [] })
209
- }).rejects.toThrow(TypeError)
210
-
211
- await expect(() => {
212
- return executor({ onMessage() {}, onError: {} })
213
- }).rejects.toThrow(TypeError)
214
-
215
- await expect(() => {
216
- return executor({ onMessage() {}, onError: true })
217
- }).rejects.toThrow(TypeError)
218
-
219
- await expect(() => {
220
- return executor({ onError() {}, onMessage: true })
221
- }).rejects.toThrow(TypeError)
222
-
223
- await expect(() => {
224
- return executor({ onError() {}, onMessage: {} })
225
- }).rejects.toThrow(TypeError)
226
-
227
- await expect(() => {
228
- return executor({ onError() {}, onMessage: [] })
229
- }).rejects.toThrow(TypeError)
230
-
231
- await expect(() => {
232
- return executor({ onError() {}, onMessage: '' })
233
- }).rejects.toThrow(TypeError)
234
-
235
- await expect(() => {
236
- return executor({ onError() {}, onMessage: 1 })
237
- }).rejects.toThrow(TypeError)
238
- })
239
- }
240
-
241
- export function testTopicAssertions(executor: (input: unknown) => void): void {
242
- it('should throw exception for bad Topic', async () => {
243
- await expect(() => executor(1)).rejects.toThrow(TypeError)
244
- await expect(() => executor(true)).rejects.toThrow(TypeError)
245
- await expect(() => executor({})).rejects.toThrow(TypeError)
246
- await expect(() => executor(null)).rejects.toThrow(TypeError)
247
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
248
- await expect(() => executor([])).rejects.toThrow(TypeError)
249
- })
250
- }
251
-
252
- export function testFeedTopicAssertions(executor: (input: unknown) => void): void {
253
- it('should throw exception for bad Topic', async () => {
254
- await expect(() => executor(1)).rejects.toThrow(TypeError)
255
- await expect(() => executor(true)).rejects.toThrow(TypeError)
256
- await expect(() => executor({})).rejects.toThrow(TypeError)
257
- await expect(() => executor(null)).rejects.toThrow(TypeError)
258
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
259
- await expect(() => executor([])).rejects.toThrow(TypeError)
260
-
261
- // Not an valid hexstring (ZZZ)
262
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).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 testEthAddressAssertions(executor: (input: unknown) => void): void {
274
- it('should throw exception for bad EthAddress', 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
-
282
- // Not an valid hexstring (ZZZ)
283
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
284
- TypeError,
285
- )
286
-
287
- // Length mismatch
288
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
289
- TypeError,
290
- )
291
-
292
- // Bytes length mismatch
293
- await expect(() => executor(makeBytes(19))).rejects.toThrow(TypeError)
294
- })
295
- }
296
-
297
- export function testMakeSignerAssertions(executor: (input: unknown) => void, optionals = true): void {
298
- it('should throw exception for bad Signer', async () => {
299
- await expect(() => executor(1)).rejects.toThrow(TypeError)
300
- await expect(() => executor(true)).rejects.toThrow(TypeError)
301
- await expect(() => executor({})).rejects.toThrow(TypeError)
302
- await expect(() => executor([])).rejects.toThrow(TypeError)
303
-
304
- if (optionals) {
305
- await expect(() => executor(null)).rejects.toThrow(TypeError)
306
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
307
- }
308
-
309
- // Not an valid hexstring (ZZZ)
310
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
311
- TypeError,
312
- )
313
-
314
- // Hex Length mismatch
315
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
316
- TypeError,
317
- )
318
-
319
- // Bytes Length mismatch
320
- await expect(() => executor(makeBytes(31))).rejects.toThrow(TypeError)
321
-
322
- await expect(() => executor({ address: makeBytes(19), sign: () => {} })).rejects.toThrow(TypeError)
323
- await expect(() => executor({ address: '', sign: () => {} })).rejects.toThrow(TypeError)
324
- await expect(() => executor({ address: undefined, sign: () => {} })).rejects.toThrow(TypeError)
325
- await expect(() => executor({ address: null, sign: () => {} })).rejects.toThrow(TypeError)
326
- await expect(() => executor({ address: [], sign: () => {} })).rejects.toThrow(TypeError)
327
- await expect(() => executor({ address: {}, sign: () => {} })).rejects.toThrow(TypeError)
328
- await expect(() => executor({ address: makeBytes(20), sign: null })).rejects.toThrow(TypeError)
329
- await expect(() => executor({ address: makeBytes(20), sign: undefined })).rejects.toThrow(TypeError)
330
- await expect(() => executor({ address: makeBytes(20), sign: 'asd' })).rejects.toThrow(TypeError)
331
- await expect(() => executor({ address: makeBytes(20), sign: [] })).rejects.toThrow(TypeError)
332
- await expect(() => executor({ address: makeBytes(20), sign: {} })).rejects.toThrow(TypeError)
333
- })
334
- }
335
-
336
- export function testFeedTypeAssertions(executor: (input: unknown) => void, optionals = true): void {
337
- it('should throw exception for bad FeedType', 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([])).rejects.toThrow(TypeError)
342
- await expect(() => executor('asd')).rejects.toThrow(TypeError)
343
-
344
- if (optionals) {
345
- await expect(() => executor('')).rejects.toThrow(TypeError)
346
- await expect(() => executor(null)).rejects.toThrow(TypeError)
347
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
348
- }
349
- })
350
- }
351
-
352
- export function testAddressAssertions(executor: (input: unknown) => void, optionals = true): void {
353
- it('should throw exception for bad Address', async () => {
354
- await expect(() => executor(1)).rejects.toThrow(TypeError)
355
- await expect(() => executor(true)).rejects.toThrow(TypeError)
356
- await expect(() => executor({})).rejects.toThrow(TypeError)
357
- await expect(() => executor([])).rejects.toThrow(TypeError)
358
- await expect(() => executor('asd')).rejects.toThrow(TypeError)
359
-
360
- // Not an valid hexstring (ZZZ)
361
- await expect(() => executor('ZZZfb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
362
- TypeError,
363
- )
364
-
365
- // Hex Length mismatch
366
- await expect(() => executor('4fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd')).rejects.toThrow(
367
- TypeError,
368
- )
369
-
370
- if (optionals) {
371
- await expect(() => executor('')).rejects.toThrow(TypeError)
372
- await expect(() => executor(null)).rejects.toThrow(TypeError)
373
- await expect(() => executor(undefined)).rejects.toThrow(TypeError)
374
- }
375
- })
376
- }