Adds magicHash test fixtures

This commit is contained in:
Daniel Cousens 2014-04-21 21:24:58 +10:00
parent 69823552c3
commit dd049fc764
2 changed files with 25 additions and 0 deletions

12
test/fixtures/message.js vendored Normal file
View file

@ -0,0 +1,12 @@
module.exports = {
magicHash: [
{
message: '',
hash256: '80e795d4a4caadd7047af389d9f7f220562feb6196032e2131e10563352c4bcc'
},
{
message: 'Vires is Numeris',
hash256: 'f8a5affbef4a3241b19067aa694562f64f513310817297089a8929a930f4f933'
}
]
}

View file

@ -3,6 +3,8 @@ var ECKey = require('../src/eckey').ECKey
var Message = require('../').Message
var network = require('../').network
var fixtures = require('./fixtures/message')
describe('Message', function() {
var msg
@ -10,6 +12,17 @@ describe('Message', function() {
msg = 'vires is numeris'
})
describe('magicHash', function() {
it('matches the test vectors', function() {
fixtures.magicHash.forEach(function(f) {
var actual = Message.magicHash(f.message)
var expected = f.hash256
assert.equal(actual.toString('hex'), expected)
})
})
})
describe('verify', function() {
var addr, sig, caddr, csig