Fix pubkey.decode API

This commit is contained in:
Kagami Hiiragi 2015-01-29 01:21:48 +03:00
parent 8e892581f5
commit 2416094686
2 changed files with 5 additions and 5 deletions

View File

@ -208,9 +208,9 @@ var pubkey = exports.pubkey = {
/** /**
* Options for decoding pubkey * Options for decoding pubkey
* @typedef {Object} PubkeyDecodeOpts * @typedef {Object} PubkeyDecodeOpts
* @property {?(Address[]|Address|Object)} neededPubkeys - Address * @property {?(Address[]|Address|Object)} needed - Address objects
* objects which represent pubkeys that we are interested in; this is * which represent pubkeys that we are interested in; this is used
* used only for pubkeys v4 * only for pubkeys v4
*/ */
/** /**
@ -266,7 +266,7 @@ var pubkey = exports.pubkey = {
// `neededPubkeys` is either single address or addresses array or // `neededPubkeys` is either single address or addresses array or
// Object key-by-tag. Time to match the tag is O(1), O(n), O(1) // Object key-by-tag. Time to match the tag is O(1), O(n), O(1)
// respectfully. // respectfully.
var neededPubkeys = opts.neededPubkeys || {}; var neededPubkeys = opts.needed || {};
if (Address.isAddress(neededPubkeys)) { if (Address.isAddress(neededPubkeys)) {
addr = neededPubkeys; addr = neededPubkeys;
neededPubkeys = {}; neededPubkeys = {};

View File

@ -612,7 +612,7 @@ describe("Object types", function() {
return pubkey.encodeAsync({ttl: 789, from: from, to: from}) return pubkey.encodeAsync({ttl: 789, from: from, to: from})
.then(function(buf) { .then(function(buf) {
expect(message.decode(buf).command).to.equal("object"); expect(message.decode(buf).command).to.equal("object");
return pubkey.decodeAsync(buf, {neededPubkeys: from}); return pubkey.decodeAsync(buf, {needed: from});
}).then(function(res) { }).then(function(res) {
expect(res.ttl).to.be.at.most(789); expect(res.ttl).to.be.at.most(789);
expect(res.type).to.equal(object.PUBKEY); expect(res.type).to.equal(object.PUBKEY);