@libp2p/interface-compliance-tests 6.1.8 → 6.1.9
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/matchers.d.ts +6 -0
- package/dist/src/matchers.d.ts.map +1 -1
- package/dist/src/matchers.js +6 -0
- package/dist/src/matchers.js.map +1 -1
- package/dist/src/mocks/index.d.ts +0 -2
- package/dist/src/mocks/index.d.ts.map +1 -1
- package/dist/src/mocks/index.js +0 -2
- package/dist/src/mocks/index.js.map +1 -1
- package/dist/src/mocks/muxer.d.ts +8 -3
- package/dist/src/mocks/muxer.d.ts.map +1 -1
- package/dist/src/mocks/muxer.js +15 -6
- package/dist/src/mocks/muxer.js.map +1 -1
- package/dist/src/mocks/upgrader.d.ts.map +1 -1
- package/dist/src/mocks/upgrader.js +0 -1
- package/dist/src/mocks/upgrader.js.map +1 -1
- package/dist/src/transport/index.d.ts +23 -10
- package/dist/src/transport/index.d.ts.map +1 -1
- package/dist/src/transport/index.js +418 -6
- package/dist/src/transport/index.js.map +1 -1
- package/dist/src/transport/utils.d.ts +17 -0
- package/dist/src/transport/utils.d.ts.map +1 -0
- package/dist/src/transport/utils.js +63 -0
- package/dist/src/transport/utils.js.map +1 -0
- package/dist/typedoc-urls.json +1 -6
- package/package.json +11 -10
- package/src/matchers.ts +6 -0
- package/src/mocks/index.ts +0 -2
- package/src/mocks/muxer.ts +24 -10
- package/src/mocks/upgrader.ts +1 -3
- package/src/transport/index.ts +570 -16
- package/src/transport/utils.ts +76 -0
- package/dist/src/connection/index.d.ts +0 -5
- package/dist/src/connection/index.d.ts.map +0 -1
- package/dist/src/connection/index.js +0 -135
- package/dist/src/connection/index.js.map +0 -1
- package/dist/src/mocks/connection-gater.d.ts +0 -3
- package/dist/src/mocks/connection-gater.d.ts.map +0 -1
- package/dist/src/mocks/connection-gater.js +0 -17
- package/dist/src/mocks/connection-gater.js.map +0 -1
- package/dist/src/mocks/metrics.d.ts +0 -3
- package/dist/src/mocks/metrics.d.ts.map +0 -1
- package/dist/src/mocks/metrics.js +0 -286
- package/dist/src/mocks/metrics.js.map +0 -1
- package/dist/src/mocks/peer-discovery.d.ts +0 -21
- package/dist/src/mocks/peer-discovery.d.ts.map +0 -1
- package/dist/src/mocks/peer-discovery.js +0 -47
- package/dist/src/mocks/peer-discovery.js.map +0 -1
- package/dist/src/transport/dial-test.d.ts +0 -5
- package/dist/src/transport/dial-test.d.ts.map +0 -1
- package/dist/src/transport/dial-test.js +0 -99
- package/dist/src/transport/dial-test.js.map +0 -1
- package/dist/src/transport/filter-test.d.ts +0 -5
- package/dist/src/transport/filter-test.d.ts.map +0 -1
- package/dist/src/transport/filter-test.js +0 -24
- package/dist/src/transport/filter-test.js.map +0 -1
- package/dist/src/transport/listen-test.d.ts +0 -5
- package/dist/src/transport/listen-test.d.ts.map +0 -1
- package/dist/src/transport/listen-test.js +0 -154
- package/dist/src/transport/listen-test.js.map +0 -1
- package/src/connection/index.ts +0 -166
- package/src/mocks/connection-gater.ts +0 -18
- package/src/mocks/metrics.ts +0 -385
- package/src/mocks/peer-discovery.ts +0 -59
- package/src/transport/dial-test.ts +0 -125
- package/src/transport/filter-test.ts +0 -32
- package/src/transport/listen-test.ts +0 -192
|
@@ -1,11 +1,423 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { stop } from '@libp2p/interface';
|
|
2
|
+
import { expect } from 'aegir/chai';
|
|
3
|
+
import delay from 'delay';
|
|
4
|
+
import drain from 'it-drain';
|
|
5
|
+
import { pushable } from 'it-pushable';
|
|
6
|
+
import pDefer from 'p-defer';
|
|
7
|
+
import { pEvent } from 'p-event';
|
|
8
|
+
import pRetry from 'p-retry';
|
|
9
|
+
import pWaitFor from 'p-wait-for';
|
|
10
|
+
import { raceSignal } from 'race-signal';
|
|
11
|
+
import { isValidTick } from '../is-valid-tick.js';
|
|
12
|
+
import { createPeer, getTransportManager, getUpgrader, slowNetwork } from './utils.js';
|
|
13
|
+
async function getSetup(common) {
|
|
14
|
+
const setup = await common.setup();
|
|
15
|
+
const dialer = await createPeer(setup.dialer);
|
|
16
|
+
let listener;
|
|
17
|
+
if (setup.listener != null) {
|
|
18
|
+
listener = await createPeer(setup.listener);
|
|
19
|
+
}
|
|
20
|
+
const dialAddrs = listener?.getMultiaddrs() ?? setup.dialAddrs;
|
|
21
|
+
if (dialAddrs == null) {
|
|
22
|
+
throw new Error('Listener config or dial addresses must be specified');
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
dialer,
|
|
26
|
+
listener,
|
|
27
|
+
dialAddrs: dialAddrs.filter(ma => setup.dialMultiaddrMatcher.exactMatch(ma)),
|
|
28
|
+
dialMultiaddrMatcher: setup.dialMultiaddrMatcher,
|
|
29
|
+
listenMultiaddrMatcher: setup.listenMultiaddrMatcher
|
|
30
|
+
};
|
|
31
|
+
}
|
|
4
32
|
export default (common) => {
|
|
5
33
|
describe('interface-transport', () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
34
|
+
let dialer;
|
|
35
|
+
let listener;
|
|
36
|
+
let dialAddrs;
|
|
37
|
+
let dialMultiaddrMatcher;
|
|
38
|
+
afterEach(async () => {
|
|
39
|
+
await stop(dialer, listener);
|
|
40
|
+
await common.teardown();
|
|
41
|
+
});
|
|
42
|
+
it('simple', async () => {
|
|
43
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
44
|
+
const input = Uint8Array.from([0, 1, 2, 3, 4]);
|
|
45
|
+
const output = await dialer.services.echo.echo(dialAddrs[0], input, {
|
|
46
|
+
signal: AbortSignal.timeout(5000)
|
|
47
|
+
});
|
|
48
|
+
expect(output).to.equalBytes(input);
|
|
49
|
+
});
|
|
50
|
+
it('should listen on multiple addresses', async () => {
|
|
51
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
52
|
+
const input = Uint8Array.from([0, 1, 2, 3, 4]);
|
|
53
|
+
await expect(dialer.services.echo.echo(dialAddrs[0], input, {
|
|
54
|
+
signal: AbortSignal.timeout(5000)
|
|
55
|
+
})).to.eventually.deep.equal(input);
|
|
56
|
+
await expect(dialer.services.echo.echo(dialAddrs[1], input, {
|
|
57
|
+
signal: AbortSignal.timeout(5000)
|
|
58
|
+
})).to.eventually.deep.equal(input);
|
|
59
|
+
});
|
|
60
|
+
it('can close connections', async () => {
|
|
61
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
62
|
+
const conn = await dialer.dial(dialAddrs[0], {
|
|
63
|
+
signal: AbortSignal.timeout(5000)
|
|
64
|
+
});
|
|
65
|
+
await conn.close();
|
|
66
|
+
expect(isValidTick(conn.timeline.close)).to.equal(true);
|
|
67
|
+
});
|
|
68
|
+
it('abort before dialing throws AbortError', async () => {
|
|
69
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
70
|
+
const controller = new AbortController();
|
|
71
|
+
controller.abort();
|
|
72
|
+
await expect(dialer.dial(dialAddrs[0], {
|
|
73
|
+
signal: controller.signal
|
|
74
|
+
})).to.eventually.be.rejected()
|
|
75
|
+
.with.property('name', 'AbortError');
|
|
76
|
+
});
|
|
77
|
+
it('abort while dialing throws AbortError', async () => {
|
|
78
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
79
|
+
slowNetwork(dialer, 100);
|
|
80
|
+
const controller = new AbortController();
|
|
81
|
+
setTimeout(() => { controller.abort(); }, 50);
|
|
82
|
+
await expect(dialer.dial(dialAddrs[0], {
|
|
83
|
+
signal: controller.signal
|
|
84
|
+
})).to.eventually.be.rejected()
|
|
85
|
+
.with.property('name', 'AbortError');
|
|
86
|
+
});
|
|
87
|
+
it('should close all streams when the connection closes', async () => {
|
|
88
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
89
|
+
let incomingConnectionPromise;
|
|
90
|
+
if (listener != null) {
|
|
91
|
+
incomingConnectionPromise = pDefer();
|
|
92
|
+
listener.addEventListener('connection:open', (event) => {
|
|
93
|
+
const conn = event.detail;
|
|
94
|
+
if (conn.remotePeer.equals(dialer.peerId)) {
|
|
95
|
+
incomingConnectionPromise?.resolve(conn);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const connection = await dialer.dial(dialAddrs[0]);
|
|
100
|
+
let remoteConn;
|
|
101
|
+
if (incomingConnectionPromise != null) {
|
|
102
|
+
remoteConn = await incomingConnectionPromise.promise;
|
|
103
|
+
}
|
|
104
|
+
for (let i = 0; i < 5; i++) {
|
|
105
|
+
await connection.newStream('/echo/1.0.0', {
|
|
106
|
+
maxOutboundStreams: 5
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const streams = connection.streams;
|
|
110
|
+
// Close the connection and verify all streams have been closed
|
|
111
|
+
await connection.close();
|
|
112
|
+
await pWaitFor(() => connection.streams.length === 0, {
|
|
113
|
+
timeout: 5000
|
|
114
|
+
});
|
|
115
|
+
if (remoteConn != null) {
|
|
116
|
+
await pWaitFor(() => remoteConn.streams.length === 0, {
|
|
117
|
+
timeout: 5000
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
expect(streams.find(stream => stream.status === 'open')).to.be.undefined();
|
|
121
|
+
});
|
|
122
|
+
it('should not handle connection if upgradeInbound rejects', async function () {
|
|
123
|
+
({ dialer, listener, dialAddrs, dialMultiaddrMatcher } = await getSetup(common));
|
|
124
|
+
if (listener == null) {
|
|
125
|
+
return this.skip();
|
|
126
|
+
}
|
|
127
|
+
const upgrader = getUpgrader(listener);
|
|
128
|
+
upgrader.upgradeInbound = async () => {
|
|
129
|
+
await delay(100);
|
|
130
|
+
throw new Error('Oh noes!');
|
|
131
|
+
};
|
|
132
|
+
await expect(dialer.dial(dialAddrs[0])).to.eventually.be.rejected
|
|
133
|
+
.with.property('name', 'EncryptionFailedError');
|
|
134
|
+
expect(dialer.getConnections().filter(conn => {
|
|
135
|
+
return dialMultiaddrMatcher.exactMatch(conn.remoteAddr);
|
|
136
|
+
})).to.have.lengthOf(0);
|
|
137
|
+
if (listener != null) {
|
|
138
|
+
const remoteConnections = listener.getConnections(dialer.peerId)
|
|
139
|
+
.filter(conn => dialMultiaddrMatcher.exactMatch(conn.remoteAddr));
|
|
140
|
+
expect(remoteConnections).to.have.lengthOf(0);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
it('should omit peerid in listening addresses', async function () {
|
|
144
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
145
|
+
if (listener == null) {
|
|
146
|
+
return this.skip();
|
|
147
|
+
}
|
|
148
|
+
const tm = getTransportManager(listener);
|
|
149
|
+
const transportListeners = tm.getListeners();
|
|
150
|
+
for (const transportListener of transportListeners) {
|
|
151
|
+
for (const ma of transportListener.getAddrs()) {
|
|
152
|
+
expect(ma.toString()).to.not.include(`/p2p/${listener.peerId}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
it('should handle one big write', async function () {
|
|
157
|
+
const timeout = 120_000;
|
|
158
|
+
this.timeout(timeout);
|
|
159
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
160
|
+
const input = new Uint8Array(1024 * 1024 * 10).fill(5);
|
|
161
|
+
const output = await dialer.services.echo.echo(dialAddrs[0], input, {
|
|
162
|
+
signal: AbortSignal.timeout(timeout)
|
|
163
|
+
});
|
|
164
|
+
expect(output).to.equalBytes(input);
|
|
165
|
+
});
|
|
166
|
+
it('should handle many small writes', async function () {
|
|
167
|
+
const timeout = 120_000;
|
|
168
|
+
this.timeout(timeout);
|
|
169
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
170
|
+
for (let i = 0; i < 2000; i++) {
|
|
171
|
+
const input = new Uint8Array(1024).fill(5);
|
|
172
|
+
const output = await dialer.services.echo.echo(dialAddrs[0], input, {
|
|
173
|
+
signal: AbortSignal.timeout(timeout)
|
|
174
|
+
});
|
|
175
|
+
expect(output).to.equalBytes(input);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
it('can close a stream for reading but send a large amount of data', async function () {
|
|
179
|
+
const timeout = 120_000;
|
|
180
|
+
this.timeout(timeout);
|
|
181
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
182
|
+
if (listener == null) {
|
|
183
|
+
return this.skip();
|
|
184
|
+
}
|
|
185
|
+
const protocol = '/send-data/1.0.0';
|
|
186
|
+
const chunkSize = 1024;
|
|
187
|
+
const bytes = chunkSize * 1024 * 10;
|
|
188
|
+
const deferred = pDefer();
|
|
189
|
+
await listener.handle(protocol, ({ stream }) => {
|
|
190
|
+
Promise.resolve().then(async () => {
|
|
191
|
+
let read = 0;
|
|
192
|
+
for await (const buf of stream.source) {
|
|
193
|
+
read += buf.byteLength;
|
|
194
|
+
if (read === bytes) {
|
|
195
|
+
deferred.resolve();
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
.catch(err => {
|
|
201
|
+
deferred.reject(err);
|
|
202
|
+
stream.abort(err);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
const stream = await dialer.dialProtocol(dialAddrs[0], protocol);
|
|
206
|
+
await stream.closeRead();
|
|
207
|
+
await stream.sink((async function* () {
|
|
208
|
+
for (let i = 0; i < bytes; i += chunkSize) {
|
|
209
|
+
yield new Uint8Array(chunkSize);
|
|
210
|
+
}
|
|
211
|
+
})());
|
|
212
|
+
await stream.close();
|
|
213
|
+
await deferred.promise;
|
|
214
|
+
});
|
|
215
|
+
it('can close a stream for writing but receive a large amount of data', async function () {
|
|
216
|
+
const timeout = 120_000;
|
|
217
|
+
this.timeout(timeout);
|
|
218
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
219
|
+
if (listener == null) {
|
|
220
|
+
return this.skip();
|
|
221
|
+
}
|
|
222
|
+
const protocol = '/receive-data/1.0.0';
|
|
223
|
+
const chunkSize = 1024;
|
|
224
|
+
const bytes = chunkSize * 1024 * 10;
|
|
225
|
+
const deferred = pDefer();
|
|
226
|
+
await listener.handle(protocol, ({ stream }) => {
|
|
227
|
+
Promise.resolve().then(async () => {
|
|
228
|
+
await stream.sink((async function* () {
|
|
229
|
+
for (let i = 0; i < bytes; i += chunkSize) {
|
|
230
|
+
yield new Uint8Array(chunkSize);
|
|
231
|
+
}
|
|
232
|
+
})());
|
|
233
|
+
await stream.close();
|
|
234
|
+
})
|
|
235
|
+
.catch(err => {
|
|
236
|
+
deferred.reject(err);
|
|
237
|
+
stream.abort(err);
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
const stream = await dialer.dialProtocol(dialAddrs[0], protocol);
|
|
241
|
+
await stream.closeWrite();
|
|
242
|
+
let read = 0;
|
|
243
|
+
for await (const buf of stream.source) {
|
|
244
|
+
read += buf.byteLength;
|
|
245
|
+
}
|
|
246
|
+
expect(read).to.equal(bytes);
|
|
247
|
+
});
|
|
248
|
+
it('can close local stream for writing and reading while a remote stream is writing', async function () {
|
|
249
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
250
|
+
if (listener == null) {
|
|
251
|
+
return this.skip();
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* NodeA NodeB
|
|
255
|
+
* | <--- STOP_SENDING |
|
|
256
|
+
* | FIN ---> |
|
|
257
|
+
* | <--- FIN |
|
|
258
|
+
* | FIN_ACK ---> |
|
|
259
|
+
* | <--- FIN_ACK |
|
|
260
|
+
*/
|
|
261
|
+
const getRemoteStream = pDefer();
|
|
262
|
+
const protocol = '/close-local-while-remote-writes/1.0.0';
|
|
263
|
+
const streamHandler = ({ stream }) => {
|
|
264
|
+
void Promise.resolve().then(async () => {
|
|
265
|
+
getRemoteStream.resolve(stream);
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
await listener.handle(protocol, (info) => {
|
|
269
|
+
streamHandler(info);
|
|
270
|
+
}, {
|
|
271
|
+
runOnLimitedConnection: true
|
|
272
|
+
});
|
|
273
|
+
const connection = await dialer.dial(dialAddrs[0]);
|
|
274
|
+
// open a stream on the echo protocol
|
|
275
|
+
const stream = await connection.newStream(protocol, {
|
|
276
|
+
runOnLimitedConnection: true
|
|
277
|
+
});
|
|
278
|
+
// close the write end immediately
|
|
279
|
+
const p = stream.closeWrite();
|
|
280
|
+
const remoteStream = await getRemoteStream.promise;
|
|
281
|
+
// close the readable end of the remote stream
|
|
282
|
+
await remoteStream.closeRead();
|
|
283
|
+
// keep the remote write end open, this should delay the FIN_ACK reply to the local stream
|
|
284
|
+
const remoteInputStream = pushable();
|
|
285
|
+
void remoteStream.sink(remoteInputStream);
|
|
286
|
+
// wait for remote to receive local close-write
|
|
287
|
+
await pRetry(() => {
|
|
288
|
+
if (remoteStream.readStatus !== 'closed') {
|
|
289
|
+
throw new Error('Remote stream read status ' + remoteStream.readStatus);
|
|
290
|
+
}
|
|
291
|
+
}, {
|
|
292
|
+
minTimeout: 100
|
|
293
|
+
});
|
|
294
|
+
// remote closes write
|
|
295
|
+
remoteInputStream.end();
|
|
296
|
+
// wait to receive FIN_ACK
|
|
297
|
+
await p;
|
|
298
|
+
// wait for remote to notice closure
|
|
299
|
+
await pRetry(() => {
|
|
300
|
+
if (remoteStream.status !== 'closed') {
|
|
301
|
+
throw new Error('Remote stream not closed');
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
assertStreamClosed(stream);
|
|
305
|
+
assertStreamClosed(remoteStream);
|
|
306
|
+
});
|
|
307
|
+
it('can close local stream for writing and reading while a remote stream is writing using source/sink', async function () {
|
|
308
|
+
({ dialer, listener, dialAddrs } = await getSetup(common));
|
|
309
|
+
if (listener == null) {
|
|
310
|
+
return this.skip();
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* NodeA NodeB
|
|
314
|
+
* | FIN ---> |
|
|
315
|
+
* | <--- FIN |
|
|
316
|
+
* | FIN_ACK ---> |
|
|
317
|
+
* | <--- FIN_ACK |
|
|
318
|
+
*/
|
|
319
|
+
const getRemoteStream = pDefer();
|
|
320
|
+
const protocol = '/close-local-while-remote-reads/1.0.0';
|
|
321
|
+
const streamHandler = ({ stream }) => {
|
|
322
|
+
void Promise.resolve().then(async () => {
|
|
323
|
+
getRemoteStream.resolve(stream);
|
|
324
|
+
});
|
|
325
|
+
};
|
|
326
|
+
await listener.handle(protocol, (info) => {
|
|
327
|
+
streamHandler(info);
|
|
328
|
+
}, {
|
|
329
|
+
runOnLimitedConnection: true
|
|
330
|
+
});
|
|
331
|
+
const connection = await dialer.dial(dialAddrs[0]);
|
|
332
|
+
// open a stream on the echo protocol
|
|
333
|
+
const stream = await connection.newStream(protocol, {
|
|
334
|
+
runOnLimitedConnection: true
|
|
335
|
+
});
|
|
336
|
+
// keep the remote write end open, this should delay the FIN_ACK reply to the local stream
|
|
337
|
+
const p = stream.sink([]);
|
|
338
|
+
const remoteStream = await getRemoteStream.promise;
|
|
339
|
+
// close the readable end of the remote stream
|
|
340
|
+
await remoteStream.closeRead();
|
|
341
|
+
// readable end should finish
|
|
342
|
+
await drain(remoteStream.source);
|
|
343
|
+
// wait for remote to receive local close-write
|
|
344
|
+
await pRetry(() => {
|
|
345
|
+
if (remoteStream.readStatus !== 'closed') {
|
|
346
|
+
throw new Error('Remote stream read status ' + remoteStream.readStatus);
|
|
347
|
+
}
|
|
348
|
+
}, {
|
|
349
|
+
minTimeout: 100
|
|
350
|
+
});
|
|
351
|
+
// remote closes write
|
|
352
|
+
await remoteStream.sink([]);
|
|
353
|
+
// wait to receive FIN_ACK
|
|
354
|
+
await p;
|
|
355
|
+
// close read end of stream
|
|
356
|
+
await stream.closeRead();
|
|
357
|
+
// readable end should finish
|
|
358
|
+
await drain(stream.source);
|
|
359
|
+
// wait for remote to notice closure
|
|
360
|
+
await pRetry(() => {
|
|
361
|
+
if (remoteStream.status !== 'closed') {
|
|
362
|
+
throw new Error('Remote stream not closed');
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
assertStreamClosed(stream);
|
|
366
|
+
assertStreamClosed(remoteStream);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
describe('events', () => {
|
|
370
|
+
let dialer;
|
|
371
|
+
let listener;
|
|
372
|
+
let listenMultiaddrMatcher;
|
|
373
|
+
afterEach(async () => {
|
|
374
|
+
await stop(dialer, listener);
|
|
375
|
+
await common.teardown();
|
|
376
|
+
});
|
|
377
|
+
it('emits listening', async function () {
|
|
378
|
+
({ dialer, listener, listenMultiaddrMatcher } = await getSetup(common));
|
|
379
|
+
if (listener == null) {
|
|
380
|
+
return this.skip();
|
|
381
|
+
}
|
|
382
|
+
await listener.stop();
|
|
383
|
+
const transportListeningPromise = pDefer();
|
|
384
|
+
listener.addEventListener('transport:listening', (event) => {
|
|
385
|
+
const transportListener = event.detail;
|
|
386
|
+
if (transportListener.getAddrs().some(ma => listenMultiaddrMatcher.exactMatch(ma))) {
|
|
387
|
+
transportListeningPromise.resolve();
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
await listener.start();
|
|
391
|
+
await raceSignal(transportListeningPromise.promise, AbortSignal.timeout(1000), {
|
|
392
|
+
errorMessage: 'Did not emit listening event'
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
it('emits close', async function () {
|
|
396
|
+
({ dialer, listener } = await getSetup(common));
|
|
397
|
+
if (listener == null) {
|
|
398
|
+
return this.skip();
|
|
399
|
+
}
|
|
400
|
+
const transportManager = getTransportManager(listener);
|
|
401
|
+
const transportListener = transportManager.getListeners()
|
|
402
|
+
.filter(listener => listener.getAddrs().some(ma => listenMultiaddrMatcher.exactMatch(ma)))
|
|
403
|
+
.pop();
|
|
404
|
+
if (transportListener == null) {
|
|
405
|
+
throw new Error('Could not find address listener');
|
|
406
|
+
}
|
|
407
|
+
const p = pEvent(transportListener, 'close');
|
|
408
|
+
await listener.stop();
|
|
409
|
+
await raceSignal(p, AbortSignal.timeout(1000), {
|
|
410
|
+
errorMessage: 'Did not emit close event'
|
|
411
|
+
});
|
|
412
|
+
});
|
|
9
413
|
});
|
|
10
414
|
};
|
|
415
|
+
function assertStreamClosed(stream) {
|
|
416
|
+
expect(stream.status).to.equal('closed');
|
|
417
|
+
expect(stream.readStatus).to.equal('closed');
|
|
418
|
+
expect(stream.writeStatus).to.equal('closed');
|
|
419
|
+
expect(stream.timeline.close).to.be.a('number');
|
|
420
|
+
expect(stream.timeline.closeRead).to.be.a('number');
|
|
421
|
+
expect(stream.timeline.closeWrite).to.be.a('number');
|
|
422
|
+
}
|
|
11
423
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,gBAAgB,CAAA;AACjC,OAAO,MAAM,MAAM,kBAAkB,CAAA;AACrC,OAAO,MAAM,MAAM,kBAAkB,CAAA;AAkBrC,eAAe,CAAC,MAAwC,EAAQ,EAAE;IAChE,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,IAAI,CAAC,MAAM,CAAC,CAAA;QACZ,MAAM,CAAC,MAAM,CAAC,CAAA;QACd,MAAM,CAAC,MAAM,CAAC,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,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C,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAAS,kBAAkB,CAAE,MAAc;IACzC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACxC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAC5C,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAE7C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC/C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IACnD,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Echo } from '@libp2p/echo';
|
|
2
|
+
import type { Libp2p, Upgrader } from '@libp2p/interface';
|
|
3
|
+
import type { TransportManager } from '@libp2p/interface-internal';
|
|
4
|
+
import type { Libp2pOptions } from 'libp2p';
|
|
5
|
+
export declare function createPeer(config?: Partial<Libp2pOptions>): Promise<Libp2p<{
|
|
6
|
+
echo: Echo;
|
|
7
|
+
}>>;
|
|
8
|
+
/**
|
|
9
|
+
* Monkey patch the upgrader in the passed libp2p to add latency to any
|
|
10
|
+
* multiaddr connections upgraded to connections - this is to work with
|
|
11
|
+
* transports that have their own muxers/encrypters and do not support
|
|
12
|
+
* connection protection
|
|
13
|
+
*/
|
|
14
|
+
export declare function slowNetwork(libp2p: any, latency: number): void;
|
|
15
|
+
export declare function getUpgrader(libp2p: any): Upgrader;
|
|
16
|
+
export declare function getTransportManager(libp2p: any): TransportManager;
|
|
17
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/transport/utils.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAE3C,wBAAsB,UAAU,CAAE,MAAM,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC,CAAC,CAsBtG;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAuB/D;AAED,wBAAgB,WAAW,CAAE,MAAM,EAAE,GAAG,GAAG,QAAQ,CAElD;AAED,wBAAgB,mBAAmB,CAAE,MAAM,EAAE,GAAG,GAAG,gBAAgB,CAElE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { echo } from '@libp2p/echo';
|
|
3
|
+
import { memory } from '@libp2p/memory';
|
|
4
|
+
import { plaintext } from '@libp2p/plaintext';
|
|
5
|
+
import delay from 'delay';
|
|
6
|
+
import map from 'it-map';
|
|
7
|
+
import { createLibp2p } from 'libp2p';
|
|
8
|
+
import { mockMuxer } from '../mocks/muxer.js';
|
|
9
|
+
export async function createPeer(config = {}) {
|
|
10
|
+
return createLibp2p({
|
|
11
|
+
transports: [
|
|
12
|
+
memory()
|
|
13
|
+
],
|
|
14
|
+
connectionEncrypters: [
|
|
15
|
+
plaintext()
|
|
16
|
+
],
|
|
17
|
+
streamMuxers: [
|
|
18
|
+
() => mockMuxer()
|
|
19
|
+
],
|
|
20
|
+
connectionGater: {
|
|
21
|
+
denyDialMultiaddr: () => false
|
|
22
|
+
},
|
|
23
|
+
...config,
|
|
24
|
+
services: {
|
|
25
|
+
...config.services,
|
|
26
|
+
echo: echo({
|
|
27
|
+
maxInboundStreams: 5
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Monkey patch the upgrader in the passed libp2p to add latency to any
|
|
34
|
+
* multiaddr connections upgraded to connections - this is to work with
|
|
35
|
+
* transports that have their own muxers/encrypters and do not support
|
|
36
|
+
* connection protection
|
|
37
|
+
*/
|
|
38
|
+
export function slowNetwork(libp2p, latency) {
|
|
39
|
+
const upgrader = getUpgrader(libp2p);
|
|
40
|
+
const originalUpgradeInbound = upgrader.upgradeInbound.bind(upgrader);
|
|
41
|
+
const originalUpgradeOutbound = upgrader.upgradeOutbound.bind(upgrader);
|
|
42
|
+
upgrader.upgradeInbound = async (maConn, opts) => {
|
|
43
|
+
maConn.source = map(maConn.source, async (buf) => {
|
|
44
|
+
await delay(latency);
|
|
45
|
+
return buf;
|
|
46
|
+
});
|
|
47
|
+
return originalUpgradeInbound(maConn, opts);
|
|
48
|
+
};
|
|
49
|
+
upgrader.upgradeOutbound = async (maConn, opts) => {
|
|
50
|
+
maConn.source = map(maConn.source, async (buf) => {
|
|
51
|
+
await delay(latency);
|
|
52
|
+
return buf;
|
|
53
|
+
});
|
|
54
|
+
return originalUpgradeOutbound(maConn, opts);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export function getUpgrader(libp2p) {
|
|
58
|
+
return libp2p.components.upgrader;
|
|
59
|
+
}
|
|
60
|
+
export function getTransportManager(libp2p) {
|
|
61
|
+
return libp2p.components.transportManager;
|
|
62
|
+
}
|
|
63
|
+
//# s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,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QAC/C,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAC/C,MAAM,KAAK,CAAC,OAAO,CAAC,CAAA;YACpB,OAAO,GAAG,CAAA;QACZ,CAAC,CAAC,CAAA;QAEF,OAAO,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC7C,CAAC,CAAA;IAED,QAAQ,CAAC,eAAe,GAAG,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;QAChD,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YAC/C,MAAM,KAAK,CAAC,OAAO,CAAC,CAAA;YACpB,OAAO,GAAG,CAAA;QACZ,CAAC,CAAC,CAAA;QAEF,OAAO,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC9C,CAAC,CAAA;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAE,MAAW;IACtC,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAE,MAAW;IAC9C,OAAO,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAA;AAC3C,CAAC"}
|
package/dist/typedoc-urls.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"default": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.connection.default.html",
|
|
3
|
-
"./connection:default": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.connection.default.html",
|
|
4
2
|
"ConnectionEncrypterSetupArgs": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.connection_encryption.ConnectionEncrypterSetupArgs.html",
|
|
5
3
|
"./connection-encryption:ConnectionEncrypterSetupArgs": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.connection_encryption.ConnectionEncrypterSetupArgs.html",
|
|
4
|
+
"default": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.connection_encryption.default.html",
|
|
6
5
|
"./connection-encryption:default": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.connection_encryption.default.html",
|
|
7
6
|
"TestSetup": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.index.TestSetup.html",
|
|
8
7
|
".:TestSetup": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.index.TestSetup.html",
|
|
@@ -23,10 +22,8 @@
|
|
|
23
22
|
"mockNetwork": "https://libp2p.github.io/js-libp2p/variables/_libp2p_interface_compliance_tests.mocks.mockNetwork-1.html",
|
|
24
23
|
"connectionPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.connectionPair.html",
|
|
25
24
|
"mockConnection": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.mockConnection.html",
|
|
26
|
-
"mockConnectionGater": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.mockConnectionGater.html",
|
|
27
25
|
"mockConnectionManager": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.mockConnectionManager.html",
|
|
28
26
|
"mockDuplex": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.mockDuplex.html",
|
|
29
|
-
"mockMetrics": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.mockMetrics.html",
|
|
30
27
|
"mockMultiaddrConnPair": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.mockMultiaddrConnPair.html",
|
|
31
28
|
"mockMultiaddrConnection": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.mockMultiaddrConnection.html",
|
|
32
29
|
"mockMuxer": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.mocks.mockMuxer.html",
|
|
@@ -41,8 +38,6 @@
|
|
|
41
38
|
"./pubsub:PubSubComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.pubsub.PubSubComponents.html",
|
|
42
39
|
"./pubsub:default": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.pubsub.default.html",
|
|
43
40
|
"./stream-muxer:default": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.stream_muxer.default.html",
|
|
44
|
-
"Connector": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.transport.Connector.html",
|
|
45
|
-
"./transport:Connector": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.transport.Connector.html",
|
|
46
41
|
"TransportTestFixtures": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.transport.TransportTestFixtures.html",
|
|
47
42
|
"./transport:TransportTestFixtures": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_compliance_tests.transport.TransportTestFixtures.html",
|
|
48
43
|
"./transport:default": "https://libp2p.github.io/js-libp2p/functions/_libp2p_interface_compliance_tests.transport.default.html"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/interface-compliance-tests",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.9",
|
|
4
4
|
"description": "Compliance tests for JS libp2p interfaces",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface-compliance-tests#readme",
|
|
@@ -48,10 +48,6 @@
|
|
|
48
48
|
"types": "./dist/src/index.d.ts",
|
|
49
49
|
"import": "./dist/src/index.js"
|
|
50
50
|
},
|
|
51
|
-
"./connection": {
|
|
52
|
-
"types": "./dist/src/connection/index.d.ts",
|
|
53
|
-
"import": "./dist/src/connection/index.js"
|
|
54
|
-
},
|
|
55
51
|
"./connection-encryption": {
|
|
56
52
|
"types": "./dist/src/connection-encryption/index.d.ts",
|
|
57
53
|
"import": "./dist/src/connection-encryption/index.js"
|
|
@@ -109,14 +105,18 @@
|
|
|
109
105
|
},
|
|
110
106
|
"dependencies": {
|
|
111
107
|
"@libp2p/crypto": "^5.0.6",
|
|
108
|
+
"@libp2p/echo": "^2.1.2",
|
|
112
109
|
"@libp2p/interface": "^2.2.0",
|
|
113
|
-
"@libp2p/interface-internal": "^2.0
|
|
110
|
+
"@libp2p/interface-internal": "^2.1.0",
|
|
114
111
|
"@libp2p/logger": "^5.1.3",
|
|
112
|
+
"@libp2p/memory": "^1.0.0",
|
|
115
113
|
"@libp2p/multistream-select": "^6.0.8",
|
|
116
|
-
"@libp2p/peer-collections": "^6.0.
|
|
114
|
+
"@libp2p/peer-collections": "^6.0.11",
|
|
117
115
|
"@libp2p/peer-id": "^5.0.7",
|
|
118
|
-
"@libp2p/
|
|
116
|
+
"@libp2p/plaintext": "^2.0.10",
|
|
117
|
+
"@libp2p/utils": "^6.2.0",
|
|
119
118
|
"@multiformats/multiaddr": "^12.2.3",
|
|
119
|
+
"@multiformats/multiaddr-matcher": "^1.5.0",
|
|
120
120
|
"abortable-iterator": "^5.0.1",
|
|
121
121
|
"aegir": "^44.0.1",
|
|
122
122
|
"delay": "^6.0.0",
|
|
@@ -131,19 +131,20 @@
|
|
|
131
131
|
"it-pushable": "^3.2.3",
|
|
132
132
|
"it-stream-types": "^2.0.1",
|
|
133
133
|
"it-to-buffer": "^4.0.7",
|
|
134
|
+
"libp2p": "^2.3.0",
|
|
134
135
|
"merge-options": "^3.0.4",
|
|
135
136
|
"p-defer": "^4.0.1",
|
|
136
137
|
"p-event": "^6.0.1",
|
|
137
138
|
"p-limit": "^6.0.0",
|
|
139
|
+
"p-retry": "^6.2.0",
|
|
138
140
|
"p-wait-for": "^5.0.2",
|
|
139
141
|
"protons-runtime": "^5.4.0",
|
|
142
|
+
"race-signal": "^1.1.0",
|
|
140
143
|
"sinon": "^18.0.0",
|
|
141
|
-
"tdigest": "^0.1.2",
|
|
142
144
|
"uint8arraylist": "^2.4.8",
|
|
143
145
|
"uint8arrays": "^5.1.0"
|
|
144
146
|
},
|
|
145
147
|
"devDependencies": {
|
|
146
|
-
"@types/tdigest": "^0.1.4",
|
|
147
148
|
"protons": "^7.5.0"
|
|
148
149
|
}
|
|
149
150
|
}
|