@libp2p/pubsub 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 (43) hide show
  1. package/dist/src/peer-streams.d.ts +2 -6
  2. package/dist/src/peer-streams.d.ts.map +1 -1
  3. package/dist/src/peer-streams.js +4 -9
  4. package/dist/src/peer-streams.js.map +1 -1
  5. package/package.json +94 -78
  6. package/src/peer-streams.ts +6 -10
  7. package/dist/test/emit-self.spec.d.ts +0 -2
  8. package/dist/test/emit-self.spec.d.ts.map +0 -1
  9. package/dist/test/emit-self.spec.js +0 -63
  10. package/dist/test/emit-self.spec.js.map +0 -1
  11. package/dist/test/instance.spec.d.ts +0 -2
  12. package/dist/test/instance.spec.d.ts.map +0 -1
  13. package/dist/test/instance.spec.js +0 -50
  14. package/dist/test/instance.spec.js.map +0 -1
  15. package/dist/test/lifesycle.spec.d.ts +0 -2
  16. package/dist/test/lifesycle.spec.d.ts.map +0 -1
  17. package/dist/test/lifesycle.spec.js +0 -192
  18. package/dist/test/lifesycle.spec.js.map +0 -1
  19. package/dist/test/message.spec.d.ts +0 -2
  20. package/dist/test/message.spec.d.ts.map +0 -1
  21. package/dist/test/message.spec.js +0 -83
  22. package/dist/test/message.spec.js.map +0 -1
  23. package/dist/test/pubsub.spec.d.ts +0 -2
  24. package/dist/test/pubsub.spec.d.ts.map +0 -1
  25. package/dist/test/pubsub.spec.js +0 -310
  26. package/dist/test/pubsub.spec.js.map +0 -1
  27. package/dist/test/sign.spec.d.ts +0 -2
  28. package/dist/test/sign.spec.d.ts.map +0 -1
  29. package/dist/test/sign.spec.js +0 -93
  30. package/dist/test/sign.spec.js.map +0 -1
  31. package/dist/test/topic-validators.spec.d.ts +0 -2
  32. package/dist/test/topic-validators.spec.d.ts.map +0 -1
  33. package/dist/test/topic-validators.spec.js +0 -86
  34. package/dist/test/topic-validators.spec.js.map +0 -1
  35. package/dist/test/utils/index.d.ts +0 -23
  36. package/dist/test/utils/index.d.ts.map +0 -1
  37. package/dist/test/utils/index.js +0 -86
  38. package/dist/test/utils/index.js.map +0 -1
  39. package/dist/test/utils.spec.d.ts +0 -2
  40. package/dist/test/utils.spec.d.ts.map +0 -1
  41. package/dist/test/utils.spec.js +0 -53
  42. package/dist/test/utils.spec.js.map +0 -1
  43. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
- import pushable from 'it-pushable';
4
3
  import type { PeerId } from '@libp2p/interfaces/peer-id';
5
4
  import type { MuxedStream } from '@libp2p/interfaces/stream-muxer';
