Skip to content

Commit fa1d30d

Browse files
committed
test: add existing input tests to the wallet coin selection.
1 parent 98eaa5f commit fa1d30d

File tree

3 files changed

+440
-216
lines changed

3 files changed

+440
-216
lines changed

lib/utils/coinselector.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,17 @@ class InMemoryCoinSource extends AbstractCoinSource {
199199

200200
class CoinSelector {
201201
/**
202-
* @param {MTX} tx
202+
* @param {MTX} mtx
203203
* @param {AbstractCoinSource} source
204204
* @param {CoinSelectorOptions?} [options]
205205
*/
206206

207-
constructor(tx, source, options = {}) {
208-
this.original = tx;
207+
constructor(mtx, source, options = {}) {
208+
this.original = mtx;
209209
/** @type {MTX} */
210-
this.tx = tx.clone();
210+
this.tx = mtx.clone();
211211
/** @type {CoinView} */
212-
this.view = tx.view;
212+
this.view = mtx.view;
213213
this.source = source;
214214
this.outputValue = 0;
215215
this.fee = CoinSelector.MIN_FEE;

test/util/primitives.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ exports.deterministicInput = (id) => {
2727
return Input.fromOutpoint(new Outpoint(hash, 0));
2828
};
2929

30-
/**
31-
* @typedef {Object} CovenantOptions
32-
* @property {String} [name]
33-
* @property {Hash} [nameHash]
34-
* @property {Covenant.types} [type=Covenant.types.NONE]
35-
* @property {Number} [height]
36-
* @property {Array} [args] - leftover args for the covenant except
37-
* for nameHash, name and height.
38-
*/
39-
4030
/**
4131
* @typedef {Object} OutputOptions
4232
* @property {Number} value
@@ -61,6 +51,16 @@ exports.makeOutput = (options) => {
6151
return output;
6252
};
6353

54+
/**
55+
* @typedef {Object} CovenantOptions
56+
* @property {String} [name]
57+
* @property {Hash} [nameHash]
58+
* @property {Covenant.types} [type=Covenant.types.NONE]
59+
* @property {Number} [height]
60+
* @property {Array} [args] - leftover args for the covenant except
61+
* for nameHash, name and height.
62+
*/
63+
6464
/**
6565
* @param {CovenantOptions} options
6666
* @returns {Covenant}
@@ -171,7 +171,7 @@ exports.randomP2PKAddress = () => {
171171
};
172172

173173
/**
174-
* @param {Object} options
174+
* @typedef {Object} CoinOptions
175175
* @param {String} [options.version=1]
176176
* @param {String} [options.height=-1]
177177
* @param {String} [options.value=0]
@@ -180,6 +180,10 @@ exports.randomP2PKAddress = () => {
180180
* @param {Boolean} [options.coinbase=false]
181181
* @param {Buffer} [options.hash]
182182
* @param {Number} [options.index=0]
183+
*/
184+
185+
/**
186+
* @param {CoinOptions} options
183187
* @returns {Coin}
184188
*/
185189

0 commit comments

Comments
 (0)