hypercore-protocol
Advanced tools
Comparing version 6.11.1 to 6.12.0
@@ -1,2 +0,2 @@ | ||
// This file is auto generated by the protocol-buffers cli tool | ||
// This file is auto generated by the protocol-buffers compiler | ||
@@ -6,2 +6,3 @@ /* eslint-disable quotes */ | ||
/* eslint-disable no-redeclare */ | ||
/* eslint-disable camelcase */ | ||
@@ -367,3 +368,4 @@ // Remember to `npm install --save protocol-buffers-encodings` | ||
encodings.varint, | ||
encodings.bytes | ||
encodings.bytes, | ||
encodings.bool | ||
] | ||
@@ -388,2 +390,6 @@ | ||
} | ||
if (defined(obj.ack)) { | ||
var len = enc[2].encodingLength(obj.ack) | ||
length += 1 + len | ||
} | ||
return length | ||
@@ -410,2 +416,7 @@ } | ||
} | ||
if (defined(obj.ack)) { | ||
buf[offset++] = 32 | ||
enc[2].encode(obj.ack, buf, offset) | ||
offset += enc[2].encode.bytes | ||
} | ||
encode.bytes = offset - oldOffset | ||
@@ -423,3 +434,4 @@ return buf | ||
length: 1, | ||
bitfield: null | ||
bitfield: null, | ||
ack: false | ||
} | ||
@@ -450,2 +462,6 @@ var found0 = false | ||
break | ||
case 4: | ||
obj.ack = enc[2].decode(buf, offset) | ||
offset += enc[2].decode.bytes | ||
break | ||
default: | ||
@@ -452,0 +468,0 @@ offset = skip(prefix & 7, buf, offset) |
{ | ||
"name": "hypercore-protocol", | ||
"version": "6.11.1", | ||
"version": "6.12.0", | ||
"description": "Stream that implements the hypercore protocol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
74
test.js
@@ -128,3 +128,3 @@ var tape = require('tape') | ||
ch1.on('have', function (have) { | ||
t.same(have, {start: 10, length: 10, bitfield: null}) | ||
t.same(have, {start: 10, length: 10, bitfield: null, ack: false}) | ||
}) | ||
@@ -197,3 +197,3 @@ | ||
ch1.on('have', function (have) { | ||
t.same(have, {start: 10, length: 10, bitfield: null}) | ||
t.same(have, {start: 10, length: 10, bitfield: null, ack: false}) | ||
}) | ||
@@ -266,3 +266,3 @@ | ||
ch1.on('have', function (have) { | ||
t.same(have, {start: 10, length: 10, bitfield: null}) | ||
t.same(have, {start: 10, length: 10, bitfield: null, ack: false}) | ||
}) | ||
@@ -298,2 +298,70 @@ | ||
tape('send messages (with ack)', function (t) { | ||
t.plan(10) | ||
var a = protocol() | ||
var b = protocol() | ||
var ch1 = a.feed(KEY) | ||
var ch2 = b.feed(KEY) | ||
b.on('feed', function (discoveryKey) { | ||
t.same(discoveryKey, ch1.discoveryKey) | ||
}) | ||
a.on('feed', function (discoveryKey) { | ||
t.same(discoveryKey, ch2.discoveryKey) | ||
}) | ||
ch2.on('data', function (data) { | ||
t.same(data, {index: 42, signature: null, value: bufferFrom('hi'), nodes: []}) | ||
}) | ||
ch1.data({index: 42, value: bufferFrom('hi')}) | ||
ch2.on('request', function (request) { | ||
t.same(request, {index: 10, hash: false, bytes: 0, nodes: 0}) | ||
}) | ||
ch1.request({index: 10}) | ||
ch2.on('cancel', function (cancel) { | ||
t.same(cancel, {index: 100, hash: false, bytes: 0}) | ||
}) | ||
ch1.cancel({index: 100}) | ||
ch1.on('want', function (want) { | ||
t.same(want, {start: 10, length: 100}) | ||
}) | ||
ch2.want({start: 10, length: 100}) | ||
ch1.on('info', function (info) { | ||
t.same(info, {uploading: false, downloading: true}) | ||
}) | ||
ch2.info({uploading: false, downloading: true}) | ||
ch1.on('unwant', function (unwant) { | ||
t.same(unwant, {start: 11, length: 100}) | ||
}) | ||
ch2.unwant({start: 11, length: 100}) | ||
ch1.on('unhave', function (unhave) { | ||
t.same(unhave, {start: 18, length: 100}) | ||
}) | ||
ch2.unhave({start: 18, length: 100}) | ||
ch1.on('have', function (have) { | ||
t.same(have, {start: 10, length: 10, bitfield: null, ack: true}) | ||
}) | ||
ch2.have({start: 10, length: 10, ack: true}) | ||
a.pipe(b).pipe(a) | ||
}) | ||
tape('first feed should be the same', function (t) { | ||
@@ -300,0 +368,0 @@ t.plan(2) |
Sorry, the diff of this file is not supported yet
71757
2140