@@ -634,6 +634,22 @@ describe('TSS', function() {
634634 sig0 . id . should . equal ( sig1 . id ) ;
635635 } ) ;
636636
637+ it ( happyPath ( 'should emit copayerReady for self on start() and for remote on subscribe()' ) , async function ( ) {
638+ const copayerReadyIds : string [ ] = [ ] ;
639+ const sigA = new TssSign ( { baseUrl : '/bws/api' , request : request ( app ) , credentials : party0Creds , tssKey : party0TssKey } ) ;
640+ const sigB = new TssSign ( { baseUrl : '/bws/api' , request : request ( app ) , credentials : party1Creds , tssKey : party1TssKey } ) ;
641+ sigA . on ( 'copayerReady' , ( id ) => copayerReadyIds . push ( id ) ) ;
642+ await sigA . start ( { id : 'copayer-ready-test' , messageHash, derivationPath } ) ;
643+ copayerReadyIds . should . deep . equal ( [ party0Creds . copayerId ] ) ;
644+ await sigB . start ( { id : 'copayer-ready-test' , messageHash, derivationPath } ) ;
645+ sigA . on ( 'error' , ( e ) => { should . not . exist ( e ?. message ?? e ) ; } ) ;
646+ const roundsubmitted = new Promise ( r => sigA . once ( 'roundsubmitted' , r ) ) ;
647+ sigA . subscribe ( { timeout : 10 , iterHandler : ( ) => sigA . unsubscribe ( ) } ) ;
648+ await roundsubmitted ;
649+ copayerReadyIds . should . include ( party0Creds . copayerId ) ;
650+ copayerReadyIds . should . include ( party1Creds . copayerId ) ;
651+ } ) ;
652+
637653 it ( 'should reject too many participants' , async function ( ) {
638654 const sig2 = new TssSign ( {
639655 baseUrl : '/bws/api' ,
@@ -715,11 +731,12 @@ describe('TSS', function() {
715731 const error = new Promise < Error > ( r => sig0 . on ( 'error' , r ) ) ;
716732 sig0 . subscribe ( { timeout : 10 , iterHandler : ( ) => sig0 . unsubscribe ( ) } ) ;
717733 const e = await error ;
718- emitSpy . callCount . should . equal ( 3 ) ;
719- emitSpy . args [ 0 ] [ 0 ] . should . equal ( 'roundready' ) ;
720- emitSpy . args [ 1 ] [ 0 ] . should . equal ( 'roundprocessed' ) ;
721- emitSpy . args [ 2 ] [ 0 ] . should . equal ( 'error' ) ;
722- emitSpy . args [ 2 ] [ 1 ] . should . equal ( e ) ;
734+ emitSpy . callCount . should . equal ( 4 ) ;
735+ emitSpy . args [ 0 ] [ 0 ] . should . equal ( 'copayerReady' ) ;
736+ emitSpy . args [ 1 ] [ 0 ] . should . equal ( 'roundready' ) ;
737+ emitSpy . args [ 2 ] [ 0 ] . should . equal ( 'roundprocessed' ) ;
738+ emitSpy . args [ 3 ] [ 0 ] . should . equal ( 'error' ) ;
739+ emitSpy . args [ 3 ] [ 1 ] . should . equal ( e ) ;
723740 e . message . should . include ( 'TSS_ROUND_ALREADY_DONE' ) ;
724741 } ) ;
725742
0 commit comments