@libp2p/interface-compliance-tests 1.0.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/crypto/index.d.ts.map +1 -1
- package/dist/src/crypto/index.js +7 -8
- package/dist/src/crypto/index.js.map +1 -1
- package/dist/src/crypto/utils/index.d.ts +3 -0
- package/dist/src/crypto/utils/index.d.ts.map +1 -0
- package/dist/src/crypto/utils/index.js +19 -0
- package/dist/src/crypto/utils/index.js.map +1 -0
- package/dist/src/stream-muxer/base-test.d.ts.map +1 -1
- package/dist/src/stream-muxer/base-test.js +26 -23
- package/dist/src/stream-muxer/base-test.js.map +1 -1
- package/dist/src/stream-muxer/close-test.d.ts.map +1 -1
- package/dist/src/stream-muxer/close-test.js +16 -17
- package/dist/src/stream-muxer/close-test.js.map +1 -1
- package/dist/src/stream-muxer/spawner.d.ts.map +1 -1
- package/dist/src/stream-muxer/spawner.js +13 -12
- package/dist/src/stream-muxer/spawner.js.map +1 -1
- package/dist/src/transport/dial-test.js +4 -4
- package/dist/src/transport/dial-test.js.map +1 -1
- package/dist/src/transport/listen-test.d.ts.map +1 -1
- package/dist/src/transport/listen-test.js +13 -9
- package/dist/src/transport/listen-test.js.map +1 -1
- package/dist/src/transport/utils/index.d.ts.map +1 -1
- package/dist/src/transport/utils/index.js +2 -4
- package/dist/src/transport/utils/index.js.map +1 -1
- package/package.json +162 -65
- package/src/crypto/index.ts +9 -9
- package/src/crypto/utils/index.ts +24 -0
- package/src/stream-muxer/base-test.ts +36 -31
- package/src/stream-muxer/close-test.ts +16 -17
- package/src/stream-muxer/spawner.ts +14 -13
- package/src/transport/dial-test.ts +4 -4
- package/src/transport/listen-test.ts +14 -10
- package/src/transport/utils/index.ts +4 -6
- package/dist/test/connection/index.spec.d.ts +0 -2
- package/dist/test/connection/index.spec.d.ts.map +0 -1
- package/dist/test/connection/index.spec.js +0 -71
- package/dist/test/connection/index.spec.js.map +0 -1
- package/dist/test/crypto/index.spec.d.ts +0 -2
- package/dist/test/crypto/index.spec.d.ts.map +0 -1
- package/dist/test/crypto/index.spec.js +0 -11
- package/dist/test/crypto/index.spec.js.map +0 -1
- package/dist/test/crypto/mock-crypto.d.ts +0 -4
- package/dist/test/crypto/mock-crypto.d.ts.map +0 -1
- package/dist/test/crypto/mock-crypto.js +0 -93
- package/dist/test/crypto/mock-crypto.js.map +0 -1
- package/dist/test/peer-discovery/index.spec.d.ts +0 -2
- package/dist/test/peer-discovery/index.spec.d.ts.map +0 -1
- package/dist/test/peer-discovery/index.spec.js +0 -18
- package/dist/test/peer-discovery/index.spec.js.map +0 -1
- package/dist/test/peer-discovery/mock-discovery.d.ts +0 -20
- package/dist/test/peer-discovery/mock-discovery.d.ts.map +0 -1
- package/dist/test/peer-discovery/mock-discovery.js +0 -39
- package/dist/test/peer-discovery/mock-discovery.js.map +0 -1
- package/dist/test/topology/mock-peer-store.d.ts +0 -12
- package/dist/test/topology/mock-peer-store.d.ts.map +0 -1
- package/dist/test/topology/mock-peer-store.js +0 -18
- package/dist/test/topology/mock-peer-store.js.map +0 -1
- package/dist/test/topology/multicodec-topology.spec.d.ts +0 -2
- package/dist/test/topology/multicodec-topology.spec.d.ts.map +0 -1
- package/dist/test/topology/multicodec-topology.spec.js +0 -45
- package/dist/test/topology/multicodec-topology.spec.js.map +0 -1
- package/dist/test/topology/topology.spec.d.ts +0 -2
- package/dist/test/topology/topology.spec.d.ts.map +0 -1
- package/dist/test/topology/topology.spec.js +0 -21
- package/dist/test/topology/topology.spec.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/transport/utils/index.ts"],"names":[],"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EAAE;QACR,OAAO;QACP,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC7B,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC1B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;aAChD;YAED,MAAM,IAAI,GAAG,IAAI,EAAc,CAAA;YAE/B,MAAM,EAAE,GAAG,GAAG,QAAQ,EAAE,EAAE,CAAA;YAC1B,MAAM,MAAM,GAAgB;gBAC1B,EAAE;gBACF,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;gBACf,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;gBACf,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;gBACf,QAAQ,EAAE;oBACR,IAAI,EAAE,CAAC;iBACR;aACF,CAAA;YAED,MAAM,UAAU,GAAG;gBACjB,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;gBACtB,MAAM;aACP,CAAA;YAED,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;YAE5B,OAAO,UAAU,CAAA;QACnB,CAAC;QACD,SAAS,EAAE,CAAC,WAAwB,EAAE,UAAsB,EAAE,EAAE;QAEhE,CAAC;QACD,YAAY,EAAE,CAAC,EAAU,EAAE,EAAE;YAC3B,QAAQ,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.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Compliance tests for JS libp2p interfaces",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
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
|
-
"
|
|
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
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
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": "^0.2.0",
|
|
51
|
-
"@libp2p/crypto": "^0.22.2",
|
|
52
|
-
"@libp2p/interfaces": "^0.2.0",
|
|
53
|
-
"@libp2p/peer-id": "^0.2.0",
|
|
54
|
-
"@libp2p/peer-id-factory": "^0.2.0",
|
|
55
|
-
"@libp2p/pubsub": "^0.2.0",
|
|
56
|
-
"@libp2p/topology": "^0.2.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": "^3.0.0",
|
|
69
|
-
"p-limit": "^3.1.0",
|
|
70
|
-
"p-wait-for": "^4.1.0",
|
|
71
|
-
"sinon": "^11.1.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,135 @@
|
|
|
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
|
+
"abort-controller": "^3.0.0",
|
|
202
|
+
"abortable-iterator": "^4.0.0",
|
|
203
|
+
"aegir": "^36.1.3",
|
|
204
|
+
"delay": "^5.0.0",
|
|
205
|
+
"it-all": "^1.0.6",
|
|
206
|
+
"it-drain": "^1.0.5",
|
|
207
|
+
"it-goodbye": "^4.0.1",
|
|
208
|
+
"it-map": "^1.0.6",
|
|
209
|
+
"it-pair": "^2.0.0",
|
|
210
|
+
"it-pipe": "^2.0.2",
|
|
211
|
+
"multiformats": "^9.4.10",
|
|
212
|
+
"p-defer": "^4.0.0",
|
|
213
|
+
"p-limit": "^4.0.0",
|
|
214
|
+
"p-wait-for": "^4.1.0",
|
|
215
|
+
"sinon": "^12.0.1",
|
|
216
|
+
"uint8arrays": "^3.0.0",
|
|
217
|
+
"util": "^0.12.4"
|
|
218
|
+
},
|
|
219
|
+
"devDependencies": {
|
|
220
|
+
"it-handshake": "^3.0.0"
|
|
124
221
|
}
|
|
125
222
|
}
|
package/src/crypto/index.ts
CHANGED
|
@@ -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
|
|
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] =
|
|
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:
|
|
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
|
-
|
|
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] =
|
|
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] =
|
|
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,24 +1,29 @@
|
|
|
1
1
|
import { expect } from 'aegir/utils/chai.js'
|
|
2
|
-
|
|
3
|
-
import pair from 'it-pair/duplex.js'
|
|
2
|
+
import { duplexPair } from 'it-pair/duplex'
|
|
4
3
|
import { pipe } from 'it-pipe'
|
|
5
|
-
import
|
|
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'
|
|
11
|
+
import type { DeferredPromise } from 'p-defer'
|
|
7
12
|
import type { TestSetup } from '../index.js'
|
|
8
13
|
import type { Muxer, MuxerOptions, MuxedStream } from '@libp2p/interfaces/stream-muxer'
|
|
9
|
-
import {
|
|
14
|
+
import type { Source } from 'it-stream-types'
|
|
10
15
|
|
|
11
|
-
function close (stream: MuxedStream) {
|
|
12
|
-
return pipe([], stream,
|
|
16
|
+
async function close (stream: MuxedStream) {
|
|
17
|
+
return await pipe([], stream, drain)
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
16
21
|
describe('base', () => {
|
|
17
22
|
it('Open a stream from the dialer', async () => {
|
|
18
|
-
const p =
|
|
23
|
+
const p = duplexPair<Uint8Array>()
|
|
19
24
|
const dialer = await common.setup()
|
|
20
|
-
const onStreamPromise:
|
|
21
|
-
const onStreamEndPromise:
|
|
25
|
+
const onStreamPromise: DeferredPromise<MuxedStream> = defer()
|
|
26
|
+
const onStreamEndPromise: DeferredPromise<MuxedStream> = defer()
|
|
22
27
|
|
|
23
28
|
const listener = await common.setup({
|
|
24
29
|
onStream: stream => {
|
|
@@ -29,8 +34,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
29
34
|
}
|
|
30
35
|
})
|
|
31
36
|
|
|
32
|
-
pipe(p[0], dialer, p[0])
|
|
33
|
-
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])
|
|
34
39
|
|
|
35
40
|
const conn = dialer.newStream()
|
|
36
41
|
expect(dialer.streams).to.include(conn)
|
|
@@ -40,7 +45,7 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
40
45
|
expect(isValidTick(stream.timeline.open)).to.equal(true)
|
|
41
46
|
// Make sure the stream is being tracked
|
|
42
47
|
expect(listener.streams).to.include(stream)
|
|
43
|
-
close(stream)
|
|
48
|
+
void close(stream)
|
|
44
49
|
|
|
45
50
|
// Make sure stream is closed properly
|
|
46
51
|
const endedStream = await onStreamEndPromise.promise
|
|
@@ -61,8 +66,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
61
66
|
})
|
|
62
67
|
|
|
63
68
|
it('Open a stream from the listener', async () => {
|
|
64
|
-
const p =
|
|
65
|
-
const onStreamPromise:
|
|
69
|
+
const p = duplexPair<Uint8Array>()
|
|
70
|
+
const onStreamPromise: DeferredPromise<MuxedStream> = defer()
|
|
66
71
|
const dialer = await common.setup({
|
|
67
72
|
onStream: stream => {
|
|
68
73
|
onStreamPromise.resolve(stream)
|
|
@@ -71,8 +76,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
71
76
|
|
|
72
77
|
const listener = await common.setup()
|
|
73
78
|
|
|
74
|
-
pipe(p[0], dialer, p[0])
|
|
75
|
-
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])
|
|
76
81
|
|
|
77
82
|
const conn = listener.newStream()
|
|
78
83
|
|
|
@@ -86,9 +91,9 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
86
91
|
})
|
|
87
92
|
|
|
88
93
|
it('Open a stream on both sides', async () => {
|
|
89
|
-
const p =
|
|
90
|
-
const onDialerStreamPromise:
|
|
91
|
-
const onListenerStreamPromise:
|
|
94
|
+
const p = duplexPair<Uint8Array>()
|
|
95
|
+
const onDialerStreamPromise: DeferredPromise<MuxedStream> = defer()
|
|
96
|
+
const onListenerStreamPromise: DeferredPromise<MuxedStream> = defer()
|
|
92
97
|
const dialer = await common.setup({
|
|
93
98
|
onStream: stream => {
|
|
94
99
|
onDialerStreamPromise.resolve(stream)
|
|
@@ -100,8 +105,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
100
105
|
}
|
|
101
106
|
})
|
|
102
107
|
|
|
103
|
-
pipe(p[0], dialer, p[0])
|
|
104
|
-
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])
|
|
105
110
|
|
|
106
111
|
const listenerConn = listener.newStream()
|
|
107
112
|
const dialerConn = dialer.newStream()
|
|
@@ -117,10 +122,10 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
117
122
|
})
|
|
118
123
|
|
|
119
124
|
it('Open a stream on one side, write, open a stream on the other side', async () => {
|
|
120
|
-
const toString =
|
|
121
|
-
const p =
|
|
122
|
-
const onDialerStreamPromise:
|
|
123
|
-
const onListenerStreamPromise:
|
|
125
|
+
const toString = (source: Source<Uint8Array>) => map(source, (u) => uint8ArrayToString(u))
|
|
126
|
+
const p = duplexPair<Uint8Array>()
|
|
127
|
+
const onDialerStreamPromise: DeferredPromise<MuxedStream> = defer()
|
|
128
|
+
const onListenerStreamPromise: DeferredPromise<MuxedStream> = defer()
|
|
124
129
|
const dialer = await common.setup({
|
|
125
130
|
onStream: stream => {
|
|
126
131
|
onDialerStreamPromise.resolve(stream)
|
|
@@ -132,22 +137,22 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
132
137
|
}
|
|
133
138
|
})
|
|
134
139
|
|
|
135
|
-
pipe(p[0], dialer, p[0])
|
|
136
|
-
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])
|
|
137
142
|
|
|
138
143
|
const dialerConn = dialer.newStream()
|
|
139
144
|
const listenerConn = listener.newStream()
|
|
140
145
|
|
|
141
|
-
pipe(['hey'], dialerConn)
|
|
142
|
-
pipe(['hello'], listenerConn)
|
|
146
|
+
void pipe([uint8ArrayFromString('hey')], dialerConn)
|
|
147
|
+
void pipe([uint8ArrayFromString('hello')], listenerConn)
|
|
143
148
|
|
|
144
149
|
const listenerStream = await onListenerStreamPromise.promise
|
|
145
150
|
const dialerStream = await onDialerStreamPromise.promise
|
|
146
151
|
|
|
147
|
-
const listenerChunks = await pipe(listenerStream, toString,
|
|
152
|
+
const listenerChunks = await pipe(listenerStream, toString, async (source) => await all(source))
|
|
148
153
|
expect(listenerChunks).to.be.eql(['hey'])
|
|
149
154
|
|
|
150
|
-
const dialerChunks = await pipe(dialerStream, toString,
|
|
155
|
+
const dialerChunks = await pipe(dialerStream, toString, async (source) => await all(source))
|
|
151
156
|
expect(dialerChunks).to.be.eql(['hello'])
|
|
152
157
|
})
|
|
153
158
|
})
|
|
@@ -1,11 +1,10 @@
|
|
|
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 {
|
|
6
|
-
import {
|
|
3
|
+
import { duplexPair } from 'it-pair/duplex'
|
|
4
|
+
import { abortableSource, abortableDuplex } from 'abortable-iterator'
|
|
7
5
|
import AbortController from 'abort-controller'
|
|
8
6
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
7
|
+
import drain from 'it-drain'
|
|
9
8
|
import type { TestSetup } from '../index.js'
|
|
10
9
|
import type { Muxer, MuxerOptions } from '@libp2p/interfaces/stream-muxer'
|
|
11
10
|
import type { Connection } from '@libp2p/interfaces/connection'
|
|
@@ -47,16 +46,16 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
47
46
|
const mockUpgrade = async (maConn: any) => {
|
|
48
47
|
const muxer = await common.setup({
|
|
49
48
|
onStream: (stream) => {
|
|
50
|
-
pipe(stream, stream)
|
|
49
|
+
void pipe(stream, stream)
|
|
51
50
|
}
|
|
52
51
|
})
|
|
53
|
-
pipe(maConn, muxer, maConn)
|
|
52
|
+
pipe(maConn, muxer.newStream('/test/stream'), maConn)
|
|
54
53
|
return mockConn(muxer)
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
const [local, remote] =
|
|
56
|
+
const [local, remote] = duplexPair<Uint8Array>()
|
|
58
57
|
const controller = new AbortController()
|
|
59
|
-
const abortableRemote =
|
|
58
|
+
const abortableRemote = abortableDuplex(remote, controller.signal, {
|
|
60
59
|
returnOnAbort: true
|
|
61
60
|
})
|
|
62
61
|
|
|
@@ -69,8 +68,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
69
68
|
// close the remote in a bit
|
|
70
69
|
setTimeout(() => controller.abort(), 50)
|
|
71
70
|
|
|
72
|
-
const s1Result = pipe(infiniteRandom, s1,
|
|
73
|
-
const s2Result = pipe(infiniteRandom, s2,
|
|
71
|
+
const s1Result = pipe(infiniteRandom, s1.stream, drain)
|
|
72
|
+
const s2Result = pipe(infiniteRandom, s2.stream, drain)
|
|
74
73
|
|
|
75
74
|
// test is complete when all muxed streams have closed
|
|
76
75
|
await s1Result
|
|
@@ -78,16 +77,16 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
78
77
|
})
|
|
79
78
|
|
|
80
79
|
it('closing one of the muxed streams doesn\'t close others', async () => {
|
|
81
|
-
const p =
|
|
80
|
+
const p = duplexPair<Uint8Array>()
|
|
82
81
|
const dialer = await common.setup()
|
|
83
82
|
|
|
84
83
|
// Listener is echo server :)
|
|
85
84
|
const listener = await common.setup({
|
|
86
|
-
onStream: (stream) => pipe(stream, stream)
|
|
85
|
+
onStream: async (stream) => await pipe(stream, stream)
|
|
87
86
|
})
|
|
88
87
|
|
|
89
|
-
pipe(p[0], dialer, p[0])
|
|
90
|
-
pipe(p[1], listener, p[1])
|
|
88
|
+
void pipe(p[0], dialer.newStream('/test/stream'), p[0])
|
|
89
|
+
void pipe(p[1], listener.newStream('/test/stream'), p[1])
|
|
91
90
|
|
|
92
91
|
const stream = dialer.newStream()
|
|
93
92
|
const streams = Array.from(Array(5), () => dialer.newStream())
|
|
@@ -99,8 +98,8 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
99
98
|
controllers.push(controller)
|
|
100
99
|
|
|
101
100
|
try {
|
|
102
|
-
const abortableRand =
|
|
103
|
-
await pipe(abortableRand, stream,
|
|
101
|
+
const abortableRand = abortableSource(infiniteRandom, controller.signal, { abortCode: 'ERR_TEST_ABORT' })
|
|
102
|
+
await pipe(abortableRand, stream, drain)
|
|
104
103
|
} catch (err: any) {
|
|
105
104
|
if (err.code !== 'ERR_TEST_ABORT') throw err
|
|
106
105
|
}
|
|
@@ -110,7 +109,7 @@ export default (common: TestSetup<Muxer, MuxerOptions>) => {
|
|
|
110
109
|
|
|
111
110
|
// Pause, and then send some data and close the first stream
|
|
112
111
|
await pause(50)
|
|
113
|
-
await pipe([randomBuffer()], stream,
|
|
112
|
+
await pipe([randomBuffer()], stream, drain)
|
|
114
113
|
closed = true
|
|
115
114
|
|
|
116
115
|
// Abort all the other streams later
|
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
import { expect } from 'aegir/utils/chai.js'
|
|
2
|
-
|
|
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 {
|
|
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] =
|
|
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
|
-
|
|
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
|
|
38
|
+
yield msg
|
|
38
39
|
}
|
|
39
|
-
}
|
|
40
|
+
}()),
|
|
40
41
|
stream,
|
|
41
|
-
|
|
42
|
+
async (source) => await all(source)
|
|
42
43
|
)
|
|
43
44
|
|
|
44
45
|
expect(res).to.be.eql([])
|