tests: always use for, it testing style
This commit is contained in:
parent
61b4216afb
commit
f20ffec8b3
4 changed files with 20 additions and 13 deletions
|
@ -13,8 +13,8 @@ var fixtures = require('./fixtures/ecdsa.json')
|
|||
|
||||
describe('ecdsa', function() {
|
||||
describe('deterministicGenerateK', function() {
|
||||
it('matches the test vectors', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('determines k for \"' + f.message + '\"', function() {
|
||||
var d = BigInteger.fromHex(f.d)
|
||||
var h1 = crypto.sha256(f.message)
|
||||
|
||||
|
@ -40,8 +40,8 @@ describe('ecdsa', function() {
|
|||
})
|
||||
|
||||
describe('sign', function() {
|
||||
it('matches the test vectors', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('produces a deterministic signature for \"' + f.message + '\"', function() {
|
||||
var d = BigInteger.fromHex(f.d)
|
||||
var hash = crypto.sha256(f.message)
|
||||
var signature = ecdsa.sign(ecparams, hash, d)
|
||||
|
@ -62,8 +62,8 @@ describe('ecdsa', function() {
|
|||
})
|
||||
|
||||
describe('verifyRaw', function() {
|
||||
it('verifies valid signatures', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('verifies a valid signature for \"' + f.message + '\"', function() {
|
||||
var d = BigInteger.fromHex(f.d)
|
||||
var Q = ecparams.getG().multiply(d)
|
||||
|
||||
|
|
9
test/fixtures/script.json
vendored
9
test/fixtures/script.json
vendored
|
@ -6,6 +6,7 @@
|
|||
"type": "pubkey",
|
||||
"hash": "26e645ab170255f2a0a82d29e48f35b14ae7c826",
|
||||
"pubKey": "031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95",
|
||||
"asm": "33 031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95 OP_CHECKSIG",
|
||||
"scriptPubKey": true
|
||||
},
|
||||
{
|
||||
|
@ -13,6 +14,7 @@
|
|||
"hex": "a914e8c300c87986efa84c37c0519929019ef86eb5b487",
|
||||
"type": "scripthash",
|
||||
"hash": "0ba47b56a573bab4b430ad6ed3ec79270e04b066",
|
||||
"asm": "OP_HASH160 20 e8c300c87986efa84c37c0519929019ef86eb5b4 OP_EQUAL",
|
||||
"scriptPubKey": true
|
||||
},
|
||||
{
|
||||
|
@ -20,6 +22,7 @@
|
|||
"hex": "76a9145a3acbc7bbcc97c5ff16f5909c9d7d3fadb293a888ac",
|
||||
"type": "pubkeyhash",
|
||||
"hash": "a5313f33d5c7b81674b35f7f3febc3522ef234db",
|
||||
"asm": "OP_DUP OP_HASH160 20 5a3acbc7bbcc97c5ff16f5909c9d7d3fadb293a8 OP_EQUALVERIFY OP_CHECKSIG",
|
||||
"scriptPubKey": true
|
||||
},
|
||||
{
|
||||
|
@ -27,6 +30,7 @@
|
|||
"hex": "48304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f30141040cd2d2ce17a1e9b2b3b2cb294d40eecf305a25b7e7bfdafae6bb2639f4ee399b3637706c3d377ec4ab781355add443ae864b134c5e523001c442186ea60f0eb8",
|
||||
"type": "pubkeyhash",
|
||||
"hash": "b9bac2a5c5c29bb27c382d41fa3d179c646c78fd",
|
||||
"asm": "72 304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301 65 040cd2d2ce17a1e9b2b3b2cb294d40eecf305a25b7e7bfdafae6bb2639f4ee399b3637706c3d377ec4ab781355add443ae864b134c5e523001c442186ea60f0eb8",
|
||||
"scriptPubKey": false
|
||||
},
|
||||
{
|
||||
|
@ -34,6 +38,7 @@
|
|||
"hex": "5121032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca330162102308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a52ae",
|
||||
"type": "multisig",
|
||||
"hash": "f1c98f0b74ecabcf78ae20dfa224bb6666051fbe",
|
||||
"asm": "OP_TRUE 33 032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca33016 33 02308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a OP_2 OP_CHECKMULTISIG",
|
||||
"scriptPubKey": true
|
||||
},
|
||||
{
|
||||
|
@ -41,6 +46,7 @@
|
|||
"hex":"6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
|
||||
"type": "nulldata",
|
||||
"hash": "ec88f016655477663455fe6a8e83508c348ea145",
|
||||
"asm": "OP_RETURN 38 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
|
||||
"scriptPubKey": true
|
||||
},
|
||||
{
|
||||
|
@ -48,14 +54,15 @@
|
|||
"hex": "aa206fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d619000000000087",
|
||||
"type": "nonstandard",
|
||||
"hash": "3823382e70d1930989813d3459988e0d7c2861d8",
|
||||
"asm": "OP_HASH256 32 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL",
|
||||
"scriptPubKey": true
|
||||
},
|
||||
{
|
||||
"description": "Invalid multisig script",
|
||||
"asm": "0 0 0 OP_CHECKMULTISIG",
|
||||
"hex": "000000ae",
|
||||
"type": "nonstandard",
|
||||
"hash": "62ede8963f9387544935f168745262f703dab1fb",
|
||||
"asm": "0 0 0 OP_CHECKMULTISIG",
|
||||
"scriptPubKey": true
|
||||
}
|
||||
]
|
||||
|
|
|
@ -9,8 +9,8 @@ var fixtures = require('./fixtures/message.json')
|
|||
|
||||
describe('Message', function() {
|
||||
describe('magicHash', function() {
|
||||
it('matches the test vectors', function() {
|
||||
fixtures.valid.magicHash.forEach(function(f) {
|
||||
it('produces the correct magicHash for \"' + f.message + '\" (' + f.network + ')', function() {
|
||||
var network = networks[f.network]
|
||||
var actual = Message.magicHash(f.message, network)
|
||||
|
||||
|
@ -20,8 +20,8 @@ describe('Message', function() {
|
|||
})
|
||||
|
||||
describe('verify', function() {
|
||||
it('verifies a valid signature', function() {
|
||||
fixtures.valid.verify.forEach(function(f) {
|
||||
it('verifies a valid signature for \"' + f.message + '\" (' + f.network + ')', function() {
|
||||
var network = networks[f.network]
|
||||
|
||||
var signature = new Buffer(f.signature, 'base64')
|
||||
|
|
|
@ -36,8 +36,8 @@ describe('Script', function() {
|
|||
})
|
||||
|
||||
describe('getHash', function() {
|
||||
it('matches the test vectors', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('produces a HASH160 of \"' + f.asm + '\"', function() {
|
||||
var script = Script.fromHex(f.hex)
|
||||
|
||||
assert.equal(script.getHash().toString('hex'), f.hash)
|
||||
|
|
Loading…
Reference in a new issue