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,6 @@
|
|||
/* global describe, it */
|
||||
/* eslint-disable no-new */
|
||||
|
||||
var assert = require('assert')
|
||||
var opcodes = require('../src/opcodes')
|
||||
|
||||
|
@ -5,9 +8,9 @@ var Script = require('../src/script')
|
|||
|
||||
var fixtures = require('./fixtures/script.json')
|
||||
|
||||
describe('Script', function() {
|
||||
describe('constructor', function() {
|
||||
it('accepts valid parameters', function() {
|
||||
describe('Script', function () {
|
||||
describe('constructor', function () {
|
||||
it('accepts valid parameters', function () {
|
||||
var buffer = new Buffer([1])
|
||||
var chunks = [1]
|
||||
var script = new Script(buffer, chunks)
|
||||
|
@ -16,30 +19,32 @@ describe('Script', function() {
|
|||
assert.equal(script.chunks, chunks)
|
||||
})
|
||||
|
||||
it('throws an error when input is not an array', function() {
|
||||
assert.throws(function(){ new Script({}) }, /Expected Buffer, got/)
|
||||
it('throws an error when input is not an array', function () {
|
||||
assert.throws(function () {
|
||||
new Script({})
|
||||
}, /Expected Buffer, got/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('fromASM/toASM', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('decodes/encodes ' + f.description, function() {
|
||||
describe('fromASM/toASM', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('decodes/encodes ' + f.description, function () {
|
||||
assert.equal(Script.fromASM(f.asm).toASM(), f.asm)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('fromHex/toHex', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('decodes/encodes ' + f.description, function() {
|
||||
describe('fromHex/toHex', function () {
|
||||
fixtures.valid.forEach(function (f) {
|
||||
it('decodes/encodes ' + f.description, function () {
|
||||
assert.equal(Script.fromHex(f.hex).toHex(), f.hex)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('getHash', function() {
|
||||
fixtures.valid.forEach(function(f) {
|
||||
it('produces a HASH160 of \"' + f.asm + '\"', function() {
|
||||
describe('getHash', 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)
|
||||
|
@ -47,8 +52,8 @@ describe('Script', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('fromChunks', function() {
|
||||
it('should match expected behaviour', function() {
|
||||
describe('fromChunks', function () {
|
||||
it('should match expected behaviour', function () {
|
||||
var hash = new Buffer(32)
|
||||
hash.fill(0)
|
||||
|
||||
|
@ -62,17 +67,17 @@ describe('Script', function() {
|
|||
})
|
||||
})
|
||||
|
||||
describe('without', function() {
|
||||
describe('without', function () {
|
||||
var hex = 'a914e8c300c87986efa94c37c0519929019ef86eb5b487'
|
||||
var script = Script.fromHex(hex)
|
||||
|
||||
it('should return a script without the given value', function() {
|
||||
it('should return a script without the given value', function () {
|
||||
var subScript = script.without(opcodes.OP_HASH160)
|
||||
|
||||
assert.equal(subScript.toHex(), '14e8c300c87986efa94c37c0519929019ef86eb5b487')
|
||||
})
|
||||
|
||||
it('shouldnt mutate the original script', function() {
|
||||
it('shouldnt mutate the original script', function () {
|
||||
var subScript = script.without(opcodes.OP_EQUAL)
|
||||
|
||||
assert.notEqual(subScript.toHex(), hex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue