Merge pull request from dcousens/b58

BS58 module
This commit is contained in:
Kyle Drake 2014-06-26 18:26:54 -04:00
commit 6596ca1ec8
7 changed files with 7 additions and 120 deletions

View file

@ -1,36 +0,0 @@
var assert = require('assert')
var base58 = require('../src/base58')
var fixtures = require('./fixtures/base58.json')
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(actual.toString('hex'), expected)
})
})
fixtures.invalid.forEach(function(f) {
it('throws on ' + f.description, function() {
assert.throws(function() {
base58.decode(f.string)
}, /Non-base58 character/)
})
})
})
describe('encode', function() {
it('can encode Bitcoin core test data', function() {
fixtures.valid.forEach(function(f) {
var actual = base58.encode(new Buffer(f.hex, 'hex'))
var expected = f.string.trim()
assert.strictEqual(actual, expected)
})
})
})
})

View file

@ -3,16 +3,13 @@ var base58check = require('../src/base58check')
var fixtures = require('./fixtures/base58check.json')
function h2b(h) { return new Buffer(h, 'hex') }
describe('base58check', function() {
describe('decode', function() {
fixtures.valid.forEach(function(f) {
it('can decode ' + f.string, function() {
var actual = base58check.decode(f.string)
var expected = h2b(f.payload)
var actual = base58check.decode(f.string).toString('hex')
assert.deepEqual(actual, expected)
assert.equal(actual, f.payload)
})
})
@ -28,10 +25,9 @@ describe('base58check', function() {
describe('encode', function() {
fixtures.valid.forEach(function(f) {
it('can encode ' + f.string, function() {
var actual = base58check.encode(h2b(f.payload))
var expected = f.string
var actual = base58check.encode(new Buffer(f.payload, 'hex'))
assert.strictEqual(actual, expected)
assert.strictEqual(actual, f.string)
})
})
})

View file

@ -1,5 +1,5 @@
var assert = require('assert')
var base58 = require('../src/base58')
var base58 = require('bs58')
var base58check = require('../src/base58check')
var networks = require('../src/networks')