|
1 | | -import * as assert from 'assert'; |
| 1 | +import assert from 'assert'; |
2 | 2 |
|
3 | 3 | import { Descriptor } from '@bitgo/wasm-miniscript'; |
4 | 4 |
|
5 | | -import { |
6 | | - getMaxOutput, |
7 | | - isMaxOutput, |
8 | | - getOutputSum, |
9 | | - getFixedOutputSum, |
10 | | - toFixedOutputs, |
11 | | - isInternalOutput, |
12 | | - isExternalOutput, |
13 | | -} from '../../src/descriptor'; |
| 5 | +import { isExternalOutput, isInternalOutput } from '../../src/descriptor'; |
14 | 6 |
|
15 | | -describe('Output', function () { |
16 | | - const oBigInt = { value: 1n }; |
17 | | - const oBigInt2 = { value: 2n }; |
18 | | - const oMax = { value: 'max' } as const; |
| 7 | +describe('decscriptor.Output', function () { |
19 | 8 | const mockDescriptor = {} as Descriptor; |
20 | 9 |
|
21 | | - it('getMaxOutput returns expected values', function () { |
22 | | - assert.strictEqual(getMaxOutput([oBigInt]), undefined); |
23 | | - assert.strictEqual(getMaxOutput([oBigInt, oBigInt]), undefined); |
24 | | - assert.strictEqual(getMaxOutput([oBigInt, oMax]), oMax); |
25 | | - assert.throws(() => getMaxOutput([oMax, oMax]), /Multiple max outputs/); |
26 | | - }); |
27 | | - |
28 | | - it('isMaxOutput correctly identifies max outputs', function () { |
29 | | - assert.strictEqual(isMaxOutput(oBigInt), false); |
30 | | - assert.strictEqual(isMaxOutput(oMax), true); |
31 | | - }); |
32 | | - |
33 | | - it('getOutputSum calculates sum correctly', function () { |
34 | | - assert.strictEqual(getOutputSum([]), 0n); |
35 | | - assert.strictEqual(getOutputSum([oBigInt]), 1n); |
36 | | - assert.strictEqual(getOutputSum([oBigInt, oBigInt2]), 3n); |
37 | | - }); |
38 | | - |
39 | | - it('getFixedOutputSum handles mixed outputs', function () { |
40 | | - assert.strictEqual(getFixedOutputSum([]), 0n); |
41 | | - assert.strictEqual(getFixedOutputSum([oBigInt]), 1n); |
42 | | - assert.strictEqual(getFixedOutputSum([oBigInt, oMax]), 1n); |
43 | | - assert.strictEqual(getFixedOutputSum([oBigInt, oBigInt2, oMax]), 3n); |
44 | | - }); |
45 | | - |
46 | | - it('toFixedOutputs converts max outputs correctly', function () { |
47 | | - const maxAmount = 10n; |
48 | | - assert.deepStrictEqual(toFixedOutputs([oBigInt], { maxAmount }), [oBigInt]); |
49 | | - assert.deepStrictEqual(toFixedOutputs([oMax], { maxAmount }), [{ ...oMax, value: maxAmount }]); |
50 | | - assert.throws(() => toFixedOutputs([oMax, oMax], { maxAmount }), /Multiple max outputs/); |
51 | | - }); |
52 | | - |
53 | 10 | it('isInternalOutput correctly identifies internal outputs', function () { |
54 | 11 | const internalOutput = { value: 1n, descriptor: mockDescriptor }; |
55 | 12 | const externalOutput = { value: 1n }; |
|
0 commit comments