@libp2p/interface-compliance-tests 1.0.1 → 1.0.5

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 (67) hide show
  1. package/dist/src/crypto/index.d.ts.map +1 -1
  2. package/dist/src/crypto/index.js +7 -8
  3. package/dist/src/crypto/index.js.map +1 -1
  4. package/dist/src/crypto/utils/index.d.ts +3 -0
  5. package/dist/src/crypto/utils/index.d.ts.map +1 -0
  6. package/dist/src/crypto/utils/index.js +19 -0
  7. package/dist/src/crypto/utils/index.js.map +1 -0
  8. package/dist/src/stream-muxer/base-test.d.ts.map +1 -1
  9. package/dist/src/stream-muxer/base-test.js +26 -23
  10. package/dist/src/stream-muxer/base-test.js.map +1 -1
  11. package/dist/src/stream-muxer/close-test.d.ts.map +1 -1
  12. package/dist/src/stream-muxer/close-test.js +16 -18
  13. package/dist/src/stream-muxer/close-test.js.map +1 -1
  14. package/dist/src/stream-muxer/spawner.d.ts.map +1 -1
  15. package/dist/src/stream-muxer/spawner.js +13 -12
  16. package/dist/src/stream-muxer/spawner.js.map +1 -1
  17. package/dist/src/transport/dial-test.d.ts.map +1 -1
  18. package/dist/src/transport/dial-test.js +4 -5
  19. package/dist/src/transport/dial-test.js.map +1 -1
  20. package/dist/src/transport/listen-test.d.ts.map +1 -1
  21. package/dist/src/transport/listen-test.js +13 -9
  22. package/dist/src/transport/listen-test.js.map +1 -1
  23. package/dist/src/transport/utils/index.d.ts.map +1 -1
  24. package/dist/src/transport/utils/index.js +2 -4
  25. package/dist/src/transport/utils/index.js.map +1 -1
  26. package/package.json +161 -65
  27. package/src/crypto/index.ts +9 -9
  28. package/src/crypto/utils/index.ts +24 -0
  29. package/src/stream-muxer/base-test.ts +28 -24
  30. package/src/stream-muxer/close-test.ts +16 -18
  31. package/src/stream-muxer/spawner.ts +14 -13
  32. package/src/transport/dial-test.ts +4 -5
  33. package/src/transport/listen-test.ts +14 -10
  34. package/src/transport/utils/index.ts +4 -6
  35. package/dist/test/connection/index.spec.d.ts +0 -2
  36. package/dist/test/connection/index.spec.d.ts.map +0 -1
  37. package/dist/test/connection/index.spec.js +0 -71
  38. package/dist/test/connection/index.spec.js.map +0 -1
  39. package/dist/test/crypto/index.spec.d.ts +0 -2
  40. package/dist/test/crypto/index.spec.d.ts.map +0 -1
  41. package/dist/test/crypto/index.spec.js +0 -11
  42. package/dist/test/crypto/index.spec.js.map +0 -1
  43. package/dist/test/crypto/mock-crypto.d.ts +0 -4
  44. package/dist/test/crypto/mock-crypto.d.ts.map +0 -1
  45. package/dist/test/crypto/mock-crypto.js +0 -93
  46. package/dist/test/crypto/mock-crypto.js.map +0 -1
  47. package/dist/test/peer-discovery/index.spec.d.ts +0 -2
  48. package/dist/test/peer-discovery/index.spec.d.ts.map +0 -1
  49. package/dist/test/peer-discovery/index.spec.js +0 -18
  50. package/dist/test/peer-discovery/index.spec.js.map +0 -1
  51. package/dist/test/peer-discovery/mock-discovery.d.ts +0 -20
  52. package/dist/test/peer-discovery/mock-discovery.d.ts.map +0 -1
  53. package/dist/test/peer-discovery/mock-discovery.js +0 -39
  54. package/dist/test/peer-discovery/mock-discovery.js.map +0 -1
  55. package/dist/test/topology/mock-peer-store.d.ts +0 -12
  56. package/dist/test/topology/mock-peer-store.d.ts.map +0 -1
  57. package/dist/test/topology/mock-peer-store.js +0 -18
  58. package/dist/test/topology/mock-peer-store.js.map +0 -1
  59. package/dist/test/topology/multicodec-topology.spec.d.ts +0 -2
  60. package/dist/test/topology/multicodec-topology.spec.d.ts.map +0 -1
  61. package/dist/test/topology/multicodec-topology.spec.js +0 -45
  62. package/dist/test/topology/multicodec-topology.spec.js.map +0 -1
  63. package/dist/test/topology/topology.spec.d.ts +0 -2
  64. package/dist/test/topology/topology.spec.d.ts.map +0 -1
  65. package/dist/test/topology/topology.spec.js +0 -21
  66. package/dist/test/topology/topology.spec.js.map +0 -1
  67. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,6 +1,5 @@
