2015-02-23 00:36:57 +01:00
|
|
|
/* global describe, it */
|
|
|
|
|
2014-04-08 15:39:22 +02:00
|
|
|
var assert = require('assert')
|
2015-08-20 05:37:19 +02:00
|
|
|
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) {
|
2015-08-20 05:37:19 +02:00
|
|
|
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-05-10 01:55:55 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2014-04-08 15:39:22 +02:00
|
|
|
})
|