From b6058a837f9a90bd2973e4be54f0eab85e85674e Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 8 Jan 2015 19:59:03 +0100 Subject: [PATCH] methods existance tests in progress --- test/db.methods.js | 18 ++++++++++++++++ test/eth.methods.js | 42 +++++++++++++++++++++++++++++++++++++ test/methods.js | 49 -------------------------------------------- test/shh.methods.js | 19 +++++++++++++++++ test/utils.js | 15 ++++++++++++++ test/web3.methods.js | 18 ++++++++++++++++ 6 files changed, 112 insertions(+), 49 deletions(-) create mode 100644 test/db.methods.js create mode 100644 test/eth.methods.js delete mode 100644 test/methods.js create mode 100644 test/shh.methods.js create mode 100644 test/utils.js create mode 100644 test/web3.methods.js diff --git a/test/db.methods.js b/test/db.methods.js new file mode 100644 index 000000000..b4abfc4d7 --- /dev/null +++ b/test/db.methods.js @@ -0,0 +1,18 @@ +require('es6-promise').polyfill(); + +var assert = require('assert'); +var web3 = require('../index.js'); +var u = require('./utils.js'); +web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider + +describe('web3', function() { + describe('db', function() { + it('should have all methods implemented', function() { + u.methodExists(web3.db, 'put'); + u.methodExists(web3.db, 'get'); + u.methodExists(web3.db, 'putString'); + u.methodExists(web3.db, 'getString'); + }); + }); +}); + diff --git a/test/eth.methods.js b/test/eth.methods.js new file mode 100644 index 000000000..7190b27d2 --- /dev/null +++ b/test/eth.methods.js @@ -0,0 +1,42 @@ +require('es6-promise').polyfill(); + +var assert = require('assert'); +var web3 = require('../index.js'); +var u = require('./utils.js'); +web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider + +describe('web3', function() { + describe('eth', function() { + it('should have all methods implemented', function() { + u.methodExists(web3.eth, 'balanceAt'); + u.methodExists(web3.eth, 'stateAt'); + u.methodExists(web3.eth, 'storageAt'); + u.methodExists(web3.eth, 'countAt'); + u.methodExists(web3.eth, 'codeAt'); + u.methodExists(web3.eth, 'transact'); + u.methodExists(web3.eth, 'call'); + u.methodExists(web3.eth, 'block'); + u.methodExists(web3.eth, 'transaction'); + u.methodExists(web3.eth, 'uncle'); + u.methodExists(web3.eth, 'compilers'); + u.methodExists(web3.eth, 'lll'); + u.methodExists(web3.eth, 'solidity'); + u.methodExists(web3.eth, 'serpent'); + u.methodExists(web3.eth, 'logs'); + }); + + it('should have all properties implemented', function () { + u.propertyExists(web3.eth, 'coinbase'); + u.propertyExists(web3.eth, 'listening'); + u.propertyExists(web3.eth, 'mining'); + u.propertyExists(web3.eth, 'gasPrice'); + u.propertyExists(web3.eth, 'account'); + u.propertyExists(web3.eth, 'accounts'); + u.propertyExists(web3.eth, 'peerCount'); + u.propertyExists(web3.eth, 'defaultBlock'); + u.propertyExists(web3.eth, 'number'); + }); + }); +}); + + diff --git a/test/methods.js b/test/methods.js deleted file mode 100644 index 54d96b486..000000000 --- a/test/methods.js +++ /dev/null @@ -1,49 +0,0 @@ -require('es6-promise').polyfill(); - -var assert = require('assert'); -var web3 = require('../index.js'); -web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider - -var methodExists = function (object, method) { - assert.equal('function', typeof object[method], 'method ' + method + ' is not implemented'); -}; - -var propertyExists = function (object, property) { - assert.equal('object', typeof object[property], 'property ' + property + ' is not implemented'); -}; - -describe('web3', function() { - describe('eth', function() { - it('should have all methods implemented', function() { - methodExists(web3.eth, 'balanceAt'); - methodExists(web3.eth, 'stateAt'); - methodExists(web3.eth, 'storageAt'); - methodExists(web3.eth, 'countAt'); - methodExists(web3.eth, 'codeAt'); - methodExists(web3.eth, 'transact'); - methodExists(web3.eth, 'call'); - methodExists(web3.eth, 'block'); - methodExists(web3.eth, 'transaction'); - methodExists(web3.eth, 'uncle'); - methodExists(web3.eth, 'compilers'); - methodExists(web3.eth, 'lll'); - methodExists(web3.eth, 'solidity'); - methodExists(web3.eth, 'serpent'); - methodExists(web3.eth, 'logs'); - }); - - it('should have all properties implemented', function () { - propertyExists(web3.eth, 'coinbase'); - propertyExists(web3.eth, 'listening'); - propertyExists(web3.eth, 'mining'); - propertyExists(web3.eth, 'gasPrice'); - propertyExists(web3.eth, 'account'); - propertyExists(web3.eth, 'accounts'); - propertyExists(web3.eth, 'peerCount'); - propertyExists(web3.eth, 'defaultBlock'); - propertyExists(web3.eth, 'number'); - }); - }); -}) - - diff --git a/test/shh.methods.js b/test/shh.methods.js new file mode 100644 index 000000000..08f573a3c --- /dev/null +++ b/test/shh.methods.js @@ -0,0 +1,19 @@ +require('es6-promise').polyfill(); + +var assert = require('assert'); +var web3 = require('../index.js'); +var u = require('./utils.js'); +web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider + +describe('web3', function() { + describe('shh', function() { + it('should have all methods implemented', function() { + u.methodExists(web3.shh, 'post'); + u.methodExists(web3.shh, 'newIdentity'); + u.methodExists(web3.shh, 'haveIdentity'); + u.methodExists(web3.shh, 'newGroup'); + u.methodExists(web3.shh, 'addToGroup'); + }); + }); +}); + diff --git a/test/utils.js b/test/utils.js new file mode 100644 index 000000000..4c508da67 --- /dev/null +++ b/test/utils.js @@ -0,0 +1,15 @@ +var assert = require('assert'); + +var methodExists = function (object, method) { + assert.equal('function', typeof object[method], 'method ' + method + ' is not implemented'); +}; + +var propertyExists = function (object, property) { + assert.equal('object', typeof object[property], 'property ' + property + ' is not implemented'); +}; + +module.exports = { + methodExists: methodExists, + propertyExists: propertyExists +}; + diff --git a/test/web3.methods.js b/test/web3.methods.js new file mode 100644 index 000000000..a7e020978 --- /dev/null +++ b/test/web3.methods.js @@ -0,0 +1,18 @@ +require('es6-promise').polyfill(); + +var assert = require('assert'); +var web3 = require('../index.js'); +var u = require('./utils.js'); +web3.setProvider(new web3.providers.WebSocketProvider('http://localhost:8080')); // TODO: create some mock provider + +describe('web3', function() { + it('should have all methods implemented', function() { + u.methodExists(web3, 'sha3'); + u.methodExists(web3, 'toAscii'); + u.methodExists(web3, 'fromAscii'); + u.methodExists(web3, 'toFixed'); + u.methodExists(web3, 'fromFixed'); + u.methodExists(web3, 'offset'); + }); +}); +