@@ -7,16 +7,16 @@ describe('GreedyInputSelector', () => {
7
7
const feeRate = 1 ; // sat/byte
8
8
const changeAddress = 'change-address' ;
9
9
10
- const createUtXO = ( satoshis : bigint , id = Math . random ( ) . toString ( ) ) => ( {
10
+ const createUTxO = ( satoshis : bigint , id = Math . random ( ) . toString ( ) ) => ( {
11
11
txId : id ,
12
12
index : 0 ,
13
13
address : 'address1' ,
14
14
vout : 0 ,
15
15
satoshis
16
16
} ) ;
17
17
18
- it ( 'selects sufficient UtXOs and returns change' , ( ) => {
19
- const utxos = [ createUtXO ( BigInt ( 5000 ) ) , createUtXO ( BigInt ( 8000 ) ) ] ;
18
+ it ( 'selects sufficient UTxOs and returns change' , ( ) => {
19
+ const utxos = [ createUTxO ( BigInt ( 5000 ) ) , createUTxO ( BigInt ( 8000 ) ) ] ;
20
20
const outputs = [ { address : 'address1' , value : BigInt ( 4000 ) } ] ;
21
21
const result = selector . selectInputs ( changeAddress , utxos , outputs , feeRate ) ;
22
22
@@ -27,15 +27,15 @@ describe('GreedyInputSelector', () => {
27
27
} ) ;
28
28
29
29
it ( 'returns undefined if inputs are insufficient' , ( ) => {
30
- const utxos = [ createUtXO ( BigInt ( 1000 ) ) ] ;
30
+ const utxos = [ createUTxO ( BigInt ( 1000 ) ) ] ;
31
31
const outputs = [ { address : 'address1' , value : BigInt ( 2000 ) } ] ;
32
32
const result = selector . selectInputs ( changeAddress , utxos , outputs , feeRate ) ;
33
33
34
34
expect ( result ) . toBeUndefined ( ) ;
35
35
} ) ;
36
36
37
37
it ( 'includes all outputs and correct change when no dust' , ( ) => {
38
- const utxos = [ createUtXO ( BigInt ( 10_000 ) ) ] ;
38
+ const utxos = [ createUTxO ( BigInt ( 10_000 ) ) ] ;
39
39
const outputs = [
40
40
{ address : 'address1' , value : BigInt ( 3000 ) } ,
41
41
{ address : 'address2' , value : BigInt ( 2000 ) }
@@ -49,7 +49,7 @@ describe('GreedyInputSelector', () => {
49
49
} ) ;
50
50
51
51
it ( 'adds dust change to fee instead of outputting it' , ( ) => {
52
- const utxos = [ createUtXO ( BigInt ( 6000 ) ) ] ;
52
+ const utxos = [ createUTxO ( BigInt ( 6000 ) ) ] ;
53
53
const outputs = [ { address : 'address1' , value : BigInt ( 5500 ) } ] ;
54
54
const result = selector . selectInputs ( changeAddress , utxos , outputs , feeRate ) ;
55
55
@@ -60,8 +60,8 @@ describe('GreedyInputSelector', () => {
60
60
expect ( sumInputs - sumOutputs - result ! . fee ) . toBe ( 0 ) ;
61
61
} ) ;
62
62
63
- it ( 'rescues dust by including an extra UtXO when it is economical' , ( ) => {
64
- const utxos = [ createUtXO ( BigInt ( 6000 ) , 'utxo1' ) , createUtXO ( BigInt ( 1000 ) , 'utxo2' ) ] ;
63
+ it ( 'rescues dust by including an extra UTxO when it is economical' , ( ) => {
64
+ const utxos = [ createUTxO ( BigInt ( 6000 ) , 'utxo1' ) , createUTxO ( BigInt ( 1000 ) , 'utxo2' ) ] ;
65
65
const outputs = [ { address : 'dest1' , value : BigInt ( 5500 ) } ] ;
66
66
67
67
const result = selector . selectInputs ( changeAddress , utxos , outputs , feeRate ) ;
@@ -78,16 +78,16 @@ describe('GreedyInputSelector', () => {
78
78
79
79
it ( 'does NOT rescue dust when the extra input would cost more than the value rescued' , ( ) => {
80
80
const bigFeeRate = 5 ;
81
- // Single UtXO leaves ~290 sats dust (below dust threshold).
82
- // Adding the second UtXO would cost ~340 sats in extra fee (68vB * 5) but
81
+ // Single UTxO leaves ~290 sats dust (below dust threshold).
82
+ // Adding the second UTxO would cost ~340 sats in extra fee (68vB * 5) but
83
83
// only rescue ~260 sats, so it should NOT be added.
84
- const utxos = [ createUtXO ( BigInt ( 9000 ) , 'big_utxo' ) , createUtXO ( BigInt ( 600 ) , 'small_utxo' ) ] ;
84
+ const utxos = [ createUTxO ( BigInt ( 9000 ) , 'big_utxo' ) , createUTxO ( BigInt ( 600 ) , 'small_utxo' ) ] ;
85
85
const outputs = [ { address : 'dest1' , value : BigInt ( 8000 ) } ] ;
86
86
87
87
const result = selector . selectInputs ( changeAddress , utxos , outputs , bigFeeRate ) ;
88
88
89
89
expect ( result ) . toBeDefined ( ) ;
90
- // Only the first (large) UtXO should be used.
90
+ // Only the first (large) UTxO should be used.
91
91
expect ( result ! . selectedUTxOs . length ) . toBe ( 1 ) ;
92
92
expect ( result ! . selectedUTxOs [ 0 ] . txId ) . toBe ( 'big_utxo' ) ;
93
93
0 commit comments