2019-09-07 06:42:03 +02:00
|
|
|
import * as assert from 'assert';
|
|
|
|
import { describe, it } from 'mocha';
|
|
|
|
import * as scriptNumber from '../src/script_number';
|
|
|
|
import * as fixtures from './fixtures/script_number.json';
|
2016-01-04 15:59:14 +01:00
|
|
|
|
2019-04-09 08:09:50 +02:00
|
|
|
describe('script-number', () => {
|
|
|
|
describe('decode', () => {
|
|
|
|
fixtures.forEach(f => {
|
|
|
|
it(f.hex + ' returns ' + f.number, () => {
|
2019-09-07 06:42:03 +02:00
|
|
|
const actual = scriptNumber.decode(Buffer.from(f.hex, 'hex'), f.bytes);
|
2016-01-04 15:59:14 +01:00
|
|
|
|
2019-09-07 06:42:03 +02:00
|
|
|
assert.strictEqual(actual, f.number);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2016-01-04 15:59:14 +01:00
|
|
|
|
2019-04-09 08:09:50 +02:00
|
|
|
describe('encode', () => {
|
|
|
|
fixtures.forEach(f => {
|
|
|
|
it(f.number + ' returns ' + f.hex, () => {
|
2019-09-07 06:42:03 +02:00
|
|
|
const actual = scriptNumber.encode(f.number);
|
2016-01-04 15:59:14 +01:00
|
|
|
|
2019-09-07 06:42:03 +02:00
|
|
|
assert.strictEqual(actual.toString('hex'), f.hex);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|