mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-22 19:18:07 +00:00
fixed #161, web3.ssh.post
This commit is contained in:
parent
dc0f2318bf
commit
96b44682f1
8
dist/web3-light.js
vendored
8
dist/web3-light.js
vendored
@ -804,7 +804,7 @@ var toAscii = function(hex) {
|
|||||||
/**
|
/**
|
||||||
* Shold be called to get hex representation (prefixed by 0x) of ascii string
|
* Shold be called to get hex representation (prefixed by 0x) of ascii string
|
||||||
*
|
*
|
||||||
* @method fromAscii
|
* @method toHexNative
|
||||||
* @param {String} string
|
* @param {String} string
|
||||||
* @returns {String} hex representation of input string
|
* @returns {String} hex representation of input string
|
||||||
*/
|
*/
|
||||||
@ -2304,9 +2304,11 @@ var inputPostFormatter = function(post) {
|
|||||||
|
|
||||||
post.payload = utils.toHex(post.payload);
|
post.payload = utils.toHex(post.payload);
|
||||||
post.ttl = utils.fromDecimal(post.ttl);
|
post.ttl = utils.fromDecimal(post.ttl);
|
||||||
|
post.workToProve = utils.fromDecimal(post.workToProve);
|
||||||
post.priority = utils.fromDecimal(post.priority);
|
post.priority = utils.fromDecimal(post.priority);
|
||||||
|
|
||||||
if(!utils.isArray(post.topics)) {
|
// fallback
|
||||||
|
if (!utils.isArray(post.topics)) {
|
||||||
post.topics = [post.topics];
|
post.topics = [post.topics];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3118,7 +3120,7 @@ var post = new Method({
|
|||||||
name: 'post',
|
name: 'post',
|
||||||
call: 'shh_post',
|
call: 'shh_post',
|
||||||
params: 1,
|
params: 1,
|
||||||
inputFormatter: formatters.inputPostFormatter
|
inputFormatter: [formatters.inputPostFormatter]
|
||||||
});
|
});
|
||||||
|
|
||||||
var newIdentity = new Method({
|
var newIdentity = new Method({
|
||||||
|
8
dist/web3-light.js.map
vendored
8
dist/web3-light.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/web3-light.min.js
vendored
2
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
5360
dist/web3.js
vendored
5360
dist/web3.js
vendored
File diff suppressed because it is too large
Load Diff
12
dist/web3.js.map
vendored
12
dist/web3.js.map
vendored
File diff suppressed because one or more lines are too long
5
dist/web3.min.js
vendored
5
dist/web3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -112,7 +112,7 @@ var toAscii = function(hex) {
|
|||||||
/**
|
/**
|
||||||
* Shold be called to get hex representation (prefixed by 0x) of ascii string
|
* Shold be called to get hex representation (prefixed by 0x) of ascii string
|
||||||
*
|
*
|
||||||
* @method fromAscii
|
* @method toHexNative
|
||||||
* @param {String} string
|
* @param {String} string
|
||||||
* @returns {String} hex representation of input string
|
* @returns {String} hex representation of input string
|
||||||
*/
|
*/
|
||||||
|
@ -155,9 +155,11 @@ var inputPostFormatter = function(post) {
|
|||||||
|
|
||||||
post.payload = utils.toHex(post.payload);
|
post.payload = utils.toHex(post.payload);
|
||||||
post.ttl = utils.fromDecimal(post.ttl);
|
post.ttl = utils.fromDecimal(post.ttl);
|
||||||
|
post.workToProve = utils.fromDecimal(post.workToProve);
|
||||||
post.priority = utils.fromDecimal(post.priority);
|
post.priority = utils.fromDecimal(post.priority);
|
||||||
|
|
||||||
if(!utils.isArray(post.topics)) {
|
// fallback
|
||||||
|
if (!utils.isArray(post.topics)) {
|
||||||
post.topics = [post.topics];
|
post.topics = [post.topics];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ var post = new Method({
|
|||||||
name: 'post',
|
name: 'post',
|
||||||
call: 'shh_post',
|
call: 'shh_post',
|
||||||
params: 1,
|
params: 1,
|
||||||
inputFormatter: formatters.inputPostFormatter
|
inputFormatter: [formatters.inputPostFormatter]
|
||||||
});
|
});
|
||||||
|
|
||||||
var newIdentity = new Method({
|
var newIdentity = new Method({
|
||||||
|
@ -20,7 +20,8 @@ describe('formatters', function () {
|
|||||||
payload: '0x7b2274657374223a2274657374227d',
|
payload: '0x7b2274657374223a2274657374227d',
|
||||||
ttl: '0xc8',
|
ttl: '0xc8',
|
||||||
priority: '0x3e8',
|
priority: '0x3e8',
|
||||||
topics: ['0x68656c6c6f','0x6d79746f70696373']
|
topics: ['0x68656c6c6f','0x6d79746f70696373'],
|
||||||
|
workToProve: '0x0'
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -2,6 +2,7 @@ var chai = require('chai');
|
|||||||
var assert = chai.assert;
|
var assert = chai.assert;
|
||||||
var web3 = require('../../index');
|
var web3 = require('../../index');
|
||||||
var FakeHttpProvider = require('./FakeHttpProvider');
|
var FakeHttpProvider = require('./FakeHttpProvider');
|
||||||
|
var clone = function (object) { return JSON.parse(JSON.stringify(object)); };
|
||||||
|
|
||||||
var runTests = function (obj, method, tests) {
|
var runTests = function (obj, method, tests) {
|
||||||
|
|
||||||
@ -22,10 +23,18 @@ var runTests = function (obj, method, tests) {
|
|||||||
assert.deepEqual(payload.params, test.formattedArgs);
|
assert.deepEqual(payload.params, test.formattedArgs);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var args = clone(test.args)
|
||||||
|
|
||||||
// when
|
// when
|
||||||
var result = (obj)
|
if (obj) {
|
||||||
? web3[obj][method].apply(null, test.args.slice(0))
|
var result = web3[obj][method].apply(null, args);
|
||||||
: web3[method].apply(null, test.args.slice(0));
|
} else {
|
||||||
|
var result = web3[method].apply(null, args);
|
||||||
|
}
|
||||||
|
// when
|
||||||
|
//var result = (obj)
|
||||||
|
//? web3[obj][method].apply(null, test.args.slice(0))
|
||||||
|
//: web3[method].apply(null, test.args.slice(0));
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert.deepEqual(test.formattedResult, result);
|
assert.deepEqual(test.formattedResult, result);
|
||||||
@ -43,7 +52,8 @@ var runTests = function (obj, method, tests) {
|
|||||||
assert.deepEqual(payload.params, test.formattedArgs);
|
assert.deepEqual(payload.params, test.formattedArgs);
|
||||||
});
|
});
|
||||||
|
|
||||||
var args = test.args.slice(0);
|
var args = clone(test.args);
|
||||||
|
|
||||||
// add callback
|
// add callback
|
||||||
args.push(function (err, result) {
|
args.push(function (err, result) {
|
||||||
assert.deepEqual(test.formattedResult, result);
|
assert.deepEqual(test.formattedResult, result);
|
||||||
@ -51,10 +61,11 @@ var runTests = function (obj, method, tests) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// when
|
// when
|
||||||
if(obj)
|
if (obj) {
|
||||||
web3[obj][method].apply(null, args);
|
web3[obj][method].apply(null, args);
|
||||||
else
|
} else {
|
||||||
web3[method].apply(null, args);
|
web3[method].apply(null, args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
49
test/web3.shh.post.js
Normal file
49
test/web3.shh.post.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
var chai = require('chai');
|
||||||
|
var web3 = require('../index');
|
||||||
|
var testMethod = require('./helpers/test.method.js');
|
||||||
|
|
||||||
|
var method = 'post';
|
||||||
|
|
||||||
|
var tests = [{
|
||||||
|
args: [{
|
||||||
|
from: '0x123123123',
|
||||||
|
topics: ['hello_world'],
|
||||||
|
payload: '12345',
|
||||||
|
ttl: 100,
|
||||||
|
workToProve: 101
|
||||||
|
}],
|
||||||
|
formattedArgs: [{
|
||||||
|
from: '0x123123123',
|
||||||
|
topics: [web3.fromAscii('hello_world')],
|
||||||
|
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'
|
||||||
|
}],
|
||||||
|
result: true,
|
||||||
|
formattedResult: true,
|
||||||
|
call: 'shh_'+ method
|
||||||
|
}];
|
||||||
|
|
||||||
|
testMethod.runTests('shh', method, tests);
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user