|
1 | | -import * as assert from 'assert'; |
| 1 | +import assert from 'assert'; |
2 | 2 |
|
3 | 3 | import { |
4 | 4 | getChangeOutputVSizesForDescriptor, |
5 | 5 | getInputVSizesForDescriptors, |
6 | 6 | getVirtualSize, |
7 | 7 | } from '../../../../src/core/descriptor/VirtualSize'; |
8 | | -import { getDescriptor, getDescriptorMap } from '../descriptor.utils'; |
| 8 | +import { DescriptorTemplate, getDescriptor, getDescriptorMap } from '../descriptor.utils'; |
9 | 9 |
|
10 | 10 | describe('VirtualSize', function () { |
11 | 11 | describe('getInputVSizesForDescriptorWallet', function () { |
@@ -38,29 +38,35 @@ describe('VirtualSize', function () { |
38 | 38 | }); |
39 | 39 | }); |
40 | 40 |
|
41 | | - describe('getVirtualSize', function () { |
42 | | - it('returns expected virtual size', function () { |
43 | | - assert.deepStrictEqual( |
44 | | - getVirtualSize( |
45 | | - { |
46 | | - inputs: [{ descriptorName: 'internal' }], |
47 | | - outputs: [{ script: Buffer.alloc(32) }], |
48 | | - }, |
49 | | - getDescriptorMap('Wsh2Of3') |
50 | | - ), |
51 | | - 157 |
52 | | - ); |
| 41 | + function describeWithTemplate(t: DescriptorTemplate, inputSize: number, outputSize: number) { |
| 42 | + describe(`getVirtualSize ${t}`, function () { |
| 43 | + it('returns expected virtual size', function () { |
| 44 | + assert.deepStrictEqual( |
| 45 | + getVirtualSize( |
| 46 | + { |
| 47 | + inputs: [{ descriptorName: 'internal' }], |
| 48 | + outputs: [{ script: Buffer.alloc(32) }], |
| 49 | + }, |
| 50 | + getDescriptorMap(t) |
| 51 | + ), |
| 52 | + outputSize |
| 53 | + ); |
53 | 54 |
|
54 | | - const descriptor = getDescriptor('Wsh2Of3'); |
| 55 | + const descriptor = getDescriptor(t); |
55 | 56 |
|
56 | | - assert.deepStrictEqual( |
57 | | - getVirtualSize({ |
58 | | - /* as proof we can pass 10_000 inputs */ |
59 | | - inputs: Array.from({ length: 10_000 }).map(() => descriptor), |
60 | | - outputs: [{ script: Buffer.alloc(32) }], |
61 | | - }), |
62 | | - 1_050_052 |
63 | | - ); |
| 57 | + const nInputs = 10_000; |
| 58 | + assert.deepStrictEqual( |
| 59 | + getVirtualSize({ |
| 60 | + /* as proof we can pass 10_000 inputs */ |
| 61 | + inputs: Array.from({ length: nInputs }).map(() => descriptor), |
| 62 | + outputs: [], |
| 63 | + }), |
| 64 | + inputSize * nInputs + 11 |
| 65 | + ); |
| 66 | + }); |
64 | 67 | }); |
65 | | - }); |
| 68 | + } |
| 69 | + |
| 70 | + describeWithTemplate('Wsh2Of3', 105, 157); |
| 71 | + describeWithTemplate('Tr2Of3-NoKeyPath', 109, 161); |
66 | 72 | }); |
0 commit comments