bitcoinjs-lib/test/script_number.js

28 lines
737 B
JavaScript
Raw Normal View History

2016-01-04 15:59:14 +01:00
/* global describe, it */
var assert = require('assert')
var scriptNumber = require('../src/script_number')
var fixtures = require('./fixtures/script_number.json')
2016-09-14 16:19:14 +02:00
describe('script-number', function () {
2016-01-04 15:59:14 +01:00
describe('decode', function () {
fixtures.forEach(function (f) {
it(f.hex + ' returns ' + f.number, function () {
2017-04-19 09:39:16 +02:00
var actual = scriptNumber.decode(Buffer.from(f.hex, 'hex'), f.bytes)
2016-01-04 15:59:14 +01:00
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)
})
})
})
})