1
1
  import { expect } from 'aegir/utils/chai.js';
2
- // @ts-expect-error no types
3
- import pair from 'it-pair';
2
+ import { pair } from 'it-pair';
4
3
  import { PeerId } from '@libp2p/peer-id';
5
4
  import * as PeerIdFactory from '@libp2p/peer-id-factory';
6
5
  /**
@@ -81,8 +80,7 @@ async function createConnection(maConn, direction) {
81
80
  reset: () => { },
82
81
  timeline: {
83
82
  open: 0
84
- },
85
- [Symbol.asyncIterator]: echo.source
83
+ }
86
84
  };
87
85
  const streamData = {
88
86
  protocol: protocols[0],
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transport/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAI5C,4BAA4B;AAC5B,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,aAAa,MAAM,yBAAyB,CAAA;AACxD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,IAAa,EAAE,KAAa,IAAI;IAC3D,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;KACzC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAEtB,IAAI,IAAI,GAAG,GAAG,GAAG,EAAE,IAAI,IAAI,IAAI,GAAG,EAAE;QAClC,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,WAAW,GAAG,CAAC,mBAAwC,EAAE,EAAE;QAC/D,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC3E,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,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,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACrB,CAAC;QACD,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;KACF,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,81 +1,48 @@
1
1
  {
2
2
  "name": "@libp2p/interface-compliance-tests",
3
- "version": "1.0.1",
3
+ "version": "1.0.5",
4
4
  "description": "Compliance tests for JS libp2p interfaces",
5
- "type": "module",
6
- "files": [
7
- "src",
8
- "dist"
5
+ "license": "Apache-2.0 OR MIT",
6
+ "homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interface-compliance-tests#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/libp2p/js-libp2p-interfaces.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/libp2p/js-libp2p-interfaces/issues"
13
+ },
14
+ "keywords": [
15
+ "interface",
16
+ "libp2p"
9
17
  ],
10
- "types": "dist/src/index.d.ts",
18
+ "engines": {
19
+ "node": ">=16.0.0",
20
+ "npm": ">=7.0.0"
21
+ },
22
+ "type": "module",
23
+ "types": "./dist/src/index.d.ts",
11
24
  "typesVersions": {
12
25
  "*": {
13
26
  "*": [
27
+ "*",
28
+ "dist/*",
29
+ "dist/src/*",
30
+ "dist/src/*/index"
31
+ ],
32
+ "src/*": [
33
+ "*",
34
+ "dist/*",
14
35
  "dist/src/*",
15
36
  "dist/src/*/index"
16
37
  ]
17
38
  }
18
39
  },
