@libp2p/interface-compliance-tests 1.0.2 → 1.0.6

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 (71) hide show
  1. package/dist/src/connection/connection.d.ts.map +1 -1
  2. package/dist/src/connection/connection.js +0 -2
  3. package/dist/src/connection/connection.js.map +1 -1
  4. package/dist/src/crypto/index.d.ts.map +1 -1
  5. package/dist/src/crypto/index.js +7 -8
  6. package/dist/src/crypto/index.js.map +1 -1
  7. package/dist/src/crypto/utils/index.d.ts +3 -0
  8. package/dist/src/crypto/utils/index.d.ts.map +1 -0
  9. package/dist/src/crypto/utils/index.js +18 -0
  10. package/dist/src/crypto/utils/index.js.map +1 -0
  11. package/dist/src/stream-muxer/base-test.d.ts.map +1 -1
  12. package/dist/src/stream-muxer/base-test.js +26 -23
  13. package/dist/src/stream-muxer/base-test.js.map +1 -1
  14. package/dist/src/stream-muxer/close-test.d.ts.map +1 -1
  15. package/dist/src/stream-muxer/close-test.js +16 -18
  16. package/dist/src/stream-muxer/close-test.js.map +1 -1
  17. package/dist/src/stream-muxer/spawner.d.ts.map +1 -1
  18. package/dist/src/stream-muxer/spawner.js +13 -12
  19. package/dist/src/stream-muxer/spawner.js.map +1 -1
  20. package/dist/src/transport/dial-test.d.ts.map +1 -1
  21. package/dist/src/transport/dial-test.js +5 -6
  22. package/dist/src/transport/dial-test.js.map +1 -1
  23. package/dist/src/transport/listen-test.d.ts.map +1 -1
  24. package/dist/src/transport/listen-test.js +13 -9
  25. package/dist/src/transport/listen-test.js.map +1 -1
  26. package/dist/src/transport/utils/index.d.ts.map +1 -1
  27. package/dist/src/transport/utils/index.js +3 -13
  28. package/dist/src/transport/utils/index.js.map +1 -1
  29. package/package.json +80 -65
  30. package/src/connection/connection.ts +0 -2
  31. package/src/crypto/index.ts +9 -9
  32. package/src/crypto/utils/index.ts +23 -0
  33. package/src/stream-muxer/base-test.ts +28 -24
  34. package/src/stream-muxer/close-test.ts +16 -18
  35. package/src/stream-muxer/spawner.ts +14 -13
  36. package/src/transport/dial-test.ts +5 -6
  37. package/src/transport/listen-test.ts +14 -10
  38. package/src/transport/utils/index.ts +5 -17
  39. package/dist/test/connection/index.spec.d.ts +0 -2
  40. package/dist/test/connection/index.spec.d.ts.map +0 -1
  41. package/dist/test/connection/index.spec.js +0 -71
  42. package/dist/test/connection/index.spec.js.map +0 -1
  43. package/dist/test/crypto/index.spec.d.ts +0 -2
  44. package/dist/test/crypto/index.spec.d.ts.map +0 -1
  45. package/dist/test/crypto/index.spec.js +0 -11
  46. package/dist/test/crypto/index.spec.js.map +0 -1
  47. package/dist/test/crypto/mock-crypto.d.ts +0 -4
  48. package/dist/test/crypto/mock-crypto.d.ts.map +0 -1
  49. package/dist/test/crypto/mock-crypto.js +0 -93
  50. package/dist/test/crypto/mock-crypto.js.map +0 -1
  51. package/dist/test/peer-discovery/index.spec.d.ts +0 -2
  52. package/dist/test/peer-discovery/index.spec.d.ts.map +0 -1
  53. package/dist/test/peer-discovery/index.spec.js +0 -18
  54. package/dist/test/peer-discovery/index.spec.js.map +0 -1
  55. package/dist/test/peer-discovery/mock-discovery.d.ts +0 -20
  56. package/dist/test/peer-discovery/mock-discovery.d.ts.map +0 -1
  57. package/dist/test/peer-discovery/mock-discovery.js +0 -39
  58. package/dist/test/peer-discovery/mock-discovery.js.map +0 -1
  59. package/dist/test/topology/mock-peer-store.d.ts +0 -12
  60. package/dist/test/topology/mock-peer-store.d.ts.map +0 -1
  61. package/dist/test/topology/mock-peer-store.js +0 -18
  62. package/dist/test/topology/mock-peer-store.js.map +0 -1
  63. package/dist/test/topology/multicodec-topology.spec.d.ts +0 -2
  64. package/dist/test/topology/multicodec-topology.spec.d.ts.map +0 -1
  65. package/dist/test/topology/multicodec-topology.spec.js +0 -45
  66. package/dist/test/topology/multicodec-topology.spec.js.map +0 -1
  67. package/dist/test/topology/topology.spec.d.ts +0 -2
  68. package/dist/test/topology/topology.spec.d.ts.map +0 -1
  69. package/dist/test/topology/topology.spec.js +0 -21
  70. package/dist/test/topology/topology.spec.js.map +0 -1
  71. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -21,15 +21,17 @@ export default (common) => {
21
21
  sinon.restore();
22
22
  });
