@@ -1787,6 +1787,28 @@ describe('V2 Wallet:', function () {
17871787 txPrebuild . recipients [ 0 ] . amount . should . equal ( '1000000000000000' ) ;
17881788 } ) ;
17891789
1790+ it ( 'should pass isTestTransaction parameter through for multisig wallets' , async function ( ) {
1791+ const recipients = [
1792+ {
1793+ address : 'aaa' ,
1794+ amount : '1000' ,
1795+ } ,
1796+ ] ;
1797+ const isTestTransaction = true ;
1798+ const path = `/api/v2/${ wallet . coin ( ) } /wallet/${ wallet . id ( ) } /tx/build` ;
1799+ const response = nock ( bgUrl )
1800+ . post ( path , _ . matches ( { recipients, isTestTransaction } ) ) // use _.matches to do a partial match on request body object instead of strict matching
1801+ . reply ( 200 ) ;
1802+ try {
1803+ await wallet . prebuildTransaction ( { recipients, isTestTransaction } ) ;
1804+ } catch ( e ) {
1805+ // the prebuildTransaction method will probably throw an exception for not having all of the correct nocks
1806+ // we only care about /tx/build and whether isTestTransaction is an allowed parameter
1807+ }
1808+
1809+ response . isDone ( ) . should . be . true ( ) ;
1810+ } ) ;
1811+
17901812 it ( 'should pass unspent reservation parameter through when building transactions' , async function ( ) {
17911813 const reservation = {
17921814 expireTime : '2029-08-12' ,
@@ -2377,6 +2399,50 @@ describe('V2 Wallet:', function () {
23772399 } ) ;
23782400 } ) ;
23792401
2402+ it ( 'should build a transfer transaction with isTestTransaction flag' , async function ( ) {
2403+ const recipients = [
2404+ {
2405+ address : '6DadkZcx9JZgeQUDbHh12cmqCpaqehmVxv6sGy49jrah' ,
2406+ amount : '1000' ,
2407+ } ,
2408+ ] ;
2409+
2410+ const prebuildTxWithIntent = sandbox . stub ( TssUtils . prototype , 'prebuildTxWithIntent' ) ;
2411+ prebuildTxWithIntent . resolves ( txRequest ) ;
2412+
2413+ const txPrebuild = await tssSolWallet . prebuildTransaction ( {
2414+ reqId,
2415+ recipients,
2416+ type : 'transfer' ,
2417+ isTestTransaction : true ,
2418+ } ) ;
2419+
2420+ // Verify isTestTransaction is passed to prebuildTxWithIntent
2421+ sinon . assert . calledOnce ( prebuildTxWithIntent ) ;
2422+ const callArgs = prebuildTxWithIntent . getCall ( 0 ) . args [ 0 ] ;
2423+ callArgs . should . have . property ( 'isTestTransaction' , true ) ;
2424+ callArgs . should . have . property ( 'intentType' , 'payment' ) ;
2425+ callArgs . should . have . property ( 'recipients' ) ;
2426+ should . exist ( callArgs . recipients ) ;
2427+ callArgs . recipients ! . should . deepEqual ( recipients ) ;
2428+
2429+ txPrebuild . should . deepEqual ( {
2430+ walletId : tssSolWallet . id ( ) ,
2431+ wallet : tssSolWallet ,
2432+ txRequestId : 'id' ,
2433+ txHex : 'ababcdcd' ,
2434+ buildParams : {
2435+ recipients,
2436+ type : 'transfer' ,
2437+ isTestTransaction : true ,
2438+ } ,
2439+ feeInfo : {
2440+ fee : 5000 ,
2441+ feeString : '5000' ,
2442+ } ,
2443+ } ) ;
2444+ } ) ;
2445+
23802446 it ( 'should build an enable token transaction' , async function ( ) {
23812447 const recipients = [ ] ;
23822448 const tokenName = 'tcoin:tokenName' ;
@@ -3965,6 +4031,35 @@ describe('V2 Wallet:', function () {
39654031 setRequestTracerSpy . restore ( ) ;
39664032 } ) ;
39674033
4034+ it ( 'should pass isTestTransaction through sendMany to prebuildAndSignTransaction' , async function ( ) {
4035+ const signedTransaction = {
4036+ txRequestId : 'txRequestId' ,
4037+ } ;
4038+
4039+ const sendManyInputWithTestFlag = {
4040+ ...sendManyInput ,
4041+ type : 'transfer' ,
4042+ isTestTransaction : true ,
4043+ } ;
4044+
4045+ const prebuildAndSignTransaction = sandbox . stub ( tssSolWallet , 'prebuildAndSignTransaction' ) ;
4046+ prebuildAndSignTransaction . resolves ( signedTransaction ) ;
4047+
4048+ const sendTxRequest = sandbox . stub ( TssUtils . prototype , 'sendTxRequest' ) ;
4049+ sendTxRequest . resolves ( 'sendTxResponse' ) ;
4050+
4051+ const sendMany = await tssSolWallet . sendMany ( sendManyInputWithTestFlag ) ;
4052+
4053+ // Verify prebuildAndSignTransaction was called with isTestTransaction
4054+ sinon . assert . calledOnce ( prebuildAndSignTransaction ) ;
4055+ const callArgs = prebuildAndSignTransaction . getCall ( 0 ) . args [ 0 ] ;
4056+ should . exist ( callArgs ) ;
4057+ callArgs ! . should . have . property ( 'isTestTransaction' , true ) ;
4058+ callArgs ! . should . have . property ( 'type' , 'transfer' ) ;
4059+
4060+ sendMany . should . deepEqual ( 'sendTxResponse' ) ;
4061+ } ) ;
4062+
39684063 it ( 'should return transfer from sendMany for apiVersion=full' , async function ( ) {
39694064 const wallet = new Wallet ( bitgo , tsol , {
39704065 ...walletData ,
0 commit comments