bitcoinjs-lib/test/convert.js

28 lines
759 B
JavaScript
Raw Normal View History

2014-03-31 05:47:47 +02:00
var assert = require('assert')
var convert = require('../src/convert')
var fixtures = require('./fixtures/convert')
2014-03-31 05:47:47 +02:00
describe('convert', function() {
describe('bufferToWordArray', function() {
fixtures.valid.forEach(function(f) {
it('converts ' + f.hex + ' correctly', function() {
var buffer = new Buffer(f.hex, 'hex')
var result = convert.bufferToWordArray(buffer)
assert.deepEqual(result, f.wordArray)
})
})
})
describe('wordArrayToBuffer', function() {
fixtures.valid.forEach(function(f) {
it('converts to ' + f.hex + ' correctly', function() {
var resultHex = convert.wordArrayToBuffer(f.wordArray).toString('hex')
assert.deepEqual(resultHex, f.hex)
2014-03-26 08:30:17 +01:00
})
})
2014-03-31 05:47:47 +02:00
})
})