bitcoinjs-lib/test/crypto.js

24 lines
685 B
JavaScript
Raw Permalink Normal View History

2018-07-23 09:45:01 +02:00
const { describe, it } = require('mocha')
2018-06-25 08:25:12 +02:00
const assert = require('assert')
const bcrypto = require('../src/crypto')
2014-05-13 08:35:07 +02:00
2018-06-25 08:25:12 +02:00
const 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) {
const fn = bcrypto[algorithm]
const expected = f[algorithm]
2014-09-20 03:20:55 +02:00
it('returns ' + expected + ' for ' + f.hex, function () {
const data = Buffer.from(f.hex, 'hex')
const actual = fn(data).toString('hex')
2014-09-20 03:20:55 +02:00
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
})