fix encoding mistake - payload should be buffer-like
This commit is contained in:
parent
08a741d880
commit
c0b95a5879
2 changed files with 6 additions and 2 deletions
|
|
@ -383,6 +383,8 @@ Network.prototype._decode = function(key, encoded) {
|
|||
};
|
||||
|
||||
Network.prototype._sendToOne = function(copayerId, payload, cb) {
|
||||
if (!Buffer.isBuffer(payload))
|
||||
throw new Error('payload must be a buffer');
|
||||
var peerId = this.peerFromCopayer(copayerId);
|
||||
if (peerId !== this.peerId) {
|
||||
var dataConn = this.connections[peerId];
|
||||
|
|
@ -413,7 +415,8 @@ Network.prototype.send = function(copayerIds, payload, cb) {
|
|||
copayerIds.forEach(function(copayerId) {
|
||||
var copayerIdBuf = new Buffer(copayerId, 'hex');
|
||||
var encPayload = self._encode(copayerIdBuf, self.getKey(), payloadBuf);
|
||||
self._sendToOne(copayerId, encPayload, function() {
|
||||
var enc = new Buffer(JSON.stringify(encPayload));
|
||||
self._sendToOne(copayerId, enc, function() {
|
||||
if (++i === l && typeof cb === 'function') cb();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -121,7 +121,8 @@ describe('Network / WebRTC', function() {
|
|||
key.regenerateSync();
|
||||
|
||||
var copayerId = key.public.toString('hex');
|
||||
n._sendToOne = function(a1, encPayload, cb) {
|
||||
n._sendToOne = function(a1, enc, cb) {
|
||||
var encPayload = JSON.parse(enc.toString());
|
||||
encPayload.sig.length.should.be.greaterThan(0);
|
||||
cb();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue