Updates test fixtures to use bitcoin core test data
This commit is contained in:
parent
540b70ccca
commit
c178804356
4 changed files with 571 additions and 199 deletions
test
|
@ -1,27 +1,37 @@
|
|||
var assert = require('assert')
|
||||
var base58 = require('../').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('decodes the test vectors', function() {
|
||||
it('can decode Bitcoin core test data', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
var actual = base58.decode(f.encoded.string)
|
||||
var expected = f.encoded.hex
|
||||
var actual = base58.decode(f.string)
|
||||
var expected = f.hex
|
||||
|
||||
assert.equal(actual.toString('hex'), expected)
|
||||
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('encodes the test vectors', function() {
|
||||
it('can encode Bitcoin core test data', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
var actual = base58.encode(new Buffer(f.encoded.hex, 'hex'))
|
||||
var expected = f.encoded.string
|
||||
var actual = base58.encode(h2b(f.hex))
|
||||
var expected = f.string.trim()
|
||||
|
||||
assert.equal(actual, expected)
|
||||
assert.strictEqual(actual, expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue