100% coverage of wallet.js

This commit is contained in:
lms 2014-04-01 21:03:41 +02:00
parent 4f578dd5c1
commit b79ccb2c0c
2 changed files with 11 additions and 7 deletions

View file

@ -3,7 +3,7 @@ var Transaction = require('./transaction').Transaction
var HDNode = require('./hdwallet.js') var HDNode = require('./hdwallet.js')
var rng = require('secure-random') var rng = require('secure-random')
var Wallet = function (seed, options) { function Wallet(seed, options) {
if (!(this instanceof Wallet)) { return new Wallet(seed, options); } if (!(this instanceof Wallet)) { return new Wallet(seed, options); }
var options = options || {} var options = options || {}
@ -132,7 +132,7 @@ var Wallet = function (seed, options) {
if (missingField) { if (missingField) {
var message = [ var message = [
'Invalid unspent output: key', field, 'is missing.', 'Invalid unspent output: key', missingField, 'is missing.',
'A valid unspent output must contain' 'A valid unspent output must contain'
] ]
message.push(requiredKeys.join(', ')) message.push(requiredKeys.join(', '))

View file

@ -22,6 +22,10 @@ describe('Wallet', function() {
}) })
describe('constructor', function() { describe('constructor', function() {
it('should be ok to call without new', function() {
assert.ok(Wallet(seed) instanceof Wallet)
})
it('defaults to Bitcoin mainnet', function() { it('defaults to Bitcoin mainnet', function() {
assert.equal(wallet.getMasterKey().network, 'mainnet') assert.equal(wallet.getMasterKey().network, 'mainnet')
}) })