Skip to content

Commit 1bfcc36

Browse files
author
Alvin Dai
committed
fix(sdk-core): choose correct default apiVersion for tss
TICKET: WP-3038
1 parent c3bc7f0 commit 1bfcc36

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

modules/bitgo/test/v2/unit/coins/utxo/prebuildAndSign.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,23 @@ function run(coin: AbstractUtxoCoin, inputScripts: ScriptType[], txFormat: TxFor
9696
feeMultiplier?: number;
9797
selfSend?: boolean;
9898
nockOutputAddresses?: boolean;
99+
txFormat?: string;
99100
}): nock.Scope[] {
100101
const nocks: nock.Scope[] = [];
101102

102103
// Nock the prebuild route (/tx/build, blockheight)
104+
const expected_params = {
105+
recipients: [params.recipient],
106+
rbfTxIds: params.rbfTxIds,
107+
feeMultiplier: params.feeMultiplier,
108+
changeAddressType: ['p2trMusig2', 'p2wsh', 'p2shP2wsh', 'p2sh', 'p2tr'],
109+
};
110+
if (params.txFormat) {
111+
expected_params['txFormat'] = params.txFormat;
112+
}
103113
nocks.push(
104114
nock(params.bgUrl)
105-
.post(`/api/v2/${coin.getChain()}/wallet/${params.wallet.id()}/tx/build`, {
106-
recipients: [params.recipient],
107-
rbfTxIds: params.rbfTxIds,
108-
feeMultiplier: params.feeMultiplier,
109-
})
115+
.post(`/api/v2/${coin.getChain()}/wallet/${params.wallet.id()}/tx/build`, expected_params)
110116
.reply(200, { txHex: params.prebuild.toHex(), txInfo: {} })
111117
);
112118
nocks.push(nock(params.bgUrl).get(`/api/v2/${coin.getChain()}/public/block/latest`).reply(200, { height: 1000 }));
@@ -212,6 +218,7 @@ function run(coin: AbstractUtxoCoin, inputScripts: ScriptType[], txFormat: TxFor
212218

213219
[true, false].forEach((useWebauthn) => {
214220
it(`should succeed with ${useWebauthn ? 'webauthn encryptedPrv' : 'encryptedPrv'}`, async function () {
221+
const txCoins = ['tzec', 'zec', 'ltc', 'bcha', 'doge', 'dash', 'btg', 'bch'];
215222
const nocks = createNocks({
216223
bgUrl,
217224
wallet,
@@ -220,6 +227,7 @@ function run(coin: AbstractUtxoCoin, inputScripts: ScriptType[], txFormat: TxFor
220227
recipient,
221228
addressInfo,
222229
nockOutputAddresses: txFormat !== 'psbt',
230+
txFormat: !txCoins.includes(coin.getChain()) ? 'psbt' : undefined,
223231
});
224232

225233
// call prebuild and sign, nocks should be consumed
@@ -257,6 +265,7 @@ function run(coin: AbstractUtxoCoin, inputScripts: ScriptType[], txFormat: TxFor
257265
it(`should be able to build, sign, & verify a replacement transaction with selfSend: ${selfSend}`, async function () {
258266
const rbfTxIds = ['tx-to-be-replaced'],
259267
feeMultiplier = 1.5;
268+
const txCoins = ['tzec', 'zec', 'ltc', 'bcha', 'doge', 'dash', 'btg', 'bch'];
260269
const nocks = createNocks({
261270
bgUrl,
262271
wallet,
@@ -268,6 +277,7 @@ function run(coin: AbstractUtxoCoin, inputScripts: ScriptType[], txFormat: TxFor
268277
feeMultiplier,
269278
selfSend,
270279
nockOutputAddresses: txFormat !== 'psbt',
280+
txFormat: !txCoins.includes(coin.getChain()) ? 'psbt' : undefined,
271281
});
272282

273283
// call prebuild and sign, nocks should be consumed

0 commit comments

Comments
 (0)