script_number: add impl/tests
This commit is contained in:
parent
cba7252c9d
commit
059f48b0c4
3 changed files with 330 additions and 0 deletions
test
27
test/script_number.js
Normal file
27
test/script_number.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* global describe, it */
|
||||
|
||||
var assert = require('assert')
|
||||
var scriptNumber = require('../src/script_number')
|
||||
var fixtures = require('./fixtures/script_number.json')
|
||||
|
||||
describe('script', function () {
|
||||
describe('decode', function () {
|
||||
fixtures.forEach(function (f) {
|
||||
it(f.hex + ' returns ' + f.number, function () {
|
||||
var actual = scriptNumber.decode(new Buffer(f.hex, 'hex'), f.bytes)
|
||||
|
||||
assert.strictEqual(actual, f.number)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('encode', function () {
|
||||
fixtures.forEach(function (f) {
|
||||
it(f.number + ' returns ' + f.hex, function () {
|
||||
var actual = scriptNumber.encode(f.number)
|
||||
|
||||
assert.strictEqual(actual.toString('hex'), f.hex)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue