bitcoinjs-lib/test/crypto.js

24 lines
651 B
JavaScript
Raw 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
describe('crypto', () => {
['hash160', 'hash256', 'ripemd160', 'sha1', 'sha256'].forEach(algorithm => {
describe(algorithm, () => {
fixtures.forEach(f => {
const fn = bcrypto[algorithm]
const expected = f[algorithm]
2014-09-20 03:20:55 +02:00
it('returns ' + expected + ' for ' + f.hex, () => {
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
})