Whisperv5 (#902)

* added whisper api

* added whisper api tests

* fix lint errors
This commit is contained in:
Fabian Vogelsteller 2017-06-23 14:57:11 +02:00 committed by GitHub
parent db6efd5f23
commit 6d3e61a010
18 changed files with 541 additions and 414 deletions

207
dist/web3-light.js vendored
View File

@ -2475,7 +2475,7 @@ module.exports = {
},{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":85}],21:[function(require,module,exports){
module.exports={
"version": "0.19.0"
"version": "0.20.0"
}
},{}],22:[function(require,module,exports){
@ -2711,7 +2711,7 @@ AllSolidityEvents.prototype.execute = function (options, callback) {
var o = this.encode(options);
var formatter = this.decode.bind(this);
return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
};
AllSolidityEvents.prototype.attachToContract = function (contract) {
@ -3336,7 +3336,7 @@ SolidityEvent.prototype.execute = function (indexed, options, callback) {
var o = this.encode(indexed, options);
var formatter = this.decode.bind(this);
return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
};
/**
@ -3459,7 +3459,7 @@ var toTopic = function(value){
/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
/// @param should be string or object
/// @returns options string or object
var getOptions = function (options) {
var getOptions = function (options, type) {
if (utils.isString(options)) {
return options;
@ -3467,6 +3467,10 @@ var getOptions = function (options) {
options = options || {};
switch(type) {
case 'eth':
// make sure topics, get converted to hex
options.topics = options.topics || [];
options.topics = options.topics.map(function(topic){
@ -3481,6 +3485,9 @@ var getOptions = function (options) {
fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
};
case 'shh':
return options;
}
};
/**
@ -3488,7 +3495,7 @@ Adds the callback and sets up the methods, to iterate over the results.
@method getLogsAtStart
@param {Object} self
@param {funciton}
@param {function} callback
*/
var getLogsAtStart = function(self, callback){
// call getFilterLogs for the first watch callback start
@ -3540,7 +3547,7 @@ var pollFilter = function(self) {
};
var Filter = function (requestManager, options, methods, formatter, callback, filterCreationErrorCallback) {
var Filter = function (options, type, requestManager, methods, formatter, callback, filterCreationErrorCallback) {
var self = this;
var implementation = {};
methods.forEach(function (method) {
@ -3548,7 +3555,7 @@ var Filter = function (requestManager, options, methods, formatter, callback, fi
method.attachToObject(implementation);
});
this.requestManager = requestManager;
this.options = getOptions(options);
this.options = getOptions(options, type);
this.implementation = implementation;
this.filterId = null;
this.callbacks = [];
@ -5485,8 +5492,8 @@ Eth.prototype.contract = function (abi) {
return factory;
};
Eth.prototype.filter = function (fil, callback, filterCreationErrorCallback) {
return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
Eth.prototype.filter = function (options, callback, filterCreationErrorCallback) {
return new Filter(options, 'eth', this._requestManager, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
};
Eth.prototype.namereg = function () {
@ -5693,8 +5700,9 @@ module.exports = Personal;
*/
/** @file shh.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
* Fabian Vogelsteller <fabian@ethereum.org>
* Marek Kotewicz <marek@ethcore.io>
* @date 2017
*/
var Method = require('../method');
@ -5713,49 +5721,107 @@ var Shh = function (web3) {
});
};
Shh.prototype.filter = function (fil, callback) {
return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
Shh.prototype.newMessageFilter = function (options, callback, filterCreationErrorCallback) {
return new Filter(options, 'shh', this._requestManager, watches.shh(), null, callback, filterCreationErrorCallback);
};
var methods = function () {
var post = new Method({
return [
new Method({
name: 'version',
call: 'shh_version',
params: 0
}),
new Method({
name: 'info',
call: 'shh_info',
params: 0
}),
new Method({
name: 'setMaxMessageSize',
call: 'shh_setMaxMessageSize',
params: 1
}),
new Method({
name: 'setMinPoW',
call: 'shh_setMinPoW',
params: 1
}),
new Method({
name: 'markTrustedPeer',
call: 'shh_markTrustedPeer',
params: 1
}),
new Method({
name: 'newKeyPair',
call: 'shh_newKeyPair',
params: 0
}),
new Method({
name: 'addPrivateKey',
call: 'shh_addPrivateKey',
params: 1
}),
new Method({
name: 'deleteKeyPair',
call: 'shh_deleteKeyPair',
params: 1
}),
new Method({
name: 'hasKeyPair',
call: 'shh_hasKeyPair',
params: 1
}),
new Method({
name: 'getPublicKey',
call: 'shh_getPublicKey',
params: 1
}),
new Method({
name: 'getPrivateKey',
call: 'shh_getPrivateKey',
params: 1
}),
new Method({
name: 'newSymKey',
call: 'shh_newSymKey',
params: 0
}),
new Method({
name: 'addSymKey',
call: 'shh_addSymKey',
params: 1
}),
new Method({
name: 'generateSymKeyFromPassword',
call: 'shh_generateSymKeyFromPassword',
params: 1
}),
new Method({
name: 'hasSymKey',
call: 'shh_hasSymKey',
params: 1
}),
new Method({
name: 'getSymKey',
call: 'shh_getSymKey',
params: 1
}),
new Method({
name: 'deleteSymKey',
call: 'shh_deleteSymKey',
params: 1
}),
// subscribe and unsubscribe missing
new Method({
name: 'post',
call: 'shh_post',
params: 1,
inputFormatter: [formatters.inputPostFormatter]
});
var newIdentity = new Method({
name: 'newIdentity',
call: 'shh_newIdentity',
params: 0
});
var hasIdentity = new Method({
name: 'hasIdentity',
call: 'shh_hasIdentity',
params: 1
});
var newGroup = new Method({
name: 'newGroup',
call: 'shh_newGroup',
params: 0
});
var addToGroup = new Method({
name: 'addToGroup',
call: 'shh_addToGroup',
params: 0
});
return [
post,
newIdentity,
hasIdentity,
newGroup,
addToGroup
inputFormatter: [null]
})
];
};
@ -5987,35 +6053,28 @@ var eth = function () {
/// @returns an array of objects describing web3.shh.watch api methods
var shh = function () {
var newFilter = new Method({
name: 'newFilter',
call: 'shh_newFilter',
params: 1
});
var uninstallFilter = new Method({
name: 'uninstallFilter',
call: 'shh_uninstallFilter',
params: 1
});
var getLogs = new Method({
name: 'getLogs',
call: 'shh_getMessages',
params: 1
});
var poll = new Method({
name: 'poll',
call: 'shh_getFilterChanges',
params: 1
});
return [
newFilter,
uninstallFilter,
getLogs,
poll
new Method({
name: 'newFilter',
call: 'shh_newMessageFilter',
params: 1
}),
new Method({
name: 'uninstallFilter',
call: 'shh_deleteMessageFilter',
params: 1
}),
new Method({
name: 'getLogs',
call: 'shh_getFilterMessages',
params: 1
}),
new Method({
name: 'poll',
call: 'shh_getFilterMessages',
params: 1
})
];
};

File diff suppressed because one or more lines are too long

207
dist/web3.js vendored
View File

@ -2475,7 +2475,7 @@ module.exports = {
},{"./sha3.js":19,"bignumber.js":"bignumber.js","utf8":84}],21:[function(require,module,exports){
module.exports={
"version": "0.19.0"
"version": "0.20.0"
}
},{}],22:[function(require,module,exports){
@ -2711,7 +2711,7 @@ AllSolidityEvents.prototype.execute = function (options, callback) {
var o = this.encode(options);
var formatter = this.decode.bind(this);
return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
};
AllSolidityEvents.prototype.attachToContract = function (contract) {
@ -3336,7 +3336,7 @@ SolidityEvent.prototype.execute = function (indexed, options, callback) {
var o = this.encode(indexed, options);
var formatter = this.decode.bind(this);
return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
};
/**
@ -3459,7 +3459,7 @@ var toTopic = function(value){
/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
/// @param should be string or object
/// @returns options string or object
var getOptions = function (options) {
var getOptions = function (options, type) {
if (utils.isString(options)) {
return options;
@ -3467,6 +3467,10 @@ var getOptions = function (options) {
options = options || {};
switch(type) {
case 'eth':
// make sure topics, get converted to hex
options.topics = options.topics || [];
options.topics = options.topics.map(function(topic){
@ -3481,6 +3485,9 @@ var getOptions = function (options) {
fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
};
case 'shh':
return options;
}
};
/**
@ -3488,7 +3495,7 @@ Adds the callback and sets up the methods, to iterate over the results.
@method getLogsAtStart
@param {Object} self
@param {funciton}
@param {function} callback
*/
var getLogsAtStart = function(self, callback){
// call getFilterLogs for the first watch callback start
@ -3540,7 +3547,7 @@ var pollFilter = function(self) {
};
var Filter = function (requestManager, options, methods, formatter, callback, filterCreationErrorCallback) {
var Filter = function (options, type, requestManager, methods, formatter, callback, filterCreationErrorCallback) {
var self = this;
var implementation = {};
methods.forEach(function (method) {
@ -3548,7 +3555,7 @@ var Filter = function (requestManager, options, methods, formatter, callback, fi
method.attachToObject(implementation);
});
this.requestManager = requestManager;
this.options = getOptions(options);
this.options = getOptions(options, type);
this.implementation = implementation;
this.filterId = null;
this.callbacks = [];
@ -5485,8 +5492,8 @@ Eth.prototype.contract = function (abi) {
return factory;
};
Eth.prototype.filter = function (fil, callback, filterCreationErrorCallback) {
return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
Eth.prototype.filter = function (options, callback, filterCreationErrorCallback) {
return new Filter(options, 'eth', this._requestManager, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
};
Eth.prototype.namereg = function () {
@ -5693,8 +5700,9 @@ module.exports = Personal;
*/
/** @file shh.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
* Fabian Vogelsteller <fabian@ethereum.org>
* Marek Kotewicz <marek@ethcore.io>
* @date 2017
*/
var Method = require('../method');
@ -5713,49 +5721,107 @@ var Shh = function (web3) {
});
};
Shh.prototype.filter = function (fil, callback) {
return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
Shh.prototype.newMessageFilter = function (options, callback, filterCreationErrorCallback) {
return new Filter(options, 'shh', this._requestManager, watches.shh(), null, callback, filterCreationErrorCallback);
};
var methods = function () {
var post = new Method({
return [
new Method({
name: 'version',
call: 'shh_version',
params: 0
}),
new Method({
name: 'info',
call: 'shh_info',
params: 0
}),
new Method({
name: 'setMaxMessageSize',
call: 'shh_setMaxMessageSize',
params: 1
}),
new Method({
name: 'setMinPoW',
call: 'shh_setMinPoW',
params: 1
}),
new Method({
name: 'markTrustedPeer',
call: 'shh_markTrustedPeer',
params: 1
}),
new Method({
name: 'newKeyPair',
call: 'shh_newKeyPair',
params: 0
}),
new Method({
name: 'addPrivateKey',
call: 'shh_addPrivateKey',
params: 1
}),
new Method({
name: 'deleteKeyPair',
call: 'shh_deleteKeyPair',
params: 1
}),
new Method({
name: 'hasKeyPair',
call: 'shh_hasKeyPair',
params: 1
}),
new Method({
name: 'getPublicKey',
call: 'shh_getPublicKey',
params: 1
}),
new Method({
name: 'getPrivateKey',
call: 'shh_getPrivateKey',
params: 1
}),
new Method({
name: 'newSymKey',
call: 'shh_newSymKey',
params: 0
}),
new Method({
name: 'addSymKey',
call: 'shh_addSymKey',
params: 1
}),
new Method({
name: 'generateSymKeyFromPassword',
call: 'shh_generateSymKeyFromPassword',
params: 1
}),
new Method({
name: 'hasSymKey',
call: 'shh_hasSymKey',
params: 1
}),
new Method({
name: 'getSymKey',
call: 'shh_getSymKey',
params: 1
}),
new Method({
name: 'deleteSymKey',
call: 'shh_deleteSymKey',
params: 1
}),
// subscribe and unsubscribe missing
new Method({
name: 'post',
call: 'shh_post',
params: 1,
inputFormatter: [formatters.inputPostFormatter]
});
var newIdentity = new Method({
name: 'newIdentity',
call: 'shh_newIdentity',
params: 0
});
var hasIdentity = new Method({
name: 'hasIdentity',
call: 'shh_hasIdentity',
params: 1
});
var newGroup = new Method({
name: 'newGroup',
call: 'shh_newGroup',
params: 0
});
var addToGroup = new Method({
name: 'addToGroup',
call: 'shh_addToGroup',
params: 0
});
return [
post,
newIdentity,
hasIdentity,
newGroup,
addToGroup
inputFormatter: [null]
})
];
};
@ -5987,35 +6053,28 @@ var eth = function () {
/// @returns an array of objects describing web3.shh.watch api methods
var shh = function () {
var newFilter = new Method({
name: 'newFilter',
call: 'shh_newFilter',
params: 1
});
var uninstallFilter = new Method({
name: 'uninstallFilter',
call: 'shh_uninstallFilter',
params: 1
});
var getLogs = new Method({
name: 'getLogs',
call: 'shh_getMessages',
params: 1
});
var poll = new Method({
name: 'poll',
call: 'shh_getFilterChanges',
params: 1
});
return [
newFilter,
uninstallFilter,
getLogs,
poll
new Method({
name: 'newFilter',
call: 'shh_newMessageFilter',
params: 1
}),
new Method({
name: 'uninstallFilter',
call: 'shh_deleteMessageFilter',
params: 1
}),
new Method({
name: 'getLogs',
call: 'shh_getFilterMessages',
params: 1
}),
new Method({
name: 'poll',
call: 'shh_getFilterMessages',
params: 1
})
];
};

16
dist/web3.js.map vendored

File diff suppressed because one or more lines are too long

10
dist/web3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,3 @@
{
"version": "0.19.0"
"version": "0.20.0"
}

View File

@ -76,7 +76,7 @@ AllSolidityEvents.prototype.execute = function (options, callback) {
var o = this.encode(options);
var formatter = this.decode.bind(this);
return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
};
AllSolidityEvents.prototype.attachToContract = function (contract) {

View File

@ -186,7 +186,7 @@ SolidityEvent.prototype.execute = function (indexed, options, callback) {
var o = this.encode(indexed, options);
var formatter = this.decode.bind(this);
return new Filter(this._requestManager, o, watches.eth(), formatter, callback);
return new Filter(o, 'eth', this._requestManager, watches.eth(), formatter, callback);
};
/**

View File

@ -49,7 +49,8 @@ var toTopic = function(value){
/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
/// @param should be string or object
/// @returns options string or object
var getOptions = function (options) {
var getOptions = function (options, type) {
/*jshint maxcomplexity: 6 */
if (utils.isString(options)) {
return options;
@ -57,6 +58,10 @@ var getOptions = function (options) {
options = options || {};
switch(type) {
case 'eth':
// make sure topics, get converted to hex
options.topics = options.topics || [];
options.topics = options.topics.map(function(topic){
@ -71,6 +76,9 @@ var getOptions = function (options) {
fromBlock: formatters.inputBlockNumberFormatter(options.fromBlock),
toBlock: formatters.inputBlockNumberFormatter(options.toBlock)
};
case 'shh':
return options;
}
};
/**
@ -78,7 +86,7 @@ Adds the callback and sets up the methods, to iterate over the results.
@method getLogsAtStart
@param {Object} self
@param {funciton}
@param {function} callback
*/
var getLogsAtStart = function(self, callback){
// call getFilterLogs for the first watch callback start
@ -130,7 +138,7 @@ var pollFilter = function(self) {
};
var Filter = function (requestManager, options, methods, formatter, callback, filterCreationErrorCallback) {
var Filter = function (options, type, requestManager, methods, formatter, callback, filterCreationErrorCallback) {
var self = this;
var implementation = {};
methods.forEach(function (method) {
@ -138,7 +146,7 @@ var Filter = function (requestManager, options, methods, formatter, callback, fi
method.attachToObject(implementation);
});
this.requestManager = requestManager;
this.options = getOptions(options);
this.options = getOptions(options, type);
this.implementation = implementation;
this.filterId = null;
this.callbacks = [];

View File

@ -335,8 +335,8 @@ Eth.prototype.contract = function (abi) {
return factory;
};
Eth.prototype.filter = function (fil, callback, filterCreationErrorCallback) {
return new Filter(this._requestManager, fil, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
Eth.prototype.filter = function (options, callback, filterCreationErrorCallback) {
return new Filter(options, 'eth', this._requestManager, watches.eth(), formatters.outputLogFormatter, callback, filterCreationErrorCallback);
};
Eth.prototype.namereg = function () {

View File

@ -16,12 +16,12 @@
*/
/** @file shh.js
* @authors:
* Marek Kotewicz <marek@ethdev.com>
* @date 2015
* Fabian Vogelsteller <fabian@ethereum.org>
* Marek Kotewicz <marek@ethcore.io>
* @date 2017
*/
var Method = require('../method');
var formatters = require('../formatters');
var Filter = require('../filter');
var watches = require('./watches');
@ -36,49 +36,107 @@ var Shh = function (web3) {
});
};
Shh.prototype.filter = function (fil, callback) {
return new Filter(this._requestManager, fil, watches.shh(), formatters.outputPostFormatter, callback);
Shh.prototype.newMessageFilter = function (options, callback, filterCreationErrorCallback) {
return new Filter(options, 'shh', this._requestManager, watches.shh(), null, callback, filterCreationErrorCallback);
};
var methods = function () {
var post = new Method({
return [
new Method({
name: 'version',
call: 'shh_version',
params: 0
}),
new Method({
name: 'info',
call: 'shh_info',
params: 0
}),
new Method({
name: 'setMaxMessageSize',
call: 'shh_setMaxMessageSize',
params: 1
}),
new Method({
name: 'setMinPoW',
call: 'shh_setMinPoW',
params: 1
}),
new Method({
name: 'markTrustedPeer',
call: 'shh_markTrustedPeer',
params: 1
}),
new Method({
name: 'newKeyPair',
call: 'shh_newKeyPair',
params: 0
}),
new Method({
name: 'addPrivateKey',
call: 'shh_addPrivateKey',
params: 1
}),
new Method({
name: 'deleteKeyPair',
call: 'shh_deleteKeyPair',
params: 1
}),
new Method({
name: 'hasKeyPair',
call: 'shh_hasKeyPair',
params: 1
}),
new Method({
name: 'getPublicKey',
call: 'shh_getPublicKey',
params: 1
}),
new Method({
name: 'getPrivateKey',
call: 'shh_getPrivateKey',
params: 1
}),
new Method({
name: 'newSymKey',
call: 'shh_newSymKey',
params: 0
}),
new Method({
name: 'addSymKey',
call: 'shh_addSymKey',
params: 1
}),
new Method({
name: 'generateSymKeyFromPassword',
call: 'shh_generateSymKeyFromPassword',
params: 1
}),
new Method({
name: 'hasSymKey',
call: 'shh_hasSymKey',
params: 1
}),
new Method({
name: 'getSymKey',
call: 'shh_getSymKey',
params: 1
}),
new Method({
name: 'deleteSymKey',
call: 'shh_deleteSymKey',
params: 1
}),
// subscribe and unsubscribe missing
new Method({
name: 'post',
call: 'shh_post',
params: 1,
inputFormatter: [formatters.inputPostFormatter]
});
var newIdentity = new Method({
name: 'newIdentity',
call: 'shh_newIdentity',
params: 0
});
var hasIdentity = new Method({
name: 'hasIdentity',
call: 'shh_hasIdentity',
params: 1
});
var newGroup = new Method({
name: 'newGroup',
call: 'shh_newGroup',
params: 0
});
var addToGroup = new Method({
name: 'addToGroup',
call: 'shh_addToGroup',
params: 0
});
return [
post,
newIdentity,
hasIdentity,
newGroup,
addToGroup
inputFormatter: [null]
})
];
};

View File

@ -75,35 +75,28 @@ var eth = function () {
/// @returns an array of objects describing web3.shh.watch api methods
var shh = function () {
var newFilter = new Method({
name: 'newFilter',
call: 'shh_newFilter',
params: 1
});
var uninstallFilter = new Method({
name: 'uninstallFilter',
call: 'shh_uninstallFilter',
params: 1
});
var getLogs = new Method({
name: 'getLogs',
call: 'shh_getMessages',
params: 1
});
var poll = new Method({
name: 'poll',
call: 'shh_getFilterChanges',
params: 1
});
return [
newFilter,
uninstallFilter,
getLogs,
poll
new Method({
name: 'newFilter',
call: 'shh_newMessageFilter',
params: 1
}),
new Method({
name: 'uninstallFilter',
call: 'shh_deleteMessageFilter',
params: 1
}),
new Method({
name: 'getLogs',
call: 'shh_getFilterMessages',
params: 1
}),
new Method({
name: 'poll',
call: 'shh_getFilterMessages',
params: 1
})
];
};

View File

@ -1,7 +1,7 @@
/* jshint ignore:start */
Package.describe({
name: 'ethereum:web3',
version: '0.19.0',
version: '0.20.0',
summary: 'Ethereum JavaScript API, middleware to talk to a ethreum node over RPC',
git: 'https://github.com/ethereum/ethereum.js',
// By default, Meteor will default to using README.md for documentation.

View File

@ -1,7 +1,7 @@
{
"name": "web3",
"namespace": "ethereum",
"version": "0.19.0",
"version": "0.20.0",
"description": "Ethereum JavaScript API, middleware to talk to a ethereum node over RPC",
"main": "./index.js",
"directories": {

View File

@ -4,59 +4,26 @@ var web3 = new Web3();
var assert = chai.assert;
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
var method = 'filter';
var method = 'newMessageFilter';
var tests = [{
args: [{
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
topics: ['0x324f5435', '0x564b4566f3453']
symKeyID: '47d33b27bb249a2dbab4c0612bf9caf4c1950855',
sig: '0x55dd47d33b27bb249a2dbab4c0612bf9caf4c1950855',
minPow: 0.5,
topics: ['0x32dd4f54', '0x564b4566'],
allowP2P: false
}],
formattedArgs: [{
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
topics: ['0x324f5435', '0x564b4566f3453']
symKeyID: '47d33b27bb249a2dbab4c0612bf9caf4c1950855',
sig: '0x55dd47d33b27bb249a2dbab4c0612bf9caf4c1950855',
minPow: 0.5,
topics: ['0x32dd4f54', '0x564b4566'],
allowP2P: false
}],
result: '0xf',
formattedResult: '0xf',
call: 'shh_newFilter'
},
{
args: [{
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
topics: ['0x324f5435', ['0x564b4566f3453', '0x345345343453']]
}],
formattedArgs: [{
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
topics: ['0x324f5435', ['0x564b4566f3453', '0x345345343453']]
}],
result: '0xf',
formattedResult: '0xf',
call: 'shh_newFilter'
},
{
args: [{
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
topics: ['0x324f5435', null, ['0x564b4566f3453', '0x345345343453']]
}],
formattedArgs: [{
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
topics: ['0x324f5435', null, ['0x564b4566f3453', '0x345345343453']]
}],
result: '0xf',
formattedResult: '0xf',
call: 'shh_newFilter'
},
{
args: [{
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
topics: ['myString', 11, '23', null]
}],
formattedArgs: [{
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
topics: ['0x6d79537472696e67', '0x3131', '0x3233', null]
}],
result: '0xf',
formattedResult: '0xf',
call: 'shh_newFilter'
call: 'shh_newMessageFilter'
}];
describe('shh', function () {

View File

@ -1,16 +0,0 @@
var chai = require('chai');
var web3 = require('../index');
var testMethod = require('./helpers/test.method.js');
var method = 'hasIdentity';
var tests = [{
args: ['0x2dbab4c0612bf9caf4c195085547dc0612bf9caf4c1950855'],
formattedArgs: ['0x2dbab4c0612bf9caf4c195085547dc0612bf9caf4c1950855'],
result: true,
formattedResult: true,
call: 'shh_'+ method
}];
testMethod.runTests('shh', method, tests);

View File

@ -6,12 +6,26 @@ var u = require('./helpers/test.utils.js');
describe('web3.shh', function() {
describe('methods', function() {
u.methodExists(web3.shh, 'version');
u.methodExists(web3.shh, 'info');
u.methodExists(web3.shh, 'setMaxMessageSize');
u.methodExists(web3.shh, 'setMinPoW');
u.methodExists(web3.shh, 'markTrustedPeer');
u.methodExists(web3.shh, 'newKeyPair');
u.methodExists(web3.shh, 'addPrivateKey');
u.methodExists(web3.shh, 'deleteKeyPair');
u.methodExists(web3.shh, 'hasKeyPair');
u.methodExists(web3.shh, 'getPublicKey');
u.methodExists(web3.shh, 'getPrivateKey');
u.methodExists(web3.shh, 'newSymKey');
u.methodExists(web3.shh, 'addSymKey');
u.methodExists(web3.shh, 'generateSymKeyFromPassword');
u.methodExists(web3.shh, 'hasSymKey');
u.methodExists(web3.shh, 'getSymKey');
u.methodExists(web3.shh, 'deleteSymKey');
u.methodExists(web3.shh, 'newMessageFilter');
u.methodExists(web3.shh, 'post');
u.methodExists(web3.shh, 'newIdentity');
u.methodExists(web3.shh, 'hasIdentity');
u.methodExists(web3.shh, 'newGroup');
u.methodExists(web3.shh, 'addToGroup');
u.methodExists(web3.shh, 'filter');
});
});

View File

@ -7,39 +7,24 @@ var method = 'post';
var tests = [{
args: [{
from: '0x123123123',
topics: ['hello_world'],
symKeyID: '123123123ff',
sig: '44ffdd55',
topic: '0xffdd11',
payload: web3.toHex('12345'),
ttl: 100,
workToProve: 101
minPow: 0.5,
powTarget: 3,
padding: '0xffdd4455'
}],
formattedArgs: [{
from: '0x123123123',
topics: [web3.fromAscii('hello_world')],
symKeyID: '123123123ff',
sig: '44ffdd55',
topic: '0xffdd11',
payload: web3.toHex('12345'),
ttl: web3.toHex('100'),
workToProve: web3.toHex('101'),
priority: '0x0'
}],
result: true,
formattedResult: true,
call: 'shh_'+ method
}, {
args: [{
from: '0x21312',
topics: ['hello_world'],
payload: '0x12345',
ttl: 0x100,
workToProve: 0x101,
priority: 0x15
}],
formattedArgs: [{
from: '0x21312',
topics: [web3.fromAscii('hello_world')],
payload: '0x12345',
ttl: '0x100',
workToProve: '0x101',
priority: '0x15'
ttl: 100,
minPow: 0.5,
powTarget: 3,
padding: '0xffdd4455'
}],
result: true,
formattedResult: true,