@@ -5,6 +5,9 @@ import nock from 'nock';
55import { app as expressApp } from '../../../masterExpressApp' ;
66import { AppMode , MasterExpressConfig , TlsMode } from '../../../shared/types' ;
77import { BitGo } from 'bitgo' ;
8+ import { Wallet } from '@bitgo/sdk-core' ;
9+ import { Trx } from '@bitgo/sdk-coin-trx' ;
10+ import { Sol } from '@bitgo/sdk-coin-sol' ;
811import { EnclavedExpressClient } from '../../../api/master/clients/enclavedExpressClient' ;
912
1013describe ( 'POST /api/:coin/wallet/recoveryConsolidations' , ( ) => {
@@ -40,14 +43,18 @@ describe('POST /api/:coin/wallet/recoveryConsolidations', () => {
4043 } ) ;
4144
4245 it ( 'should handle TRON consolidation recovery' , async ( ) => {
43- const mockTransactions = [ { txHex : 'unsigned-tx-1' } ] ;
44- const recoverConsolidationsStub = sinon . stub ( ) . resolves ( { transactions : mockTransactions } ) ;
45- const coinStub = { recoverConsolidations : recoverConsolidationsStub } ;
46- sinon . stub ( BitGo . prototype , 'coin' ) . returns ( coinStub ) ;
46+ const mockTransactions = [ { txHex : 'unsigned-tx-1' , serializedTx : 'serialized-unsigned-tx-1' } ] ;
47+
48+ const recoverConsolidationsStub = sinon
49+ . stub ( Trx . prototype , 'recoverConsolidations' )
50+ . resolves ( {
51+ transactions : mockTransactions
52+ } ) ;
53+
4754 const recoveryMultisigStub = sinon . stub ( EnclavedExpressClient . prototype , 'recoveryMultisig' ) . resolves ( { txHex : 'signed-tx' } ) ;
4855
4956 const response = await agent
50- . post ( `/api/ttrx /wallet/recoveryConsolidations` )
57+ . post ( `/api/trx /wallet/recoveryConsolidations` )
5158 . set ( 'Authorization' , `Bearer ${ accessToken } ` )
5259 . send ( {
5360 userPub : 'user-xpub' ,
@@ -63,40 +70,42 @@ describe('POST /api/:coin/wallet/recoveryConsolidations', () => {
6370 sinon . assert . calledOnce ( recoverConsolidationsStub ) ;
6471 sinon . assert . calledOnce ( recoveryMultisigStub ) ;
6572 const callArgs = recoverConsolidationsStub . firstCall . args [ 0 ] ;
66- callArgs . tokenContractAddress . should . equal ( 'tron-token' ) ;
73+ callArgs . tokenContractAddress ! . should . equal ( 'tron-token' ) ;
6774 callArgs . userKey . should . equal ( 'user-xpub' ) ;
6875 callArgs . backupKey . should . equal ( 'backup-xpub' ) ;
6976 callArgs . bitgoKey . should . equal ( 'bitgo-xpub' ) ;
7077 } ) ;
7178
72- // it('should handle Solana consolidation recovery', async () => {
73- // const mockTransactions = [{ txHex: 'unsigned-tx-1' }];
74- // const recoverConsolidationsStub = sinon.stub().resolves({ transactions: mockTransactions });
75- // const coinStub = { recoverConsolidations: recoverConsolidationsStub };
76- // sinon.stub(BitGo.prototype, 'coin').returns(coinStub);
77- // const recoveryMultisigStub = sinon.stub(EnclavedExpressClient.prototype, 'recoveryMultisig').resolves({ txHex: 'signed-tx' });
79+ it ( 'should handle Solana consolidation recovery' , async ( ) => {
80+ const mockTransactions = [ { txHex : 'unsigned-tx-1' , serializedTx : 'serialized-unsigned-tx-1' } ] ;
81+
82+ const recoverConsolidationsStub = sinon
83+ . stub ( Sol . prototype , 'recoverConsolidations' )
84+ . resolves ( {
85+ transactions : mockTransactions
86+ } ) ;
7887
79- // const response = await agent
80- // .post(`/api/sol/wallet/recoveryConsolidations`)
81- // .set('Authorization', `Bearer ${accessToken}`)
82- // .send({
83- // userPub: 'user-xpub',
84- // backupPub: 'backup-xpub',
85- // bitgoKey: 'bitgo-xpub',
86- // durableNonces: {
87- // publicKeys: ['sol-pubkey-1', 'sol-pubkey-2'],
88- // secretKey: 'sol-secret',
89- // },
90- // tokenContractAddress: 'sol-token',
91- // });
88+ const recoveryMultisigStub = sinon . stub ( EnclavedExpressClient . prototype , 'recoveryMultisig' ) . resolves ( { txHex : 'signed-tx' } ) ;
9289
93- // response.status.should.equal(200);
94- // response.body.should.have.property('signedTxs');
95- // sinon.assert.calledOnce(recoverConsolidationsStub);
96- // sinon.assert.calledOnce(recoveryMultisigStub);
97- // const callArgs = recoverConsolidationsStub.firstCall.args[0];
98- // callArgs.durableNonces.should.have.property('publicKeys').which.is.an.Array();
99- // callArgs.durableNonces.should.have.property('secretKey', 'sol-secret');
100- // callArgs.tokenContractAddress.should.equal('sol-token');
101- // });
90+ const response = await agent
91+ . post ( `/api/sol/wallet/recoveryConsolidations` )
92+ . set ( 'Authorization' , `Bearer ${ accessToken } ` )
93+ . send ( {
94+ userPub : 'user-xpub' ,
95+ backupPub : 'backup-xpub' ,
96+ bitgoKey : 'bitgo-xpub' ,
97+ durableNonces : {
98+ publicKeys : [ 'sol-pubkey-1' , 'sol-pubkey-2' ] ,
99+ secretKey : 'sol-secret' ,
100+ }
101+ } ) ;
102+
103+ response . status . should . equal ( 200 ) ;
104+ response . body . should . have . property ( 'signedTxs' ) ;
105+ sinon . assert . calledOnce ( recoverConsolidationsStub ) ;
106+ sinon . assert . calledOnce ( recoveryMultisigStub ) ;
107+ const callArgs = recoverConsolidationsStub . firstCall . args [ 0 ] ;
108+ callArgs . durableNonces . should . have . property ( 'publicKeys' ) . which . is . an . Array ( ) ;
109+ callArgs . durableNonces . should . have . property ( 'secretKey' , 'sol-secret' ) ;
110+ } ) ;
102111} ) ;
0 commit comments