use standardjs formatting
This commit is contained in:
parent
09d8e440de
commit
399803affa
41 changed files with 1252 additions and 1177 deletions
test
|
@ -1,3 +1,5 @@
|
|||
/* global describe, it */
|
||||
|
||||
var assert = require('assert')
|
||||
|
||||
var BigInteger = require('bigi')
|
||||
|
@ -5,13 +7,13 @@ var ECSignature = require('../src/ecsignature')
|
|||
|
||||
var fixtures = require('./fixtures/ecsignature.json')
|
||||
|
||||
describe('ECSignature', function() {
|
||||
describe('toCompact', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('exports ' + f.compact.hex + ' correctly', function() {
|
||||
describe('ECSignature', function () {
|
||||
describe('toCompact', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('exports ' + f.compact.hex + ' correctly', function () {
|
||||
var signature = new ECSignature(
|
||||
new BigInteger(f.signature.r),
|
||||
new BigInteger(f.signature.s)
|
||||
new BigInteger(f.signature.r),
|
||||
new BigInteger(f.signature.s)
|
||||
)
|
||||
|
||||
var buffer = signature.toCompact(f.compact.i, f.compact.compressed)
|
||||
|
@ -20,9 +22,9 @@ describe('ECSignature', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('parseCompact', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('imports ' + f.compact.hex + ' correctly', function() {
|
||||
describe('parseCompact', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('imports ' + f.compact.hex + ' correctly', function () {
|
||||
var buffer = new Buffer(f.compact.hex, 'hex')
|
||||
var parsed = ECSignature.parseCompact(buffer)
|
||||
|
||||
|
@ -33,23 +35,23 @@ describe('ECSignature', function() {
|
|||
})
|
||||
})
|
||||
|
||||
fixtures.invalid.compact.forEach(function(f) {
|
||||
it('throws on ' + f.hex, function() {
|
||||
fixtures.invalid.compact.forEach(function (f) {
|
||||
it('throws on ' + f.hex, function () {
|
||||
var buffer = new Buffer(f.hex, 'hex')
|
||||
|
||||
assert.throws(function() {
|
||||
assert.throws(function () {
|
||||
ECSignature.parseCompact(buffer)
|
||||
}, new RegExp(f.exception))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('toDER', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('exports ' + f.DER + ' correctly', function() {
|
||||
describe('toDER', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('exports ' + f.DER + ' correctly', function () {
|
||||
var signature = new ECSignature(
|
||||
new BigInteger(f.signature.r),
|
||||
new BigInteger(f.signature.s)
|
||||
new BigInteger(f.signature.r),
|
||||
new BigInteger(f.signature.s)
|
||||
)
|
||||
|
||||
var DER = signature.toDER()
|
||||
|
@ -58,9 +60,9 @@ describe('ECSignature', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('fromDER', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('imports ' + f.DER + ' correctly', function() {
|
||||
describe('fromDER', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('imports ' + f.DER + ' correctly', function () {
|
||||
var buffer = new Buffer(f.DER, 'hex')
|
||||
var signature = ECSignature.fromDER(buffer)
|
||||
|
||||
|
@ -69,23 +71,23 @@ describe('ECSignature', function() {
|
|||
})
|
||||
})
|
||||
|
||||
fixtures.invalid.DER.forEach(function(f) {
|
||||
it('throws on ' + f.hex, function() {
|
||||
fixtures.invalid.DER.forEach(function (f) {
|
||||
it('throws on ' + f.hex, function () {
|
||||
var buffer = new Buffer(f.hex, 'hex')
|
||||
|
||||
assert.throws(function() {
|
||||
assert.throws(function () {
|
||||
ECSignature.fromDER(buffer)
|
||||
}, new RegExp(f.exception))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('toScriptSignature', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('exports ' + f.scriptSignature.hex + ' correctly', function() {
|
||||
describe('toScriptSignature', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('exports ' + f.scriptSignature.hex + ' correctly', function () {
|
||||
var signature = new ECSignature(
|
||||
new BigInteger(f.signature.r),
|
||||
new BigInteger(f.signature.s)
|
||||
new BigInteger(f.signature.r),
|
||||
new BigInteger(f.signature.s)
|
||||
)
|
||||
|
||||
var scriptSignature = signature.toScriptSignature(f.scriptSignature.hashType)
|
||||
|
@ -93,23 +95,23 @@ describe('ECSignature', function() {
|
|||
})
|
||||
})
|
||||
|
||||
fixtures.invalid.scriptSignature.forEach(function(f) {
|
||||
it('throws ' + f.exception, function() {
|
||||
fixtures.invalid.scriptSignature.forEach(function (f) {
|
||||
it('throws ' + f.exception, function () {
|
||||
var signature = new ECSignature(
|
||||
new BigInteger(f.signature.r),
|
||||
new BigInteger(f.signature.s)
|
||||
new BigInteger(f.signature.r),
|
||||
new BigInteger(f.signature.s)
|
||||
)
|
||||
|
||||
assert.throws(function() {
|
||||
assert.throws(function () {
|
||||
signature.toScriptSignature(f.hashType)
|
||||
}, new RegExp(f.exception))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('parseScriptSignature', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('imports ' + f.scriptSignature.hex + ' correctly', function() {
|
||||
describe('parseScriptSignature', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('imports ' + f.scriptSignature.hex + ' correctly', function () {
|
||||
var buffer = new Buffer(f.scriptSignature.hex, 'hex')
|
||||
var parsed = ECSignature.parseScriptSignature(buffer)
|
||||
|
||||
|
@ -119,11 +121,11 @@ describe('ECSignature', function() {
|
|||
})
|
||||
})
|
||||
|
||||
fixtures.invalid.scriptSignature.forEach(function(f) {
|
||||
it('throws on ' + f.hex, function() {
|
||||
fixtures.invalid.scriptSignature.forEach(function (f) {
|
||||
it('throws on ' + f.hex, function () {
|
||||
var buffer = new Buffer(f.hex, 'hex')
|
||||
|
||||
assert.throws(function() {
|
||||
assert.throws(function () {
|
||||
ECSignature.parseScriptSignature(buffer)
|
||||
}, new RegExp(f.exception))
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue