bitcoinjs-lib/test/crypto.js

25 lines
656 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-09-08 08:00:16 +02:00
describe('crypto', function () {
2014-09-20 03:20:55 +02:00
['hash160', 'hash256', 'ripemd160', 'sha1', 'sha256'].forEach(function (algorithm) {
describe(algorithm, function () {
2015-09-08 08:00:16 +02:00
fixtures.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 () {
2017-04-19 09:39:16 +02:00
var data = Buffer.from(f.hex, 'hex')
2014-09-20 03:20:55 +02:00
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
})