5
+ import type { Pushable } from 'it-pushable';
6
6
  export interface Options {
7
7
  id: PeerId;
8
8
  protocol: string;
@@ -16,7 +16,7 @@ export declare class PeerStreams extends EventEmitter {
16
16
  /**
17
17
  * Write stream - it's preferable to use the write method
18
18
  */
19
- outboundStream: pushable.Pushable<Uint8Array> | undefined;
19
+ outboundStream: Pushable<Uint8Array> | undefined;
20
20
  /**
21
21
  * Read stream
22
22
  */
@@ -36,14 +36,10 @@ export declare class PeerStreams extends EventEmitter {
36
36
  constructor(opts: Options);
37
37
  /**
38
38
  * Do we have a connection to read from?
39
- *
40
- * @type {boolean}
41
39
  */
42
40
  get isReadable(): boolean;
43
41
  /**
44
42
  * Do we have a connection to write on?
45
- *
46
- * @type {boolean}
47
43
  */
48
44
  get isWritable(): boolean;
49
45
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"peer-streams.d.ts","sourceRoot":"","sources":["../../src/peer-streams.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAErC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAIlC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA;AAMlE,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM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;IAC1B,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAChC;;OAEG;IACI,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,SAAS,CAAA;IACvD;;OAEG;IACI,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,SAAS,CAAA;IAC3D;;OAEG;IACH,OAAO,CAAC,kBAAkB,CAAyB;IACnD;;OAEG;IACH,OAAO,CAAC,iBAAiB,CAAyB;IAClD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAiB;gBAE5C,IAAI,EAAE,OAAO;IAS1B;;OAEG;IACH,IAAI,UAAU,YAEb;IAED;;OAEG;IACH,IAAI,UAAU,YAEb;IAED;;;OAGG;IACH,KAAK,CAAE,IAAI,EAAE,UAAU;IASvB;;OAEG;IACH,mBAAmB,CAAE,MAAM,EAAE,WAAW;IAmBxC;;OAEG;IACG,oBAAoB,CAAE,MAAM,EAAE,WAAW;IAsC/C;;OAEG;IACH,KAAK;CAgBN"}
@@ -1,10 +1,9 @@
1
1
  import debug from 'debug';
2
2
  import { EventEmitter } from 'events';
3
- import lp from 'it-length-prefixed';
4
- import pushable from 'it-pushable';
3
+ import * as lp from 'it-length-prefixed';
4
+ import { pushable } from 'it-pushable';
5
5
  import { pipe } from 'it-pipe';
6
- import { source as abortable } from 'abortable-iterator';
7
- import AbortController from 'abort-controller';
6
+ import { abortableSource } from 'abortable-iterator';
8
7
  const log = Object.assign(debug('libp2p-pubsub:peer-streams'), {
9
8
  error: debug('libp2p-pubsub:peer-streams:err')
10
9
  });
@@ -20,16 +19,12 @@ export class PeerStreams extends EventEmitter {
20
19
  }
21
20
  /**
22
21
  * Do we have a connection to read from?
23
- *
24
- * @type {boolean}
25
22
  */
26
23
  get isReadable() {
27
24
  return Boolean(this.inboundStream);
28
25
  }
29
26
  /**
30
27
  * Do we have a connection to write on?
31
- *
32
- * @type {boolean}
33
28
  */
34
29
  get isWritable() {
35
30
  return Boolean(this.outboundStream);
@@ -54,7 +49,7 @@ export class PeerStreams extends EventEmitter {
54
49
  // - abortable, set to only return on abort, rather than throw
55
50
  // - transformed with length-prefix transform
56
51
  this._rawInboundStream = stream;
57
- this.inboundStream = abortable(pipe(this._rawInboundStream, lp.decode()), this._inboundAbortController.signal, { returnOnAbort: true });
52
+ this.inboundStream = abortableSource(pipe(this._rawInboundStream, lp.decode()), this._inboundAbortController.signal, { returnOnAbort: true });
58
53
  this.emit('stream:inbound');
59
54
  return this.inboundStream;
60
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"peer-streams.js","sourceRoot":"","sources":["../../src/peer-streams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACnC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,eAAe,MAAM,kBAAkB,CAAA;AAI9C,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,EAAE;IAC7D,KAAK,EAAE,KAAK,CAAC,gCAAgC,CAAC;CAC/C,CAAC,CAAA;AAOF;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,YAAY;IAwB3C,YAAa,IAAa;QACxB,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAE7B,IAAI,CAAC,uBAAuB,GAAG,IAAI,eAAe,EAAE,CAAA;IACtD,CAAC;IAED;;;;OAIG;IACH,IAAI,UAAU;QACZ,OAAO,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IACpC,CAAC;IAED;;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C,CAAC,GAAU,EAAE,EAAE;YACrB,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChB,CAAC,CAAC,CAAA;QAEF,qCAAqC;QACrC,IAAI,WAAW,IAAI,IAAI,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;SAC7B;IACH,CAAC;IAED;;OAEG;IACH,KAAK;QACH,0BAA0B;QAC1B,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,EAAE;YAC/B,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAA;SAC1B;QACD,yBAAyB;QACzB,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,EAAE;YAC9B,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,CAAA;SACrC;QAED,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;QACnC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAA;QAC/B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAA;QAClC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAA;QAC9B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,86 +1,48 @@
1
1
  {
2
2
  "name": "@libp2p/pubsub",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "description": "libp2p pubsub base class",
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-pubsub#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
- "ignorePatterns": [
22
- "src/message/*.d.ts",
23
- "src/message/*.js"
24
- ]
25
- },
26
- "scripts": {
27
- "lint": "aegir lint",
28
- "dep-check": "aegir dep-check dist/src/**/*.js",
29
- "build": "tsc",
30
- "postbuild": "npm run build:copy-proto-files",
31
- "pretest": "npm run build",
32
- "test": "aegir test -f ./dist/test/**/*.js",
33
- "test:chrome": "npm run test -- -t browser",
34
- "test:chrome-webworker": "npm run test -- -t webworker",
35
- "test:firefox": "npm run test -- -t browser -- --browser firefox",
36
- "test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
37
- "test:node": "npm run test -- -t node --cov",
38
- "test:electron-main": "npm run test -- -t electron-main",
39
- "build:proto": "npm run build:proto:rpc && npm run build:proto:topic-descriptor",
40
- "build:proto:rpc": "pbjs -t static-module -w es6 -r libp2p-pubsub-rpc --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/message/rpc.js ./src/message/rpc.proto",
41
- "build:proto:topic-descriptor": "pbjs -t static-module -w es6 -r libp2p-pubsub-topic-descriptor --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/message/topic-descriptor.js ./src/message/topic-descriptor.proto",
42
- "build:proto-types": "npm run build:proto-types:rpc && npm run build:proto-types:topic-descriptor",
43
- "build:proto-types:rpc": "pbts -o src/message/rpc.d.ts src/message/rpc.js",
44
- "build:proto-types:topic-descriptor": "pbts -o src/message/topic-descriptor.d.ts src/message/topic-descriptor.js",
45
- "build:copy-proto-files": "cp src/message/*.js dist/src/message && cp src/message/*.d.ts dist/src/message"
46
- },
47
- "repository": {
48
- "type": "git",
49
- "url": "git+https://github.com/libp2p/js-libp2p-interfaces.git"
50
- },
51
- "keywords": [
52
- "libp2p",
53
- "interface"
40
+ "files": [
41
+ "src",
42
+ "dist/src",
43
+ "!dist/test",
44
+ "!**/*.tsbuildinfo"
54
45
  ],
55
- "author": "",
56
- "license": "Apache-2.0 OR MIT",
57
- "bugs": {
58
- "url": "https://github.com/libp2p/js-libp2p-interfaces/issues"
59
- },
60
- "homepage": "https://github.com/libp2p/js-libp2p-interfaces/tree/master/packages/libp2p-pubsub#readme",
61
- "dependencies": {
62
- "@libp2p/crypto": "^0.22.2",
63
- "@libp2p/interfaces": "^1.0.0",
64
- "@libp2p/peer-id": "^1.0.0",
65
- "@libp2p/peer-id-factory": "^1.0.0",
66
- "@libp2p/topology": "^1.0.0",
67
- "@multiformats/multiaddr": "^10.1.1",
68
- "debug": "^4.3.2",
69
- "err-code": "^3.0.1",
70
- "iso-random-stream": "^2.0.0",
71
- "it-length-prefixed": "^5.0.3",
72
- "it-pipe": "^1.1.0",
73
- "multiformats": "^9.4.10",
74
- "p-queue": "^7.1.0",
75
- "uint8arrays": "^3.0.0"
76
- },
77
- "devDependencies": {
78
- "@types/bl": "^5.0.2",
79
- "@types/debug": "^4.1.7",
80
- "aegir": "^36.1.3",
81
- "protobufjs": "^6.10.2",
82
- "util": "^0.12.4"
83
- },
84
46
  "exports": {
85
47
  ".": {
86
48
  "import": "./dist/src/index.js",
@@ -90,6 +52,14 @@
90
52
  "import": "./dist/src/errors.js",
91
53
  "types": "./dist/src/errors.d.ts"
92
54
  },
55
+ "./message/rpc": {
56
+ "import": "./dist/src/message/rpc.js",
57
+ "types": "./dist/src/message/rpc.d.ts"
58
+ },
59
+ "./message/topic-descriptor": {
60
+ "import": "./dist/src/message/topic-descriptor.js",
61
+ "types": "./dist/src/message/topic-descriptor.d.ts"
62
+ },
93
63
  "./peer-streams": {
94
64
  "import": "./dist/src/peer-streams.js",
95
65
  "types": "./dist/src/peer-streams.d.ts"
@@ -101,16 +71,18 @@
101
71
  "./utils": {
102
72
  "import": "./dist/src/utils.js",
103
73
  "types": "./dist/src/utils.d.ts"
104
- },
105
- "./message/rpc": {
106
- "import": "./dist/src/message/rpc.js",
107
- "types": "./dist/src/message/rpc.d.ts"
108
- },
109
- "./message/topic-descriptor": {
110
- "import": "./dist/src/message/topic-descriptor.js",
111
- "types": "./dist/src/message/topic-descriptor.d.ts"
112
74
  }
113
75
  },
76
+ "eslintConfig": {
77
+ "extends": "ipfs",
78
+ "parserOptions": {
79
+ "sourceType": "module"
80
+ },
81
+ "ignorePatterns": [
82
+ "src/message/*.d.ts",
83
+ "src/message/*.js"
84
+ ]
85
+ },
114
86
  "release": {
115
87
  "branches": [
116
88
  "master"
@@ -191,5 +163,49 @@
191
163
  "@semantic-release/github",
192
164
  "@semantic-release/git"
193
165
  ]
166
+ },
167
+ "scripts": {
168
+ "lint": "aegir lint",
169
+ "dep-check": "aegir dep-check dist/src/**/*.js",
170
+ "build": "tsc",
171
+ "postbuild": "npm run build:copy-proto-files",
172
+ "pretest": "npm run build",
173
+ "test": "aegir test -f ./dist/test/**/*.js",
174
+ "test:chrome": "npm run test -- -t browser",
175
+ "test:chrome-webworker": "npm run test -- -t webworker",
176
+ "test:firefox": "npm run test -- -t browser -- --browser firefox",
177
+ "test:firefox-webworker": "npm run test -- -t webworker -- --browser firefox",
178
+ "test:node": "npm run test -- -t node --cov",
179
+ "test:electron-main": "npm run test -- -t electron-main",
180
+ "build:proto": "npm run build:proto:rpc && npm run build:proto:topic-descriptor",
181
+ "build:proto:rpc": "pbjs -t static-module -w es6 -r libp2p-pubsub-rpc --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/message/rpc.js ./src/message/rpc.proto",
182
+ "build:proto:topic-descriptor": "pbjs -t static-module -w es6 -r libp2p-pubsub-topic-descriptor --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/message/topic-descriptor.js ./src/message/topic-descriptor.proto",
183
+ "build:proto-types": "npm run build:proto-types:rpc && npm run build:proto-types:topic-descriptor",
184
+ "build:proto-types:rpc": "pbts -o src/message/rpc.d.ts src/message/rpc.js",
185
+ "build:proto-types:topic-descriptor": "pbts -o src/message/topic-descriptor.d.ts src/message/topic-descriptor.js",
186
+ "build:copy-proto-files": "cp src/message/*.js dist/src/message && cp src/message/*.d.ts dist/src/message"
187
+ },
188
+ "dependencies": {
189
+ "@libp2p/crypto": "^0.22.2",
190
+ "@libp2p/interfaces": "^1.0.0",
191
+ "@libp2p/peer-id": "^1.0.0",
192
+ "@libp2p/peer-id-factory": "^1.0.0",
193
+ "@libp2p/topology": "^1.0.0",
194
+ "@multiformats/multiaddr": "^10.1.1",
195
+ "debug": "^4.3.2",
196
+ "err-code": "^3.0.1",
197
+ "iso-random-stream": "^2.0.0",
198
+ "it-length-prefixed": "^6.0.1",
199
+ "it-pipe": "^2.0.2",
200
+ "multiformats": "^9.4.10",
201
+ "p-queue": "^7.1.0",
202
+ "uint8arrays": "^3.0.0"
203
+ },
204
+ "devDependencies": {
205
+ "@types/bl": "^5.0.2",
206
+ "@types/debug": "^4.1.7",
207
+ "aegir": "^36.1.3",
208
+ "protobufjs": "^6.10.2",
209
+ "util": "^0.12.4"
194
210
  }
195
211
  }
@@ -1,12 +1,12 @@
1
1
  import debug from 'debug'
2
2
  import { EventEmitter } from 'events'
3
- import lp from 'it-length-prefixed'
4
- import pushable from 'it-pushable'
3
+ import * as lp from 'it-length-prefixed'
4
+ import { pushable } from 'it-pushable'
5
5
  import { pipe } from 'it-pipe'
6
- import { source as abortable } from 'abortable-iterator'
7
- import AbortController from 'abort-controller'
6
+ import { abortableSource } from 'abortable-iterator'
8
7
  import type { PeerId } from '@libp2p/interfaces/peer-id'
9
8
  import type { MuxedStream } from '@libp2p/interfaces/stream-muxer'
9
+ import type { Pushable } from 'it-pushable'
10
10
 
11
11
  const log = Object.assign(debug('libp2p-pubsub:peer-streams'), {
12
12
  error: debug('libp2p-pubsub:peer-streams:err')
@@ -26,7 +26,7 @@ export class PeerStreams extends EventEmitter {
26
26
  /**
27
27
  * Write stream - it's preferable to use the write method
28
28
  */
29
- public outboundStream: pushable.Pushable<Uint8Array> | undefined
29
+ public outboundStream: Pushable<Uint8Array> | undefined
30
30
  /**
31
31
  * Read stream
32
32
  */
@@ -55,8 +55,6 @@ export class PeerStreams extends EventEmitter {
55
55
 
56
56
  /**
57
57
  * Do we have a connection to read from?
58
- *
59
- * @type {boolean}
60
58
  */
61
59
  get isReadable () {
62
60
  return Boolean(this.inboundStream)
@@ -64,8 +62,6 @@ export class PeerStreams extends EventEmitter {
64
62
 
65
63
  /**
66
64
  * Do we have a connection to write on?
67
- *
68
- * @type {boolean}
69
65
  */
70
66
  get isWritable () {
71
67
  return Boolean(this.outboundStream)
@@ -93,7 +89,7 @@ export class PeerStreams extends EventEmitter {
93
89
  // - abortable, set to only return on abort, rather than throw
94
90
  // - transformed with length-prefix transform
95
91
  this._rawInboundStream = stream
96
- this.inboundStream = abortable(
92
+ this.inboundStream = abortableSource(
97
93
  pipe(
98
94
  this._rawInboundStream,
99
95
  lp.decode()
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=emit-self.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-self.spec.d.ts","sourceRoot":"","sources":["../../test/emit-self.spec.ts"],"names":[],"mappings":""}
@@ -1,63 +0,0 @@
1
- import { expect } from 'aegir/utils/chai.js';
2
- import { createPeerId, mockRegistrar, PubsubImplementation } from './utils/index.js';
3
- import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
4
- import delay from 'delay';
5
- const protocol = '/pubsub/1.0.0';
6
- const topic = 'foo';
7
- const data = uint8ArrayFromString('bar');
8
- const shouldNotHappen = () => expect.fail();
9
- describe('emitSelf', () => {
10
- let pubsub;
11
- describe('enabled', () => {
12
- before(async () => {
13
- const peerId = await createPeerId();
14
- pubsub = new PubsubImplementation({
15
- multicodecs: [protocol],
16
- libp2p: {
17
- peerId,
18
- registrar: mockRegistrar
19
- },
20
- emitSelf: true
21
- });
22
- });
23
- before(async () => {
24
- await pubsub.start();
25
- pubsub.subscribe(topic);
26
- });
27
- after(async () => {
28
- await pubsub.stop();
29
- });
30
- it('should emit to self on publish', async () => {
31
- const promise = new Promise((resolve) => pubsub.once(topic, resolve));
32
- await pubsub.publish(topic, data);
33
- return await promise;
34
- });
35
- });
36
- describe('disabled', () => {
37
- before(async () => {
38
- const peerId = await createPeerId();
39
- pubsub = new PubsubImplementation({
40
- multicodecs: [protocol],
41
- libp2p: {
42
- peerId,
43
- registrar: mockRegistrar
44
- },
45
- emitSelf: false
46
- });
47
- });
48
- before(async () => {
49
- await pubsub.start();
50
- pubsub.subscribe(topic);
51
- });
52
- after(async () => {
53
- await pubsub.stop();
54
- });
55
- it('should not emit to self on publish', async () => {
56
- pubsub.once(topic, () => shouldNotHappen);
57
- await pubsub.publish(topic, data);
58
- // Wait 1 second to guarantee that self is not noticed
59
- await delay(1000);
60
- });
61
- });
62
- });
63
- //# sourceMappingURL=emit-self.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emit-self.spec.js","sourceRoot":"","sources":["../../test/emit-self.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,oBAAoB,EACrB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,QAAQ,GAAG,eAAe,CAAA;AAChC,MAAM,KAAK,GAAG,KAAK,CAAA;AACnB,MAAM,IAAI,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAA;AACxC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC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AAM,EAAE;oBACN,MAAM;oBACN,SAAS,EAAE,aAAa;iBACzB;gBACD,QAAQ,EAAE,KAAK;aAChB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,IAAI,EAAE;YAChB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;YACpB,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;QAEF,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;QACrB,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;YAClD,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,CAAA;YAEzC,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;YAEjC,sDAAsD;YACtD,MAAM,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=instance.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instance.spec.d.ts","sourceRoot":"","sources":["../../test/instance.spec.ts"],"names":[],"mappings":""}
@@ -1,50 +0,0 @@
1
- import { expect } from 'aegir/utils/chai.js';
2
- import { PubsubBaseProtocol } from '../src/index.js';
3
- import { createPeerId, mockRegistrar } from './utils/index.js';
4
- class PubsubProtocol extends PubsubBaseProtocol {
5
- async _publish(message) {
6
- throw new Error('Method not implemented.');
7
- }
8
- }
9
- describe('pubsub instance', () => {
10
- let peerId;
11
- before(async () => {
12
- peerId = await createPeerId();
13
- });
14
- it('should throw if no debugName is provided', () => {
15
- expect(() => {
16
- // @ts-expect-error incorrect constructor args
17
- new PubsubProtocol(); // eslint-disable-line no-new
18
- }).to.throw();
19
- });
20
- it('should throw if no multicodec is provided', () => {
21
- expect(() => {
22
- // @ts-expect-error incorrect constructor args
23
- new PubsubProtocol({
24
- debugName: 'pubsub'
25
- });
26
- }).to.throw();
27
- });
28
- it('should throw if no libp2p is provided', () => {
29
- expect(() => {
30
- // @ts-expect-error incorrect constructor args
31
- new PubsubProtocol({
32
- debugName: 'pubsub',
33
- multicodecs: ['/pubsub/1.0.0']
34
- });
35
- }).to.throw();
36
- });
37
- it('should accept valid parameters', () => {
38
- expect(() => {
39
- new PubsubProtocol({
40
- debugName: 'pubsub',
41
- multicodecs: ['/pubsub/1.0.0'],
42
- libp2p: {
43
- peerId: peerId,
44
- registrar: mockRegistrar
45
- }
46
- });
47
- }).not.to.throw();
48
- });
49
- });
50
- //# sourceMappingURL=instance.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instance.spec.js","sourceRoot":"","sources":["../../test/instance.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EACL,YAAY,EACZ,aAAa,EACd,MAAM,kBAAkB,CAAA;AAIzB,MAAM,cAAe,SAAQ,kBAAkB;IAC7C,KAAK,CAAC,QAAQ,CAAE,OAAgB;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC5C,CAAC;CACF;AAED,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,MAAc,CAAA;IAElB,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,MAAM,GAAG,MAAM,YAAY,EAAE,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,CAAC,GAAG,EAAE;YACV,8CAA8C;YAC9C,IAAI,cAAc,EAAE,CAAA,CAAC,6BAA6B;QACpD,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,CAAC,GAAG,EAAE;YACV,8CAA8C;YAC9C,IAAI,cAAc,CAAC;gBACjB,SAAS,EAAE,QAAQ;aACpB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,GAAG,EAAE;YACV,8CAA8C;YAC9C,IAAI,cAAc,CAAC;gBACjB,SAAS,EAAE,QAAQ;gBACnB,WAAW,EAAE,CAAC,eAAe,CAAC;aAC/B,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,CAAC,GAAG,EAAE;YACV,IAAI,cAAc,CAAC;gBACjB,SAAS,EAAE,QAAQ;gBACnB,WAAW,EAAE,CAAC,eAAe,CAAC;gBAC9B,MAAM,EAAE;oBACN,MAAM,EAAE,MAAM;oBACd,SAAS,EAAE,aAAa;iBACzB;aACF,CAAC,CAAA;QACJ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;IACnB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=lifesycle.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lifesycle.spec.d.ts","sourceRoot":"","sources":["../../test/lifesycle.spec.ts"],"names":[],"mappings":""}