diff --git a/lib/web3/eth.getTransaction.js b/lib/web3/eth.getTransaction.js index 2a1bdda..fb833ed 100644 --- a/lib/web3/eth.getTransaction.js +++ b/lib/web3/eth.getTransaction.js @@ -42,5 +42,5 @@ var tests = [{ call: 'eth_'+ method + 'ByHash' }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getBalance.js b/test/eth.getBalance.js index e9b2b15..9e9d110 100644 --- a/test/eth.getBalance.js +++ b/test/eth.getBalance.js @@ -30,5 +30,5 @@ var tests = [{ call: 'eth_'+ method }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getBlock.js b/test/eth.getBlock.js index f836c12..539e433 100644 --- a/test/eth.getBlock.js +++ b/test/eth.getBlock.js @@ -135,5 +135,5 @@ var tests = [{ call: 'eth_'+ method + 'ByNumber' }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getBlockTransactionCount.js b/test/eth.getBlockTransactionCount.js index 43e0b9b..a7901e3 100644 --- a/test/eth.getBlockTransactionCount.js +++ b/test/eth.getBlockTransactionCount.js @@ -19,5 +19,5 @@ var tests = [{ call: 'eth_getBlockTransactionCountByNumber' }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getBlockUncleCount.js b/test/eth.getBlockUncleCount.js index 49ad7b7..4cdeb08 100644 --- a/test/eth.getBlockUncleCount.js +++ b/test/eth.getBlockUncleCount.js @@ -18,4 +18,4 @@ var tests = [{ call: 'eth_getUncleCountByBlockNumber' }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getCode.js b/test/eth.getCode.js index d774e5d..fc4f5b8 100644 --- a/test/eth.getCode.js +++ b/test/eth.getCode.js @@ -19,5 +19,5 @@ var tests = [{ call: 'eth_'+ method }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getCompilers.js b/test/eth.getCompilers.js index 2074f0c..ab426b2 100644 --- a/test/eth.getCompilers.js +++ b/test/eth.getCompilers.js @@ -19,5 +19,5 @@ var tests = [{ call: 'eth_'+ method }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getStorageAt.js b/test/eth.getStorageAt.js index d6738bc..539b535 100644 --- a/test/eth.getStorageAt.js +++ b/test/eth.getStorageAt.js @@ -25,5 +25,5 @@ var tests = [{ call: 'eth_'+ method }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getTransactionFromBlock.js b/test/eth.getTransactionFromBlock.js index 3e24936..7b59a3b 100644 --- a/test/eth.getTransactionFromBlock.js +++ b/test/eth.getTransactionFromBlock.js @@ -48,5 +48,5 @@ var tests = [{ call: 'eth_getTransactionByBlockNumberAndIndex' }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/eth.getUncle.js b/test/eth.getUncle.js index 91912ea..1118653 100644 --- a/test/eth.getUncle.js +++ b/test/eth.getUncle.js @@ -136,4 +136,4 @@ var tests = [{ call: 'eth_getUncleByBlockNumberAndIndex' }]; -testMethod.runTests(method, tests); +testMethod.runTests('eth', method, tests); diff --git a/test/helpers/test.method.js b/test/helpers/test.method.js index 21a1def..2d45a7b 100644 --- a/test/helpers/test.method.js +++ b/test/helpers/test.method.js @@ -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); }); }); }); diff --git a/test/net.listening.js b/test/net.listening.js new file mode 100644 index 0000000..72a0a0a --- /dev/null +++ b/test/net.listening.js @@ -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); + }); + }); + }); +}); + diff --git a/test/net.peerCount.js b/test/net.peerCount.js new file mode 100644 index 0000000..c031050 --- /dev/null +++ b/test/net.peerCount.js @@ -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); + }); + }); + }); +}); + diff --git a/test/shh.filter.js b/test/shh.filter.js new file mode 100644 index 0000000..1684adf --- /dev/null +++ b/test/shh.filter.js @@ -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); + + }); + }); + }); +}); + + diff --git a/test/shh.hasIdentity.js b/test/shh.hasIdentity.js new file mode 100644 index 0000000..59284cd --- /dev/null +++ b/test/shh.hasIdentity.js @@ -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); +