Skip to content

Commit

Permalink
chore(wp): add unit test for unspents param
Browse files Browse the repository at this point in the history
TICKET: BTC-1501
  • Loading branch information
kcheng-bitgo committed Sep 26, 2024
1 parent 5e3f611 commit 163ec40
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion modules/bitgo/test/v2/unit/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1461,9 +1461,13 @@ describe('V2 Wallet:', function () {
});
});

describe('maxNumInputsToUse verification', function () {
describe('fanout input maxNumInputsToUse and unspents verification', function () {
const address = '5b34252f1bf349930e34020a';
const maxNumInputsToUse = 2;
const unspents = [
'cc30565750e2aeb818625aaedaf89db5c614e5977b9645cee1d7289f616fb1d8:0',
'8c45164787a954ab07864af9b05b34fbde3a8e430a8c65b0e60e4e543d8e1b6c:2',
];
let basecoin;
let wallet;

Expand Down Expand Up @@ -1492,8 +1496,42 @@ describe('V2 Wallet:', function () {

response.isDone().should.be.true();
});

it('should pass unspents parameter when calling fanout unspents', async function () {
const path = `/api/v2/${wallet.coin()}/wallet/${wallet.id()}/fanoutUnspents`;
const response = nock(bgUrl)
.post(path, _.matches({ unspents })) // use _.matches to do a partial match on request body object instead of strict matching
.reply(200);

try {
await wallet.fanoutUnspents({ address, unspents });
} catch (e) {
// the fanoutUnspents method will probably throw an exception for not having all of the correct nocks
// we only care about /fanoutUnspents and whether unspents is an allowed parameter
}

response.isDone().should.be.true();
});
});

// describe('fanout specific unspents param verification', function () {
// const address = '5b34252f1bf349930e34020a';

// let basecoin;
// let wallet;

// before(async function () {
// basecoin = bitgo.coin('tbtc');
// const walletData = {
// id: '5b34252f1bf349930e34020a',
// coin: 'tbtc',
// keys: ['5b3424f91bf349930e340175'],
// };
// wallet = new Wallet(bitgo, basecoin, walletData);
// });

// });

describe('manage unspents', function () {
let rootWalletKey;
let walletPassphrase;
Expand Down

0 comments on commit 163ec40

Please sign in to comment.