mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
add shh tests
This commit is contained in:
parent
e7304b546e
commit
afd7e7ba32
@ -42,5 +42,5 @@ var tests = [{
|
||||
call: 'eth_'+ method + 'ByHash'
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
||||
|
@ -30,5 +30,5 @@ var tests = [{
|
||||
call: 'eth_'+ method
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
||||
|
@ -135,5 +135,5 @@ var tests = [{
|
||||
call: 'eth_'+ method + 'ByNumber'
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
||||
|
@ -19,5 +19,5 @@ var tests = [{
|
||||
call: 'eth_getBlockTransactionCountByNumber'
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
||||
|
@ -18,4 +18,4 @@ var tests = [{
|
||||
call: 'eth_getUncleCountByBlockNumber'
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
@ -19,5 +19,5 @@ var tests = [{
|
||||
call: 'eth_'+ method
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
||||
|
@ -19,5 +19,5 @@ var tests = [{
|
||||
call: 'eth_'+ method
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
||||
|
@ -25,5 +25,5 @@ var tests = [{
|
||||
call: 'eth_'+ method
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
||||
|
@ -48,5 +48,5 @@ var tests = [{
|
||||
call: 'eth_getTransactionByBlockNumberAndIndex'
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
||||
|
@ -136,4 +136,4 @@ var tests = [{
|
||||
call: 'eth_getUncleByBlockNumberAndIndex'
|
||||
}];
|
||||
|
||||
testMethod.runTests(method, tests);
|
||||
testMethod.runTests('eth', method, tests);
|
||||
|
@ -3,9 +3,9 @@ var assert = chai.assert;
|
||||
var web3 = require('../../index');
|
||||
var FakeHttpProvider = require('./FakeHttpProvider');
|
||||
|
||||
var runTests = function (method, tests) {
|
||||
var runTests = function (obj, method, tests) {
|
||||
|
||||
describe('eth', function () {
|
||||
describe(obj, function () {
|
||||
describe(method, function () {
|
||||
tests.forEach(function (test, index) {
|
||||
it('sync test: ' + index, function () {
|
||||
@ -21,7 +21,7 @@ var runTests = function (method, tests) {
|
||||
});
|
||||
|
||||
// when
|
||||
var result = web3.eth[method].apply(null, test.args.slice(0));
|
||||
var result = web3[obj][method].apply(null, test.args.slice(0));
|
||||
|
||||
// then
|
||||
assert.deepEqual(test.formattedResult, result);
|
||||
@ -47,7 +47,7 @@ var runTests = function (method, tests) {
|
||||
args.push(callback);
|
||||
|
||||
// when
|
||||
web3.eth[method].apply(null, args);
|
||||
web3[obj][method].apply(null, args);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
38
test/net.listening.js
Normal file
38
test/net.listening.js
Normal file
@ -0,0 +1,38 @@
|
||||
var chai = require('chai');
|
||||
var assert = chai.assert;
|
||||
var web3 = require('../index');
|
||||
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
|
||||
|
||||
var method = 'listening';
|
||||
|
||||
var tests = [{
|
||||
result: true,
|
||||
formattedResult: true,
|
||||
call: 'net_'+ method
|
||||
}];
|
||||
|
||||
describe('net', function () {
|
||||
describe(method, function () {
|
||||
tests.forEach(function (test, index) {
|
||||
it('property test: ' + index, function () {
|
||||
|
||||
// given
|
||||
var provider = new FakeHttpProvider();
|
||||
web3.setProvider(provider);
|
||||
provider.injectResult(test.result);
|
||||
provider.injectValidation(function (payload) {
|
||||
assert.equal(payload.jsonrpc, '2.0');
|
||||
assert.equal(payload.method, test.call);
|
||||
assert.deepEqual(payload.params, []);
|
||||
});
|
||||
|
||||
// when
|
||||
var result = web3.net[method];
|
||||
|
||||
// then
|
||||
assert.deepEqual(test.formattedResult, result);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
38
test/net.peerCount.js
Normal file
38
test/net.peerCount.js
Normal file
@ -0,0 +1,38 @@
|
||||
var chai = require('chai');
|
||||
var assert = chai.assert;
|
||||
var web3 = require('../index');
|
||||
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
|
||||
|
||||
var method = 'peerCount';
|
||||
|
||||
var tests = [{
|
||||
result: '0xf',
|
||||
formattedResult: 15,
|
||||
call: 'net_'+ method
|
||||
}];
|
||||
|
||||
describe('net', function () {
|
||||
describe(method, function () {
|
||||
tests.forEach(function (test, index) {
|
||||
it('property test: ' + index, function () {
|
||||
|
||||
// given
|
||||
var provider = new FakeHttpProvider();
|
||||
web3.setProvider(provider);
|
||||
provider.injectResult(test.result);
|
||||
provider.injectValidation(function (payload) {
|
||||
assert.equal(payload.jsonrpc, '2.0');
|
||||
assert.equal(payload.method, test.call);
|
||||
assert.deepEqual(payload.params, []);
|
||||
});
|
||||
|
||||
// when
|
||||
var result = web3.net[method];
|
||||
|
||||
// then
|
||||
assert.deepEqual(test.formattedResult, result);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
46
test/shh.filter.js
Normal file
46
test/shh.filter.js
Normal file
@ -0,0 +1,46 @@
|
||||
var chai = require('chai');
|
||||
var web3 = require('../index');
|
||||
var assert = chai.assert;
|
||||
var FakeHttpProvider = require('./helpers/FakeHttpProvider');
|
||||
|
||||
var method = 'filter';
|
||||
|
||||
|
||||
var tests = [{
|
||||
args: [{
|
||||
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
|
||||
topics: ['0x324f5435', '0x564b4566f3453']
|
||||
}],
|
||||
formattedArgs: [{
|
||||
to: '0x47d33b27bb249a2dbab4c0612bf9caf4c1950855',
|
||||
topics: ['0x324f5435', '0x564b4566f3453']
|
||||
}],
|
||||
result: '0xf',
|
||||
formattedResult: '0xf',
|
||||
call: 'shh_newFilter'
|
||||
}];
|
||||
|
||||
describe('shh', function () {
|
||||
describe(method, function () {
|
||||
tests.forEach(function (test, index) {
|
||||
it('property test: ' + index, function () {
|
||||
|
||||
// given
|
||||
var provider = new FakeHttpProvider();
|
||||
web3.setProvider(provider);
|
||||
provider.injectResult(test.result);
|
||||
provider.injectValidation(function (payload) {
|
||||
assert.equal(payload.jsonrpc, '2.0');
|
||||
assert.equal(payload.method, test.call);
|
||||
assert.deepEqual(payload.params, test.formattedArgs);
|
||||
});
|
||||
|
||||
// call
|
||||
web3.shh[method].apply(null, test.args);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
17
test/shh.hasIdentity.js
Normal file
17
test/shh.hasIdentity.js
Normal file
@ -0,0 +1,17 @@
|
||||
var chai = require('chai');
|
||||
var web3 = require('../index');
|
||||
var BigNumber = require('bignumber.js');
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user