Skip to content

Commit bd862b8

Browse files
test(wallet): add test for isTestTransaction in sendMany
Add unit test to verify that isTestTransaction parameter is properly passed through the sendMany -> prebuildAndSignTransaction flow for TSS wallets. This ensures the parameter flows correctly via inheritance from SendManyOptions -> PrebuildAndSignTransactionOptions -> PrebuildTransactionOptions.
1 parent b52c7b8 commit bd862b8

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

modules/bitgo/test/v2/unit/wallet.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2386,7 +2386,8 @@ describe('V2 Wallet:', function () {
23862386
callArgs.should.have.property('isTestTransaction', true);
23872387
callArgs.should.have.property('intentType', 'payment');
23882388
callArgs.should.have.property('recipients');
2389-
callArgs.recipients.should.deepEqual(recipients);
2389+
should.exist(callArgs.recipients);
2390+
callArgs.recipients!.should.deepEqual(recipients);
23902391

23912392
txPrebuild.should.deepEqual({
23922393
walletId: tssSolWallet.id(),
@@ -3952,6 +3953,35 @@ describe('V2 Wallet:', function () {
39523953
setRequestTracerSpy.restore();
39533954
});
39543955

3956+
it('should pass isTestTransaction through sendMany to prebuildAndSignTransaction', async function () {
3957+
const signedTransaction = {
3958+
txRequestId: 'txRequestId',
3959+
};
3960+
3961+
const sendManyInputWithTestFlag = {
3962+
...sendManyInput,
3963+
type: 'transfer',
3964+
isTestTransaction: true,
3965+
};
3966+
3967+
const prebuildAndSignTransaction = sandbox.stub(tssSolWallet, 'prebuildAndSignTransaction');
3968+
prebuildAndSignTransaction.resolves(signedTransaction);
3969+
3970+
const sendTxRequest = sandbox.stub(TssUtils.prototype, 'sendTxRequest');
3971+
sendTxRequest.resolves('sendTxResponse');
3972+
3973+
const sendMany = await tssSolWallet.sendMany(sendManyInputWithTestFlag);
3974+
3975+
// Verify prebuildAndSignTransaction was called with isTestTransaction
3976+
sinon.assert.calledOnce(prebuildAndSignTransaction);
3977+
const callArgs = prebuildAndSignTransaction.getCall(0).args[0];
3978+
should.exist(callArgs);
3979+
callArgs!.should.have.property('isTestTransaction', true);
3980+
callArgs!.should.have.property('type', 'transfer');
3981+
3982+
sendMany.should.deepEqual('sendTxResponse');
3983+
});
3984+
39553985
it('should return transfer from sendMany for apiVersion=full', async function () {
39563986
const wallet = new Wallet(bitgo, tsol, {
39573987
...walletData,

0 commit comments

Comments
 (0)