23
23
  it('simple', async () => {
24
- const listener = transport.createListener({}, (conn) => { });
24
+ const listener = transport.createListener();
25
25
  await listener.listen(addrs[0]);
26
26
  await listener.close();
27
27
  });
28
28
  it('close listener with connections, through timeout', async () => {
29
29
  const upgradeSpy = sinon.spy(upgrader, 'upgradeInbound');
30
30
  const listenerConns = [];
31
- const listener = transport.createListener({}, (conn) => {
32
- listenerConns.push(conn);
31
+ const listener = transport.createListener({
32
+ handler: (conn) => {
33
+ listenerConns.push(conn);
34
+ }
33
35
  });
34
36
  // Listen
35
37
  await listener.listen(addrs[0]);
@@ -58,8 +60,10 @@ export default (common) => {
58
60
  });
59
61
  it('should not handle connection if upgradeInbound throws', async () => {
60
62
  sinon.stub(upgrader, 'upgradeInbound').throws();
61
- const listener = transport.createListener(() => {
62
- throw new Error('should not handle the connection if upgradeInbound throws');
63
+ const listener = transport.createListener({
64
+ handler: () => {
65
+ throw new Error('should not handle the connection if upgradeInbound throws');
66
+ }
63
67
  });
64
68
  // Listen
65
69
  await listener.listen(addrs[0]);
@@ -71,7 +75,7 @@ export default (common) => {
71
75
  describe('events', () => {
72
76
  it('connection', async () => {
73
77
  const upgradeSpy = sinon.spy(upgrader, 'upgradeInbound');
74
- const listener = transport.createListener({});
78
+ const listener = transport.createListener();
75
79
  const deferred = defer();
76
80
  let conn;
77
81
  listener.on('connection', (c) => {
@@ -88,14 +92,14 @@ export default (common) => {
88
92
  await listener.close();
89
93
  });
90
94
  it('listening', (done) => {
91
- const listener = transport.createListener({});
95
+ const listener = transport.createListener();
92
96
  listener.on('listening', () => {
93
97
  listener.close().then(done, done);
94
98
  });
95
99
  void listener.listen(addrs[0]);
96
100
  });
97
101
  it('error', (done) => {
98
- const listener = transport.createListener({});
102
+ const listener = transport.createListener();
99
103
  listener.on('error', (err) => {
100
104
  expect(err).to.exist();
101
105
  listener.close().then(done, done);
@@ -103,7 +107,7 @@ export default (common) => {
103
107
  listener.emit('error', new Error('my err'));
104
108
  });
105
109
  it('close', (done) => {
106
- const listener = transport.createListener({});
110
+ const listener = transport.createListener();
107
111
  listener.on('close', done);
108
112
  void (async () => {
109
113
  await listener.listen(addrs[0]);
@@ -1 +1 @@
1
- {"version":3,"file":"listen-test.js","sourceRoot":"","sources":["../../../src/transport/listen-test.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,KAAK,MAAM,SAAS,CAAA;AAO3B,eAAe,CAAC,MAAmD,EAAE,EAAE;IACrE,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;QACtB,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAA;QAC/B,IAAI,KAAkB,CAAA;QACtB,IAAI,SAA8B,CAAA;QAElC,MAAM,CAAC,KAAK,IAAI,EAAE;YAChB,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;QAC3D,CAAC,CAAC,CAAA;QAEF,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;QACzB,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,GAAG,EAAE;YACb,KAAK,CAAC,OAAO,EAAE,CAAA;QACjB,CAAC,CAAC,CAAA;Q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E,CAAC,IAAI,EAAE,EAAE;gBACnB,MAAM,QAAQ,GAAG,SAAS,CAAC,cAAc,EAAE,CAAA;gBAC3C,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;oBAC3B,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;oBACtB,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;gBACnC,CAAC,CAAC,CAAA;gBACF,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;YAC7C,CAAC,CAAC,CAAA;YAEF,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBACnB,MAAM,QAAQ,GAAG,SAAS,CAAC,cAAc,EAAE,CAAA;gBAC3C,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;gBAE1B,KAAK,CAAC,KAAK,IAAI,EAAE;oBACf,MAAM,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;oBAC/B,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAA;gBACxB,CAAC,CAAC,EAAE,CAAA;YACN,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transport/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAuB,MAAM,8BAA8B,CAAA;AAOjF;;;GAGG;AACH,wBAAgB,WAAW,CAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAE,MAAa,WAY5D;AAED,wBAAgB,YAAY,aAoB3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transport/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAuB,MAAM,8BAA8B,CAAA;AAMjF;;;GAGG;AACH,wBAAgB,WAAW,CAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,GAAE,MAAa,WAY5D;AAED,wBAAgB,YAAY,aAoB3B"}
@@ -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
  /**
@@ -19,7 +18,7 @@ export function isValidTick(date, ms = 5000) {
19
18
  }
20
19
  export function mockUpgrader() {
21
20
  const ensureProps = (multiaddrConnection) => {
22
- ['sink', 'source', 'remoteAddr', 'conn', 'timeline', 'close'].forEach(prop => {
21
+ ['sink', 'source', 'remoteAddr', 'timeline', 'close'].forEach(prop => {
23
22
  expect(multiaddrConnection).to.have.property(prop);
24
23
  });
25
24
  expect(isValidTick(multiaddrConnection.timeline.open)).to.equal(true);
@@ -38,23 +37,15 @@ export function mockUpgrader() {
38
37
  return upgrader;
39
38
  }
40
39
  async function createConnection(maConn, direction) {
41
- const localAddr = maConn.localAddr;
42
40
  const remoteAddr = maConn.remoteAddr;
43
- if (localAddr == null) {
44
- throw new Error('No localAddr found on MultiaddrConnection');
45
- }
46
- const localPeerIdStr = localAddr.getPeerId();
47
41
  const remotePeerIdStr = remoteAddr.getPeerId();
48
- const localPeer = localPeerIdStr != null ? PeerId.fromString(localPeerIdStr) : await PeerIdFactory.createEd25519PeerId();
49
42
  const remotePeer = remotePeerIdStr != null ? PeerId.fromString(remotePeerIdStr) : await PeerIdFactory.createEd25519PeerId();
50
43
  const streams = [];
51
44
  let streamId = 0;
52
45
  const registry = new Map();
53
46
  return {
54
47
  id: 'mock-connection',
55
- localAddr,
56
48
  remoteAddr,
57
- localPeer,
58
49
  remotePeer,
59
50
  stat: {
60
51
  status: 'OPEN',
@@ -81,8 +72,7 @@ async function createConnection(maConn, direction) {
81
72
  reset: () => { },
82
73
  timeline: {
83
74
  open: 0
84
- },
85
- [Symbol.asyncIterator]: echo.source
75
+ }
86
76
  };
87
77
  const streamData = {
88
78
  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,CAAC,IAAI,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;QACF,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,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,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.2",
3
+ "version": "1.0.6",
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",
@@ -122,6 +89,12 @@
122
89
  "types": "./dist/src/utils/peers.d.ts"
123
90
  }
124
91
  },
92
+ "eslintConfig": {
93
+ "extends": "ipfs",
94
+ "parserOptions": {
95
+ "sourceType": "module"
96
+ }
97
+ },
125
98
  "release": {
126
99
  "branches": [
127
100
  "master"
@@ -202,5 +175,47 @@
202
175
  "@semantic-release/github",
203
176
  "@semantic-release/git"
204
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"
205
220
  }
206
221
  }
@@ -19,9 +19,7 @@ export default (test: TestSetup<Connection>) => {
19
19
 
20
20
  it('should have properties set', () => {
21
21
  expect(connection.id).to.exist()
22
- expect(connection.localPeer).to.exist()
23
22
  expect(connection.remotePeer).to.exist()
24
- expect(connection.localAddr).to.exist()
25
23
  expect(connection.remoteAddr).to.exist()
26
24
  expect(connection.stat.status).to.equal('OPEN')
27
25
  expect(connection.stat.timeline.open).to.exist()
@@ -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,23 @@
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
+ remoteAddr: new Multiaddr('/ip4/127.0.0.1/tcp/4001'),
14
+ timeline: {
15
+ open: Date.now()
16
+ }
17
+ }
18
+
19
+ return output
20
+ }
21
+
22
+ return [duplexToMaConn(local), duplexToMaConn(remote)]
23
+ }
@@ -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
  })