@@ -1980,53 +1980,71 @@ describe('V2 Wallet:', function () {
19801980 } ;
19811981 let signTxRequestForMessage ;
19821982 const messageSigningCoins = [ 'teth' , 'tpolygon' ] ;
1983+ const message = 'test' ;
19831984
19841985 beforeEach ( async function ( ) {
19851986 signTxRequestForMessage = sandbox . stub ( ECDSAUtils . EcdsaUtils . prototype , 'signTxRequestForMessage' ) ;
19861987 signTxRequestForMessage . resolves ( txRequestForMessageSigning ) ;
1987- // TODO(BG-59686): this is not doing anything if we don't check the return value
1988- signTxRequestForMessage . calledOnceWithExactly ( { txRequest : txRequestForMessageSigning , prv : 'secretKey' , reqId } ) ;
1988+ } ) ;
1989+
1990+ afterEach ( async function ( ) {
1991+ sinon . restore ( ) ;
19891992 } ) ;
19901993
19911994 it ( 'should throw error for unsupported coins' , async function ( ) {
19921995
19931996 await tssWallet . signMessage ( {
19941997 reqId,
1995- messagePrebuild : { message : 'test' } ,
1998+ messagePrebuild : { message } ,
19961999 prv : 'secretKey' ,
19972000 } ) . should . be . rejectedWith ( 'Message signing not supported for Testnet Solana' ) ;
19982001 } ) ;
19992002
20002003 messageSigningCoins . map ( ( coinName ) => {
20012004 tssEthWallet = new Wallet ( bitgo , bitgo . coin ( coinName ) , ethWalletData ) ;
2005+ const txRequestId = txRequestForMessageSigning . txRequestId ;
2006+
20022007 it ( 'should sign message' , async function ( ) {
2008+ const signMessageTssSpy = sinon . spy ( tssEthWallet , 'signMessageTss' as any ) ;
2009+ nock ( bgUrl )
2010+ . get ( `/api/v2/wallet/${ tssEthWallet . id ( ) } /txrequests?txRequestIds=${ txRequestForMessageSigning . txRequestId } &latest=true` )
2011+ . reply ( 200 , { txRequests : [ txRequestForMessageSigning ] } ) ;
20032012
20042013 const signMessage = await tssEthWallet . signMessage ( {
20052014 reqId,
2006- messagePrebuild : { message : 'test' , txRequestId : 'id' } ,
2015+ messagePrebuild : { message, txRequestId } ,
20072016 prv : 'secretKey' ,
20082017 } ) ;
2009- signMessage . should . deepEqual ( { txRequestId : 'id' } ) ;
2018+ signMessage . should . deepEqual ( { txRequestId } ) ;
2019+ const actualArg = signMessageTssSpy . getCalls ( ) [ 0 ] . args [ 0 ] ;
2020+ actualArg . messagePrebuild . message . should . equal ( `\u0019Ethereum Signed Message:\\n${ message . length } ${ message } ` ) ;
20102021 } ) ;
20112022
2012- it ( 'should fail to sign message without txRequestId' , async function ( ) {
2013- await tssEthWallet . signMessage ( {
2023+ it ( 'should sign message when txRequestId not provided' , async function ( ) {
2024+ const signMessageTssSpy = sinon . spy ( tssEthWallet , 'signMessageTss' as any ) ;
2025+ nock ( bgUrl )
2026+ . post ( `/api/v2/wallet/${ tssEthWallet . id ( ) } /txrequests` )
2027+ . reply ( 200 , txRequestForMessageSigning ) ;
2028+
2029+ const signMessage = await tssEthWallet . signMessage ( {
20142030 reqId,
2015- messagePrebuild : { message : '' } ,
2031+ messagePrebuild : { message } ,
20162032 prv : 'secretKey' ,
2017- } ) . should . be . rejectedWith ( 'txRequestId required to sign message with TSS' ) ;
2033+ } ) ;
2034+ signMessage . should . deepEqual ( { txRequestId } ) ;
2035+ const actualArg = signMessageTssSpy . getCalls ( ) [ 0 ] . args [ 0 ] ;
2036+ actualArg . messagePrebuild . message . should . equal ( `\u0019Ethereum Signed Message:\\n${ message . length } ${ message } ` ) ;
20182037 } ) ;
20192038
20202039 it ( 'should fail to sign message with empty prv' , async function ( ) {
20212040 await tssEthWallet . signMessage ( {
20222041 reqId,
2023- messagePrebuild : { message : 'test' , txRequestId : 'id' } ,
2042+ messagePrebuild : { message, txRequestId } ,
20242043 prv : '' ,
20252044 } ) . should . be . rejectedWith ( 'prv required to sign message with TSS' ) ;
20262045 } ) ;
20272046 } ) ;
20282047
2029-
20302048 } ) ;
20312049
20322050 describe ( 'Send Many' , function ( ) {
0 commit comments