From aa6dc453dd2d5cdafa58b5c75571f9ec9f69d197 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 11 Aug 2022 11:48:12 +0100 Subject: [PATCH] deps(dev): update protons to 5.1.0 (#98) --- package.json | 4 +-- test/message/rpc.ts | 83 +++++++++++---------------------------------- 2 files changed, 21 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index c65737c999..c18eaa9e3e 100644 --- a/package.json +++ b/package.json @@ -205,8 +205,8 @@ "it-pair": "^2.0.2", "p-defer": "^4.0.0", "p-wait-for": "^5.0.0", - "protons": "^5.0.0", - "protons-runtime": "^3.0.1", + "protons": "^5.1.0", + "protons-runtime": "^3.1.0", "sinon": "^14.0.0", "util": "^0.12.4" } diff --git a/test/message/rpc.ts b/test/message/rpc.ts index ebc741e04b..e9798c9ddd 100644 --- a/test/message/rpc.ts +++ b/test/message/rpc.ts @@ -214,7 +214,10 @@ export namespace RPC { writer.ldelim() } }, (reader, length) => { - const obj: any = {} + const obj: any = { + subscriptions: [], + messages: [] + } const end = length == null ? reader.len : reader.pos + length @@ -223,11 +226,9 @@ export namespace RPC { switch (tag >>> 3) { case 1: - obj.subscriptions = obj.subscriptions ?? [] obj.subscriptions.push(RPC.SubOpts.codec().decode(reader, reader.uint32())) break case 2: - obj.messages = obj.messages ?? [] obj.messages.push(RPC.Message.codec().decode(reader, reader.uint32())) break case 3: @@ -239,17 +240,6 @@ export namespace RPC { } } - obj.subscriptions = obj.subscriptions ?? [] - obj.messages = obj.messages ?? [] - - if (obj.subscriptions == null) { - throw new Error('Protocol error: value for required field "subscriptions" was not found in protobuf') - } - - if (obj.messages == null) { - throw new Error('Protocol error: value for required field "messages" was not found in protobuf') - } - return obj }) } @@ -323,7 +313,12 @@ export namespace ControlMessage { writer.ldelim() } }, (reader, length) => { - const obj: any = {} + const obj: any = { + ihave: [], + iwant: [], + graft: [], + prune: [] + } const end = length == null ? reader.len : reader.pos + length @@ -332,19 +327,15 @@ export namespace ControlMessage { switch (tag >>> 3) { case 1: - obj.ihave = obj.ihave ?? [] obj.ihave.push(ControlIHave.codec().decode(reader, reader.uint32())) break case 2: - obj.iwant = obj.iwant ?? [] obj.iwant.push(ControlIWant.codec().decode(reader, reader.uint32())) break case 3: - obj.graft = obj.graft ?? [] obj.graft.push(ControlGraft.codec().decode(reader, reader.uint32())) break case 4: - obj.prune = obj.prune ?? [] obj.prune.push(ControlPrune.codec().decode(reader, reader.uint32())) break default: @@ -353,27 +344,6 @@ export namespace ControlMessage { } } - obj.ihave = obj.ihave ?? [] - obj.iwant = obj.iwant ?? [] - obj.graft = obj.graft ?? [] - obj.prune = obj.prune ?? [] - - if (obj.ihave == null) { - throw new Error('Protocol error: value for required field "ihave" was not found in protobuf') - } - - if (obj.iwant == null) { - throw new Error('Protocol error: value for required field "iwant" was not found in protobuf') - } - - if (obj.graft == null) { - throw new Error('Protocol error: value for required field "graft" was not found in protobuf') - } - - if (obj.prune == null) { - throw new Error('Protocol error: value for required field "prune" was not found in protobuf') - } - return obj }) } @@ -423,7 +393,9 @@ export namespace ControlIHave { writer.ldelim() } }, (reader, length) => { - const obj: any = {} + const obj: any = { + messageIDs: [] + } const end = length == null ? reader.len : reader.pos + length @@ -435,7 +407,6 @@ export namespace ControlIHave { obj.topic = reader.string() break case 2: - obj.messageIDs = obj.messageIDs ?? [] obj.messageIDs.push(reader.bytes()) break default: @@ -444,12 +415,6 @@ export namespace ControlIHave { } } - obj.messageIDs = obj.messageIDs ?? [] - - if (obj.messageIDs == null) { - throw new Error('Protocol error: value for required field "messageIDs" was not found in protobuf') - } - return obj }) } @@ -493,7 +458,9 @@ export namespace ControlIWant { writer.ldelim() } }, (reader, length) => { - const obj: any = {} + const obj: any = { + messageIDs: [] + } const end = length == null ? reader.len : reader.pos + length @@ -502,7 +469,6 @@ export namespace ControlIWant { switch (tag >>> 3) { case 1: - obj.messageIDs = obj.messageIDs ?? [] obj.messageIDs.push(reader.bytes()) break default: @@ -511,12 +477,6 @@ export namespace ControlIWant { } } - obj.messageIDs = obj.messageIDs ?? [] - - if (obj.messageIDs == null) { - throw new Error('Protocol error: value for required field "messageIDs" was not found in protobuf') - } - return obj }) } @@ -628,7 +588,9 @@ export namespace ControlPrune { writer.ldelim() } }, (reader, length) => { - const obj: any = {} + const obj: any = { + peers: [] + } const end = length == null ? reader.len : reader.pos + length @@ -640,7 +602,6 @@ export namespace ControlPrune { obj.topic = reader.string() break case 2: - obj.peers = obj.peers ?? [] obj.peers.push(PeerInfo.codec().decode(reader, reader.uint32())) break case 3: @@ -652,12 +613,6 @@ export namespace ControlPrune { } } - obj.peers = obj.peers ?? [] - - if (obj.peers == null) { - throw new Error('Protocol error: value for required field "peers" was not found in protobuf') - } - return obj }) }