From bf641ef954aecbb3428b269cf47b54bc4e8f6454 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 19 Feb 2014 14:25:14 -0300 Subject: [PATCH] refactor tests --- bitcore.js | 9 +++++---- test/test.base58.js | 45 --------------------------------------------- test/test.misc.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 49 deletions(-) delete mode 100644 test/test.base58.js diff --git a/bitcore.js b/bitcore.js index ac10d13fe..513948a73 100644 --- a/bitcore.js +++ b/bitcore.js @@ -5,14 +5,15 @@ module.exports.bignum = require('bignum'); module.exports.base58 = require('base58-native'); -module.exports.EncodedData = require('./util/EncodedData'); -module.exports.VersionedData = require('./util/VersionedData'); -module.exports.Address = require('./Address'); +module.exports.buffertools = require('buffertools'); module.exports.config = require('./config'); module.exports.log = require('./util/log'); module.exports.networks = require('./networks'); -module.exports.Opcode = require('./Opcode'); module.exports.util = require('./util/util'); +module.exports.EncodedData = require('./util/EncodedData'); +module.exports.VersionedData = require('./util/VersionedData'); +module.exports.Address = require('./Address'); +module.exports.Opcode = require('./Opcode'); module.exports.Script = require('./Script'); module.exports.SINKey = require('./SINKey'); module.exports.Transaction = require('./Transaction'); diff --git a/test/test.base58.js b/test/test.base58.js deleted file mode 100644 index 54d57eb13..000000000 --- a/test/test.base58.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -var chai = require('chai'); -var bitcore = require('../bitcore'); - -var expect = chai.expect; -var should = chai.should(); - -var bignum = bitcore.bignum; -var base58 = bitcore.base58; -var base58Check = base58.base58Check; - -describe('bignum module basics', function() { - it('should initialze the main object', function() { - should.exist(bitcore.bignum); - }); - it('should create a bignum from string', function() { - var n = bignum('9832087987979879879879879879879879879879879879'); - should.exist(n); - }); - it('should perform basic math operations', function() { - var b = bignum('782910138827292261791972728324982') - .sub('182373273283402171237474774728373') - .div(13); - b.toNumber().should.equal(46195143503376160811884457968969); - }); -}); - - -describe('base58 module', function() { - it('should initialze the main object', function() { - should.exist(bitcore.base58); - }); - it('should obtain the same string in base58 roundtrip', function() { - var m = 'mqqa8xSMVDyf9QxihGnPtap6Mh6qemUkcu'; - base58.encode(base58.decode(m)).should.equal(m); - }); - it('should obtain the same string in base58Check roundtrip', function() { - var m = '1QCJj1gPZKx2EwzGo9Ri8mMBs39STvDYcv'; - base58Check.encode(base58Check.decode(m)).should.equal(m); - }); -}); - - - diff --git a/test/test.misc.js b/test/test.misc.js index ab4364ade..b9e090ab6 100644 --- a/test/test.misc.js +++ b/test/test.misc.js @@ -5,6 +5,10 @@ var bitcore = require('../bitcore'); var should = chai.should(); +var bignum = bitcore.bignum; +var base58 = bitcore.base58; +var base58Check = base58.base58Check; + describe('Miscelaneous stuff', function() { it('should initialze the config object', function() { should.exist(bitcore.config); @@ -16,9 +20,38 @@ describe('Miscelaneous stuff', function() { should.exist(bitcore.util); }); + + // bignum + it('should initialze the bignum object', function() { + should.exist(bitcore.bignum); + }); + it('should create a bignum from string', function() { + var n = bignum('9832087987979879879879879879879879879879879879'); + should.exist(n); + }); + it('should perform basic math operations for bignum', function() { + var b = bignum('782910138827292261791972728324982') + .sub('182373273283402171237474774728373') + .div(13); + b.toNumber().should.equal(46195143503376160811884457968969); + }); + + // base58 + it('should initialze the base58 object', function() { + should.exist(bitcore.base58); + }); + it('should obtain the same string in base58 roundtrip', function() { + var m = 'mqqa8xSMVDyf9QxihGnPtap6Mh6qemUkcu'; + base58.encode(base58.decode(m)).should.equal(m); + }); + it('should obtain the same string in base58Check roundtrip', function() { + var m = '1QCJj1gPZKx2EwzGo9Ri8mMBs39STvDYcv'; + base58Check.encode(base58Check.decode(m)).should.equal(m); + }); }); +