Skip to content

Commit 5356be5

Browse files
authored
chore: update pubsub interface to run subsystem tests (#148)
1 parent 966bd47 commit 5356be5

File tree

4 files changed

+301
-130
lines changed

4 files changed

+301
-130
lines changed

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,28 @@
4040
"homepage": "https://github.com/ChainSafe/js-libp2p-gossipsub#readme",
4141
"dependencies": {
4242
"@types/debug": "^4.1.5",
43-
"debug": "^4.1.1",
44-
"denque": "^1.4.1",
45-
"err-code": "^2.0.0",
46-
"it-pipe": "^1.0.1",
47-
"libp2p-interfaces": "^0.10.0",
48-
"peer-id": "^0.14.0",
49-
"protobufjs": "^6.10.2",
43+
"debug": "^4.3.1",
44+
"denque": "^1.5.0",
45+
"err-code": "^3.0.1",
46+
"it-pipe": "^1.1.0",
47+
"libp2p-interfaces": "^0.11.0",
48+
"peer-id": "^0.14.8",
49+
"protobufjs": "^6.11.2",
5050
"time-cache": "^0.3.0",
51-
"uint8arrays": "^2.1.4"
51+
"uint8arrays": "^2.1.5"
5252
},
5353
"devDependencies": {
5454
"@types/chai": "^4.2.3",
5555
"@types/mocha": "^8.2.2",
5656
"@typescript-eslint/eslint-plugin": "^3.0.2",
5757
"@typescript-eslint/parser": "^3.0.2",
58-
"aegir": "^33.0.0",
58+
"aegir": "^33.2.0",
5959
"benchmark": "^2.1.4",
6060
"buffer": "^6.0.3",
6161
"chai": "^4.2.0",
6262
"chai-spies": "^1.0.0",
6363
"delay": "^5.0.0",
64-
"detect-node": "^2.0.4",
64+
"detect-node": "^2.1.0",
6565
"dirty-chai": "^2.0.1",
6666
"eslint": "^7.1.0",
6767
"eslint-config-standard": "^14.1.1",
@@ -70,9 +70,9 @@
7070
"eslint-plugin-promise": "^4.2.1",
7171
"eslint-plugin-standard": "^4.0.1",
7272
"it-pair": "^1.0.0",
73-
"libp2p": "^0.31.0",
74-
"libp2p-floodsub": "^0.25.0",
75-
"libp2p-mplex": "^0.10.0",
73+
"libp2p": "^0.31.6",
74+
"libp2p-floodsub": "^0.25.1",
75+
"libp2p-mplex": "^0.10.3",
7676
"libp2p-noise": "^2.0.0",
7777
"libp2p-websockets": "^0.15.5",
7878
"lodash": "^4.17.15",
@@ -82,7 +82,7 @@
8282
"p-times": "^2.1.0",
8383
"p-wait-for": "^3.1.0",
8484
"promisify-es6": "^1.0.3",
85-
"sinon": "^10.0.1",
85+
"sinon": "^11.1.1",
8686
"typescript": "4.0.x",
8787
"util": "^0.12.3"
8888
},

test/go-gossipsub.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ describe("go-libp2p-pubsub gossipsub tests", function () {
858858

859859
// verify that the direct peers connected
860860
await delay(2000)
861-
expect(libp2ps[1].connectionManager.get(libp2ps[2].peerId)).to.be.truthy
861+
expect(libp2ps[1].connectionManager.get(libp2ps[2].peerId)).to.exist()
862862

863863
const topic = 'foobar'
864864
psubs.forEach(ps => ps.subscribe(topic))
@@ -884,7 +884,7 @@ describe("go-libp2p-pubsub gossipsub tests", function () {
884884

885885
await Promise.all(psubs.map(ps => awaitEvents(ps, 'gossipsub:heartbeat', 5)))
886886

887-
expect(libp2ps[1].connectionManager.get(libp2ps[2].peerId)).to.be.truthy
887+
expect(libp2ps[1].connectionManager.get(libp2ps[2].peerId)).to.exist()
888888

889889
sendRecv = []
890890
for (let i = 0; i < 3; i++) {
@@ -1067,7 +1067,7 @@ describe("go-libp2p-pubsub gossipsub tests", function () {
10671067
],
10681068
})
10691069

1070-
expect(rpc.control).to.be.truthy
1070+
expect(rpc.control).to.exist()
10711071
expect(rpc.control.graft.length).to.be.eql(1)
10721072
expect(rpc.control.graft[0].topicID).to.be.eql(test1)
10731073
expect(rpc.control.prune.length).to.be.eql(2)

ts/message/rpc.d.ts

Lines changed: 55 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export class RPC implements IRPC {
3030
/** RPC control. */
3131
public control?: (RPC.IControlMessage|null);
3232

33+
/** RPC _control. */
34+
public _control?: "control";
35+
3336
/**
3437
* Encodes the specified RPC message. Does not implicitly {@link RPC.verify|verify} messages.
3538
* @param m RPC message or plain object to encode
@@ -92,10 +95,16 @@ export namespace RPC {
9295
constructor(p?: RPC.ISubOpts);
9396

9497
/** SubOpts subscribe. */
95-
public subscribe: boolean;
98+
public subscribe?: (boolean|null);
9699

97100
/** SubOpts topicID. */
98-
public topicID: string;
101+
public topicID?: (string|null);
102+
103+
/** SubOpts _subscribe. */
104+
public _subscribe?: "subscribe";
105+
106+
/** SubOpts _topicID. */
107+
public _topicID?: "topicID";
99108

100109
/**
101110
* Encodes the specified SubOpts message. Does not implicitly {@link RPC.SubOpts.verify|verify} messages.
@@ -169,22 +178,37 @@ export namespace RPC {
169178
constructor(p?: RPC.IMessage);
170179

171180
/** Message from. */
172-
public from: Uint8Array;
181+
public from?: (Uint8Array|null);
173182

174183
/** Message data. */
175-
public data: Uint8Array;
184+
public data?: (Uint8Array|null);
176185

177186
/** Message seqno. */
178-
public seqno: Uint8Array;
187+
public seqno?: (Uint8Array|null);
179188

180189
/** Message topicIDs. */
181190
public topicIDs: string[];
182191

183192
/** Message signature. */
184-
public signature: Uint8Array;
193+
public signature?: (Uint8Array|null);
185194

186195
/** Message key. */
187-
public key: Uint8Array;
196+
public key?: (Uint8Array|null);
197+
198+
/** Message _from. */
199+
public _from?: "from";
200+
201+
/** Message _data. */
202+
public _data?: "data";
203+
204+
/** Message _seqno. */
205+
public _seqno?: "seqno";
206+
207+
/** Message _signature. */
208+
public _signature?: "signature";
209+
210+
/** Message _key. */
211+
public _key?: "key";
188212

189213
/**
190214
* Encodes the specified Message message. Does not implicitly {@link RPC.Message.verify|verify} messages.
@@ -323,11 +347,14 @@ export namespace RPC {
323347
constructor(p?: RPC.IControlIHave);
324348

325349
/** ControlIHave topicID. */
326-
public topicID: string;
350+
public topicID?: (string|null);
327351

328352
/** ControlIHave messageIDs. */
329353
public messageIDs: Uint8Array[];
330354

355+
/** ControlIHave _topicID. */
356+
public _topicID?: "topicID";
357+
331358
/**
332359
* Encodes the specified ControlIHave message. Does not implicitly {@link RPC.ControlIHave.verify|verify} messages.
333360
* @param m ControlIHave message or plain object to encode
@@ -444,7 +471,10 @@ export namespace RPC {
444471
constructor(p?: RPC.IControlGraft);
445472

446473
/** ControlGraft topicID. */
447-
public topicID: string;
474+
public topicID?: (string|null);
475+
476+
/** ControlGraft _topicID. */
477+
public _topicID?: "topicID";
448478

449479
/**
450480
* Encodes the specified ControlGraft message. Does not implicitly {@link RPC.ControlGraft.verify|verify} messages.
@@ -509,13 +539,19 @@ export namespace RPC {
509539
constructor(p?: RPC.IControlPrune);
510540

511541
/** ControlPrune topicID. */
512-
public topicID: string;
542+
public topicID?: (string|null);
513543

514544
/** ControlPrune peers. */
515545
public peers: RPC.IPeerInfo[];
516546

517547
/** ControlPrune backoff. */
518-
public backoff: number;
548+
public backoff?: (number|null);
549+
550+
/** ControlPrune _topicID. */
551+
public _topicID?: "topicID";
552+
553+
/** ControlPrune _backoff. */
554+
public _backoff?: "backoff";
519555

520556
/**
521557
* Encodes the specified ControlPrune message. Does not implicitly {@link RPC.ControlPrune.verify|verify} messages.
@@ -577,10 +613,16 @@ export namespace RPC {
577613
constructor(p?: RPC.IPeerInfo);
578614

579615
/** PeerInfo peerID. */
580-
public peerID: Uint8Array;
616+
public peerID?: (Uint8Array|null);
581617

582618
/** PeerInfo signedPeerRecord. */
583-
public signedPeerRecord: Uint8Array;
619+
public signedPeerRecord?: (Uint8Array|null);
620+
621+
/** PeerInfo _peerID. */
622+
public _peerID?: "peerID";
623+
624+
/** PeerInfo _signedPeerRecord. */
625+
public _signedPeerRecord?: "signedPeerRecord";
584626

585627
/**
586628
* Encodes the specified PeerInfo message. Does not implicitly {@link RPC.PeerInfo.verify|verify} messages.

0 commit comments

Comments
 (0)