bitcoinjs-lib/test/crypto.js

25 lines
661 B
JavaScript
Raw Normal View History

2015-02-23 00:36:57 +01:00
/* global describe, it */
2014-04-08 15:39:22 +02:00
var assert = require('assert')
var bcrypto = require('../src/crypto')
2014-05-13 08:35:07 +02:00
2014-09-20 03:20:55 +02:00
var fixtures = require('./fixtures/crypto')
2014-04-08 15:39:22 +02:00
2015-02-23 00:36:57 +01:00
describe('Crypto', function () {
2014-09-20 03:20:55 +02:00
['hash160', 'hash256', 'ripemd160', 'sha1', 'sha256'].forEach(function (algorithm) {
describe(algorithm, function () {
fixtures.valid.forEach(function (f) {
var fn = bcrypto[algorithm]
2014-09-20 03:20:55 +02:00
var expected = f[algorithm]
it('returns ' + expected + ' for ' + f.hex, function () {
var data = new Buffer(f.hex, 'hex')
var actual = fn(data).toString('hex')
2015-05-07 03:29:20 +02:00
assert.strictEqual(actual, expected)
2014-09-20 03:20:55 +02:00
})
})
})
})
2014-04-08 15:39:22 +02:00
})