19
- "eslintConfig": {
20
- "extends": "ipfs"
21
- },
22
- "scripts": {
23
- "lint": "aegir lint",
24
- "dep-check": "aegir dep-check dist/src/**/*.js",
25
- "build": "tsc",
26
- "pretest": "npm run build",
27
- "test": "aegir test -f ./dist/test/**/*.js",
28
- "test:chrome": "npm run test -- -t browser",
29
- "test:chrome-webworker": "npm run test -- -t webworker",
30
- "test:firefox": "npm run test -- -t browser -- --browser firefox",
31
- "test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
32
- "test:node": "npm run test -- -t node --cov",
33
- "test:electron-main": "npm run test -- -t electron-main"
34
- },
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/libp2p/js-libp2p-interfaces.git"
38
- },
39
- "keywords": [
40
- "libp2p",
41
- "interface"
40
+ "files": [
41
+ "src",
42
+ "dist/src",
43
+ "!dist/test",
44
+ "!**/*.tsbuildinfo"
42
45
  ],
43
- "author": "",
44
- "license": "(Apache-2.0 OR MIT)",
45
- "bugs": {
46
- "url": "https://github.com/libp2p/js-libp2p-interfaces/issues"
47
- },
48
- "homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-interfaces-compliance-tests#readme",
49
- "dependencies": {
50
- "@libp2p/connection": "^1.0.0",
51
- "@libp2p/crypto": "^0.22.2",
52
- "@libp2p/interfaces": "^1.0.0",
53
- "@libp2p/peer-id": "^1.0.0",
54
- "@libp2p/peer-id-factory": "^1.0.0",
55
- "@libp2p/pubsub": "^1.0.0",
56
- "@libp2p/topology": "^1.0.0",
57
- "@multiformats/multiaddr": "^10.1.1",
58
- "abort-controller": "^3.0.0",
59
- "abortable-iterator": "^3.0.0",
60
- "aegir": "^36.1.3",
61
- "chai": "^4.3.4",
62
- "chai-checkmark": "^1.0.1",
63
- "delay": "^5.0.0",
64
- "it-goodbye": "^3.0.0",
65
- "it-pair": "^1.0.0",
66
- "it-pipe": "^1.1.0",
67
- "multiformats": "^9.4.10",
68
- "p-defer": "^4.0.0",
69
- "p-limit": "^4.0.0",
70
- "p-wait-for": "^4.1.0",
71
- "sinon": "^12.0.1",
72
- "streaming-iterables": "^6.0.0",
73
- "uint8arrays": "^3.0.0",
74
- "util": "^0.12.4"
75
- },
76
- "devDependencies": {
77
- "it-handshake": "^2.0.0"
78
- },
79
46
  "exports": {
80
47
  ".": {
81
48
  "import": "./dist/src/index.js",
@@ -121,5 +88,134 @@
121
88
  "import": "./dist/src/utils/peers.js",
122
89
  "types": "./dist/src/utils/peers.d.ts"
123
90
  }
91
+ },
92
+ "eslintConfig": {
93
+ "extends": "ipfs",
94
+ "parserOptions": {
95
+ "sourceType": "module"
96
+ }
97
+ },
98
+ "release": {
99
+ "branches": [
100
+ "master"
101
+ ],
102
+ "plugins": [
103
+ [
104
+ "@semantic-release/commit-analyzer",
105
+ {
106
+ "preset": "conventionalcommits",
107
+ "releaseRules": [
108
+ {
109
+ "breaking": true,
110
+ "release": "major"
111
+ },
112
+ {
113
+ "revert": true,
114
+ "release": "patch"
115
+ },
116
+ {
117
+ "type": "feat",
118
+ "release": "minor"
119
+ },
120
+ {
121
+ "type": "fix",
122
+ "release": "patch"
123
+ },
124
+ {
125
+ "type": "chore",
126
+ "release": "patch"
127
+ },
128
+ {
129
+ "type": "docs",
130
+ "release": "patch"
131
+ },
132
+ {
133
+ "type": "test",
134
+ "release": "patch"
135
+ },
136
+ {
137
+ "scope": "no-release",
138
+ "release": false
139
+ }
140
+ ]
141
+ }
142
+ ],
143
+ [
144
+ "@semantic-release/release-notes-generator",
145
+ {
146
+ "preset": "conventionalcommits",
147
+ "presetConfig": {
148
+ "types": [
149
+ {
150
+ "type": "feat",
151
+ "section": "Features"
152
+ },
153
+ {
154
+ "type": "fix",
155
+ "section": "Bug Fixes"
156
+ },
157
+ {
158
+ "type": "chore",
159
+ "section": "Trivial Changes"
160
+ },
161
+ {
162
+ "type": "docs",
163
+ "section": "Trivial Changes"
164
+ },
165
+ {
166
+ "type": "test",
167
+ "section": "Tests"
168
+ }
169
+ ]
170
+ }
171
+ }
172
+ ],
173
+ "@semantic-release/changelog",
174
+ "@semantic-release/npm",
175
+ "@semantic-release/github",
176
+ "@semantic-release/git"
177
+ ]
178
+ },
179
+ "scripts": {
180
+ "lint": "aegir lint",
181
+ "dep-check": "aegir dep-check dist/src/**/*.js",
182
+ "build": "tsc",
183
+ "pretest": "npm run build",
184
+ "test": "aegir test -f ./dist/test/**/*.js",
185
+ "test:chrome": "npm run test -- -t browser",
186
+ "test:chrome-webworker": "npm run test -- -t webworker",
187
+ "test:firefox": "npm run test -- -t browser -- --browser firefox",
188
+ "test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
189
+ "test:node": "npm run test -- -t node --cov",
190
+ "test:electron-main": "npm run test -- -t electron-main"
191
+ },
192
+ "dependencies": {
193
+ "@libp2p/connection": "^1.0.0",
194
+ "@libp2p/crypto": "^0.22.2",
195
+ "@libp2p/interfaces": "^1.0.0",
196
+ "@libp2p/peer-id": "^1.0.0",
197
+ "@libp2p/peer-id-factory": "^1.0.0",
198
+ "@libp2p/pubsub": "^1.0.0",
199
+ "@libp2p/topology": "^1.0.0",
200
+ "@multiformats/multiaddr": "^10.1.1",
201
+ "abortable-iterator": "^4.0.0",
202
+ "aegir": "^36.1.3",
203
+ "delay": "^5.0.0",
204
+ "it-all": "^1.0.6",
205
+ "it-drain": "^1.0.5",
206
+ "it-goodbye": "^4.0.1",
207
+ "it-map": "^1.0.6",
208
+ "it-pair": "^2.0.0",
209
+ "it-pipe": "^2.0.2",
210
+ "multiformats": "^9.4.10",
211
+ "p-defer": "^4.0.0",
212
+ "p-limit": "^4.0.0",
213
+ "p-wait-for": "^4.1.0",
214
+ "sinon": "^12.0.1",
215
+ "uint8arrays": "^3.0.0",
216
+ "util": "^0.12.4"
217
+ },
218
+ "devDependencies": {
219
+ "it-handshake": "^3.0.0"
124
220
  }
125
221
  }
