2018-07-23 09:45:01 +02:00
|
|
|
const { describe, it } = require('mocha')
|
2018-06-25 08:25:12 +02:00
|
|
|
const assert = require('assert')
|
2018-12-26 06:25:33 +01:00
|
|
|
const scriptNumber = require('../dist/src/script_number')
|
2018-06-25 08:25:12 +02:00
|
|
|
const fixtures = require('./fixtures/script_number.json')
|
2016-01-04 15:59:14 +01:00
|
|
|
|
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 () {
|
2018-06-25 08:37:45 +02:00
|
|
|
const 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 () {
|
2018-06-25 08:37:45 +02:00
|
|
|
const actual = scriptNumber.encode(f.number)
|
2016-01-04 15:59:14 +01:00
|
|
|
|
|
|
|
assert.strictEqual(actual.toString('hex'), f.hex)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|