bitcoinjs-lib/test/base58.js
Daniel Cousens 6c0eebe94b tests: use filepaths directly
After a long IRC discussion, it was decided that the use of direct
filepaths instead of the module is a more pure form of testing ,
although it may provide less overall coverage than the mixed integration
style imports used previously.

This will need to be remedied by further integration testing in
/test/integration.
2014-05-13 18:05:56 +10:00

38 lines
1,015 B
JavaScript

var assert = require('assert')
var base58 = require('../src/base58')
var fixtures = require('./fixtures/base58')
function b2h(b) { return new Buffer(b).toString('hex') }
function h2b(h) { return new Buffer(h, 'hex') }
describe('base58', function() {
describe('decode', function() {
it('can decode Bitcoin core test data', function() {
fixtures.valid.forEach(function(f) {
var actual = base58.decode(f.string)
var expected = f.hex
assert.strictEqual(b2h(actual), expected)
})
})
fixtures.invalid.forEach(function(f) {
it('throws on ' + f.description, function() {
assert.throws(function() {
base58.decode(f.string)
})
})
})
})
describe('encode', function() {
it('can encode Bitcoin core test data', function() {
fixtures.valid.forEach(function(f) {
var actual = base58.encode(h2b(f.hex))
var expected = f.string.trim()
assert.strictEqual(actual, expected)
})
})
})
})