@@ -1,15 +1,15 @@
1
1
  import { expect } from 'aegir/utils/chai.js'
2
- // @ts-expect-error no types
3
- import duplexPair from 'it-pair/duplex.js'
4
2
  import { pipe } from 'it-pipe'
5
3
  import * as PeerIdFactory from '@libp2p/peer-id-factory'
6
- import { collect } from 'streaming-iterables'
4
+ import all from 'it-all'
7
5
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
8
6
  import peers from '../utils/peers.js'
9
7
  import { UnexpectedPeerError } from '@libp2p/interfaces/crypto/errors'
8
+ import { createMaConnPair } from './utils/index.js'
10
9
  import type { TestSetup } from '../index.js'
11
10
  import type { Crypto } from '@libp2p/interfaces/crypto'
12
11
  import type { PeerId } from '@libp2p/interfaces/peer-id'
12
+ import type { Source } from 'it-stream-types'
13
13
 
14
14
  export default (common: TestSetup<Crypto>) => {
15
15
  describe('interface-crypto compliance tests', () => {
@@ -42,7 +42,7 @@ export default (common: TestSetup<Crypto>) => {
42
42
  })
43
43
 
44
44
  it('it wraps the provided duplex connection', async () => {
45
- const [localConn, remoteConn] = duplexPair()
45
+ const [localConn, remoteConn] = createMaConnPair()
46
46
 
47
47
  const [
48
48
  inboundResult,
@@ -53,7 +53,7 @@ export default (common: TestSetup<Crypto>) => {
53
53
  ])
54
54
 
55
55
  // Echo server
56
- pipe(inboundResult.conn, inboundResult.conn)
56
+ void pipe(inboundResult.conn, inboundResult.conn)
57
57
 
58
58
  // Send some data and collect the result
59
59
  const input = uint8ArrayFromString('data to encrypt')
@@ -61,19 +61,19 @@ export default (common: TestSetup<Crypto>) => {
61
61
  [input],
62
62
  outboundResult.conn,
63
63
  // Convert BufferList to Buffer via slice
64
- (source: AsyncIterable<Uint8Array>) => (async function * toBuffer () {
64
+ (source: Source<Uint8Array>) => (async function * toBuffer () {
65
65
  for await (const chunk of source) {
66
66
  yield chunk.slice()
67
67
  }
68
68
  })(),
69
- collect
69
+ async (source) => await all(source)
70
70
  )
71
71
 
72
72
  expect(result).to.eql([input])
73
73
  })
74
74
 
75
75
  it('should return the remote peer id', async () => {
76
- const [localConn, remoteConn] = duplexPair()
76
+ const [localConn, remoteConn] = createMaConnPair()
77
77
 
78
78
  const [
79
79
  inboundResult,
@@ -90,7 +90,7 @@ export default (common: TestSetup<Crypto>) => {
90
90
  })
91
91
 
92
92
  it('inbound connections should verify peer integrity if known', async () => {
93
- const [localConn, remoteConn] = duplexPair()
93
+ const [localConn, remoteConn] = createMaConnPair()
94
94
 
95
95
  await Promise.all([
96
96
  crypto.secureInbound(remotePeer, localConn, mitmPeer),
@@ -0,0 +1,24 @@
1
+ import { duplexPair } from 'it-pair/duplex'
2
+ import { Multiaddr } from '@multiformats/multiaddr'
3
+ import type { MultiaddrConnection } from '@libp2p/interfaces/transport'
4
+ import type { Duplex } from 'it-stream-types'
5
+
6
+ export function createMaConnPair (): [MultiaddrConnection, MultiaddrConnection] {
7
+ const [local, remote] = duplexPair<Uint8Array>()
8
+
9
+ function duplexToMaConn (duplex: Duplex<Uint8Array>): MultiaddrConnection {
10
+ const output: MultiaddrConnection = {
11
+ ...duplex,
12
+ close: async () => {},
13
+ conn: {},
14
+ remoteAddr: new Multiaddr('/ip4/127.0.0.1/tcp/4001'),
15
+ timeline: {
16
+ open: Date.now()
17
+ }
18
+ }
19
+
20
+ return output
21
+ }
22
+
23
+ return [duplexToMaConn(local), duplexToMaConn(remote)]
24
+ }
@@ -1,22 +1,26 @@
1
1
  import { expect } from 'aegir/utils/chai.js'
2
- // @ts-expect-error no types
3
- import pair from 'it-pair/duplex.js'
2
+ import { duplexPair } from 'it-pair/duplex'
4
3
  import { pipe } from 'it-pipe'
5
- import { collect, map, consume } from 'streaming-iterables'
4
+ import drain from 'it-drain'
5
+ import map from 'it-map'
6
+ import all from 'it-all'
6
7
  import defer from 'p-defer'
8
+ import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
9
+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
10
+ import { isValidTick } from '../transport/utils/index.js'
7
11
  import type { DeferredPromise } from 'p-defer'
8
12
  import type { TestSetup } from '../index.js'
9
13
  import type { Muxer, MuxerOptions, MuxedStream } from '@libp2p/interfaces/stream-muxer'
10
- import { isValidTick } from '../transport/utils/index.js'
14
+ import type { Source } from 'it-stream-types'
11
15
 
12
- function close (stream: MuxedStream) {
13
- return pipe([], stream, consume)
16
+ async function close (stream: MuxedStream) {
17
+ return await pipe([], stream, drain)
14
18
  }
15
19
 
16
20
  export default (common: TestSetup<Muxer, MuxerOptions>) => {
17
21
  describe('base', () => {
18
22
  it('Open a stream from the dialer', async () => {
19
- const p = pair()
23
+ const p = duplexPair<Uint8Array>()
20
24
  const dialer = await common.setup()
21
25
  const onStreamPromise: DeferredPromise<MuxedStream> = defer()
22
26
  const onStreamEndPromise: DeferredPromise<MuxedStream> = defer()
@@ -30,8 +34,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
30
34
  }
31
35
  })
32
36
 
33
- pipe(p[0], dialer, p[0])
34
- pipe(p[1], listener, p[1])
37
+ void pipe(p[0], dialer.newStream('/test/stream'), p[0])
38
+ void pipe(p[1], listener.newStream('/test/stream'), p[1])
35
39
 
36
40
  const conn = dialer.newStream()
37
41
  expect(dialer.streams).to.include(conn)
@@ -41,7 +45,7 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
41
45
  expect(isValidTick(stream.timeline.open)).to.equal(true)
42
46
  // Make sure the stream is being tracked
43
47
  expect(listener.streams).to.include(stream)
44
- close(stream)
48
+ void close(stream)
45
49
 
46
50
  // Make sure stream is closed properly
47
51
  const endedStream = await onStreamEndPromise.promise
@@ -62,7 +66,7 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
62
66
  })
63
67
 
64
68
  it('Open a stream from the listener', async () => {
65
- const p = pair()
69
+ const p = duplexPair<Uint8Array>()
66
70
  const onStreamPromise: DeferredPromise<MuxedStream> = defer()
67
71
  const dialer = await common.setup({
68
72
  onStream: stream => {
@@ -72,8 +76,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
72
76
 
73
77
  const listener = await common.setup()
74
78
 
75
- pipe(p[0], dialer, p[0])
76
- pipe(p[1], listener, p[1])
79
+ void pipe(p[0], dialer.newStream('/test/stream'), p[0])
80
+ void pipe(p[1], listener.newStream('/test/stream'), p[1])
77
81
 
78
82
  const conn = listener.newStream()
79
83
 
@@ -87,7 +91,7 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
87
91
  })
88
92
 
89
93
  it('Open a stream on both sides', async () => {
90
- const p = pair()
94
+ const p = duplexPair<Uint8Array>()
91
95
  const onDialerStreamPromise: DeferredPromise<MuxedStream> = defer()
92
96
  const onListenerStreamPromise: DeferredPromise<MuxedStream> = defer()
93
97
  const dialer = await common.setup({
@@ -101,8 +105,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
101
105
  }
102
106
  })
103
107
 
104
- pipe(p[0], dialer, p[0])
105
- pipe(p[1], listener, p[1])
108
+ void pipe(p[0], dialer.newStream('/test/stream'), p[0])
109
+ void pipe(p[1], listener.newStream('/test/stream'), p[1])
106
110
 
107
111
  const listenerConn = listener.newStream()
108
112
  const dialerConn = dialer.newStream()
@@ -118,8 +122,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
118
122
  })
119
123
 
120
124
  it('Open a stream on one side, write, open a stream on the other side', async () => {
121
- const toString = map((c: string) => c.slice().toString())
122
- const p = pair()
125
+ const toString = (source: Source<Uint8Array>) => map(source, (u) => uint8ArrayToString(u))
126
+ const p = duplexPair<Uint8Array>()
123
127
  const onDialerStreamPromise: DeferredPromise<MuxedStream> = defer()
124
128
  const onListenerStreamPromise: DeferredPromise<MuxedStream> = defer()
125
129
  const dialer = await common.setup({
@@ -133,22 +137,22 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
133
137
  }
134
138
  })
135
139
 
136
- pipe(p[0], dialer, p[0])
137
- pipe(p[1], listener, p[1])
140
+ void pipe(p[0], dialer.newStream('/test/stream'), p[0])
141
+ void pipe(p[1], listener.newStream('/test/stream'), p[1])
138
142
 
139
143
  const dialerConn = dialer.newStream()
140
144
  const listenerConn = listener.newStream()
141
145
 
142
- pipe(['hey'], dialerConn)
143
- pipe(['hello'], listenerConn)
146
+ void pipe([uint8ArrayFromString('hey')], dialerConn)
147
+ void pipe([uint8ArrayFromString('hello')], listenerConn)
144
148
 
145
149
  const listenerStream = await onListenerStreamPromise.promise
146
150
  const dialerStream = await onDialerStreamPromise.promise
147
151
 
148
- const listenerChunks = await pipe(listenerStream, toString, collect)
152
+ const listenerChunks = await pipe(listenerStream, toString, async (source) => await all(source))
149
153
  expect(listenerChunks).to.be.eql(['hey'])
150
154
 
151
- const dialerChunks = await pipe(dialerStream, toString, collect)
155
+ const dialerChunks = await pipe(dialerStream, toString, async (source) => await all(source))
152
156
  expect(dialerChunks).to.be.eql(['hello'])
153
157
  })
154
158
  })
@@ -1,11 +1,9 @@
1
1
  /* eslint max-nested-callbacks: ["error", 8] */
2
- // @ts-expect-error no types
3
- import pair from 'it-pair/duplex.js'
4
2
  import { pipe } from 'it-pipe'
5
- import { consume } from 'streaming-iterables'
6
- import { source, duplex } from 'abortable-iterator'
7
- import AbortController from 'abort-controller'
3
+ import { duplexPair } from 'it-pair/duplex'
4
+ import { abortableSource, abortableDuplex } from 'abortable-iterator'
8
5
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
6
+ import drain from 'it-drain'
9
7
  import type { TestSetup } from '../index.js'
10
8
  import type { Muxer, MuxerOptions } from '@libp2p/interfaces/stream-muxer'
11
9
  import type { Connection } from '@libp2p/interfaces/connection'
@@ -47,16 +45,16 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
47
45
  const mockUpgrade = async (maConn: any) => {
48
46
  const muxer = await common.setup({
49
47
  onStream: (stream) => {
50
- pipe(stream, stream)
48
+ void pipe(stream, stream)
51
49
  }
52
50
  })
53
- pipe(maConn, muxer, maConn)
51
+ pipe(maConn, muxer.newStream('/test/stream'), maConn)
54
52
  return mockConn(muxer)
55
53
  }
56
54
 
57
- const [local, remote] = pair()
55
+ const [local, remote] = duplexPair<Uint8Array>()
58
56
  const controller = new AbortController()
59
- const abortableRemote = duplex(remote, controller.signal, {
57
+ const abortableRemote = abortableDuplex(remote, controller.signal, {
60
58
  returnOnAbort: true
61
59
  })
62
60
 
@@ -69,8 +67,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
69
67
  // close the remote in a bit
70
68
  setTimeout(() => controller.abort(), 50)
71
69
 
72
- const s1Result = pipe(infiniteRandom, s1, consume)
73
- const s2Result = pipe(infiniteRandom, s2, consume)
70
+ const s1Result = pipe(infiniteRandom, s1.stream, drain)
71
+ const s2Result = pipe(infiniteRandom, s2.stream, drain)
74
72
 
75
73
  // test is complete when all muxed streams have closed
76
74
  await s1Result
@@ -78,16 +76,16 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
78
76
  })
79
77
 
80
78
  it('closing one of the muxed streams doesn\'t close others', async () => {
81
- const p = pair()
79
+ const p = duplexPair<Uint8Array>()
82
80
  const dialer = await common.setup()
83
81
 
84
82
  // Listener is echo server :)
85
83
  const listener = await common.setup({
86
- onStream: (stream) => pipe(stream, stream)
84
+ onStream: async (stream) => await pipe(stream, stream)
87
85
  })
88
86
 
89
- pipe(p[0], dialer, p[0])
90
- pipe(p[1], listener, p[1])
87
+ void pipe(p[0], dialer.newStream('/test/stream'), p[0])
88
+ void pipe(p[1], listener.newStream('/test/stream'), p[1])
91
89
 
92
90
  const stream = dialer.newStream()
93
91
  const streams = Array.from(Array(5), () => dialer.newStream())
@@ -99,8 +97,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
99
97
  controllers.push(controller)
100
98
 
101
99
  try {
102
- const abortableRand = source(infiniteRandom, controller.signal, { abortCode: 'ERR_TEST_ABORT' })
103
- await pipe(abortableRand, stream, consume)
100
+ const abortableRand = abortableSource(infiniteRandom, controller.signal, { abortCode: 'ERR_TEST_ABORT' })
101
+ await pipe(abortableRand, stream, drain)
104
102
  } catch (err: any) {
105
103
  if (err.code !== 'ERR_TEST_ABORT') throw err
106
104
  }
@@ -110,7 +108,7 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
110
108
 
111
109
  // Pause, and then send some data and close the first stream
112
110
  await pause(50)
113
- await pipe([randomBuffer()], stream, consume)
111
+ await pipe([randomBuffer()], stream, drain)
114
112
  closed = true
115
113
 
116
114
  // Abort all the other streams later
@@ -1,44 +1,45 @@
1
1
  import { expect } from 'aegir/utils/chai.js'
2
- // @ts-expect-error no types
3
- import pair from 'it-pair/duplex.js'
2
+ import { duplexPair } from 'it-pair/duplex'
4
3
  import { pipe } from 'it-pipe'
5
4
  import pLimit from 'p-limit'
6
- import { collect, consume } from 'streaming-iterables'
5
+ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
6
+ import drain from 'it-drain'
7
+ import all from 'it-all'
7
8
  import type { Muxer, MuxerOptions } from '@libp2p/interfaces/stream-muxer'
8
9
 
9
10
  export default async (createMuxer: (options?: MuxerOptions) => Promise<Muxer>, nStreams: number, nMsg: number, limit?: number) => {
10
- const [dialerSocket, listenerSocket] = pair()
11
+ const [dialerSocket, listenerSocket] = duplexPair<Uint8Array>()
11
12
 
12
- const msg = 'simple msg'
13
+ const msg = uint8ArrayFromString('simple msg')
13
14
 
14
15
  const listener = await createMuxer({
15
16
  onStream: async (stream) => {
16
17
  await pipe(
17
18
  stream,
18
- consume
19
+ drain
19
20
  )
20
21
 
21
- pipe([], stream)
22
+ void pipe([], stream)
22
23
  }
23
24
  })
24
25
 
25
26
  const dialer = await createMuxer()
26
27
 
27
- pipe(listenerSocket, listener, listenerSocket)
28
- pipe(dialerSocket, dialer, dialerSocket)
28
+ void pipe(listenerSocket, listener.newStream('/test/stream'), listenerSocket)
29
+ void pipe(dialerSocket, dialer.newStream('/test/stream'), dialerSocket)
29
30
 
30
31
  const spawnStream = async () => {
31
32
  const stream = dialer.newStream()
32
33
  expect(stream).to.exist // eslint-disable-line
33
34
 
34
35
  const res = await pipe(
35
- (function * () {
36
+ (async function * () {
36
37
  for (let i = 0; i < nMsg; i++) {
37
- yield new Promise(resolve => resolve(msg))
38
+ yield msg
38
39
  }
39
- })(),
40
+ }()),
40
41
  stream,
41
- collect
42
+ async (source) => await all(source)
42
43
  )
43
44
 
44
45
  expect(res).to.be.eql([])