@@ -20,7 +20,8 @@ describe('recoveryMpcV2', async () => {
2020 const cosmosLikeCoin = 'tsei' ;
2121 const accessToken = 'test-token' ;
2222
23- // sinon stubs
23+ // sinon sandbox
24+ const sandbox = sinon . createSandbox ( ) ;
2425 let configStub : sinon . SinonStub ;
2526
2627 // key provider nocks setup
@@ -67,7 +68,11 @@ describe('recoveryMpcV2', async () => {
6768 recoveryMode : true ,
6869 } ;
6970
70- configStub = sinon . stub ( configModule , 'initConfig' ) . returns ( cfg ) ;
71+ // Restore any existing stub from other test suites before re-stubbing
72+ if ( typeof ( configModule . initConfig as any ) . restore === 'function' ) {
73+ ( configModule . initConfig as any ) . restore ( ) ;
74+ }
75+ configStub = sandbox . stub ( configModule , 'initConfig' ) . returns ( cfg ) ;
7176
7277 // app setup
7378 app = advancedWalletManagerApp ( cfg ) ;
@@ -79,7 +84,7 @@ describe('recoveryMpcV2', async () => {
7984 } ) ;
8085
8186 after ( ( ) => {
82- configStub . restore ( ) ;
87+ sandbox . restore ( ) ;
8388 } ) ;
8489
8590 // happy path test
@@ -133,15 +138,30 @@ describe('recoveryMpcV2', async () => {
133138 } ) ;
134139
135140 it ( 'should route backup key retrieval to backup KMS when configured' , async ( ) => {
141+ const kmsUrl = 'http://kms.invalid' ;
136142 const backupKmsUrl = 'http://backup-kms.invalid' ;
137143
144+ const mockKmsUserResponse = {
145+ prv : JSON . stringify ( userKeyShare ) ,
146+ pub : commonKeychain ,
147+ source : 'user' ,
148+ type : 'tss' ,
149+ } ;
150+
151+ const mockKmsBackupResponse = {
152+ prv : JSON . stringify ( backupKeyShare ) ,
153+ pub : commonKeychain ,
154+ source : 'backup' ,
155+ type : 'tss' ,
156+ } ;
157+
138158 // Reconfigure app with backup KMS URL
139- configStub . restore ( ) ;
140159 const dualCfg : AdvancedWalletManagerConfig = {
141160 ...cfg ,
161+ keyProviderUrl : kmsUrl ,
142162 backupKmsUrl,
143163 } ;
144- configStub = sinon . stub ( configModule , 'initConfig' ) . returns ( dualCfg ) ;
164+ configStub . returns ( dualCfg ) ;
145165 const dualApp = advancedWalletManagerApp ( dualCfg ) ;
146166 const dualAgent = request . agent ( dualApp ) ;
147167
0 commit comments