File tree Expand file tree Collapse file tree 3 files changed +21
-17
lines changed
Expand file tree Collapse file tree 3 files changed +21
-17
lines changed Original file line number Diff line number Diff line change @@ -2,23 +2,30 @@ import { XudClient } from '../../proto/xudrpc_grpc_pb';
22import { testConfig } from '../../test-utils' ;
33import { errors } from '../errors' ;
44import { getXudClient$ } from './client' ;
5+ import { take } from 'rxjs/operators' ;
56
67jest . mock ( '../../proto/xudrpc_grpc_pb' ) ;
78jest . mock ( '../../proto/xudrpc_pb' ) ;
89
910describe ( 'getXudClient$' , ( ) => {
1011 test ( 'success' , done => {
11- expect . assertions ( 2 ) ;
12+ expect . assertions ( 3 ) ;
1213 const config = testConfig ( ) ;
1314 const xudClient$ = getXudClient$ ( config ) ;
14- xudClient$ . subscribe ( ( ) => {
15- expect ( XudClient ) . toHaveBeenCalledTimes ( 1 ) ;
16- expect ( XudClient ) . toHaveBeenCalledWith (
17- `${ config . OPENDEX_RPC_HOST } :${ config . OPENDEX_RPC_PORT } ` ,
18- expect . any ( Object ) ,
19- expect . any ( Object )
20- ) ;
21- done ( ) ;
15+
16+ xudClient$ . pipe ( take ( 1 ) ) . subscribe ( {
17+ next : client => {
18+ expect ( XudClient ) . toHaveBeenCalledTimes ( 1 ) ;
19+ expect ( XudClient ) . toHaveBeenCalledWith (
20+ `${ config . OPENDEX_RPC_HOST } :${ config . OPENDEX_RPC_PORT } ` ,
21+ expect . any ( Object ) ,
22+ expect . any ( Object )
23+ ) ;
24+ setImmediate ( ( ) => {
25+ expect ( client . close ) . toHaveBeenCalledTimes ( 1 ) ;
26+ done ( ) ;
27+ } ) ;
28+ } ,
2229 } ) ;
2330 } ) ;
2431
Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ const getXudClient$ = (config: Config): Observable<XudClient> => {
2020 options
2121 ) ;
2222 subscriber . next ( client ) ;
23- subscriber . complete ( ) ;
23+ return ( ) => {
24+ client . close ( ) ;
25+ } ;
2426 } ) . pipe (
2527 catchError ( error => {
2628 if ( error . code === 'ENOENT' ) {
Original file line number Diff line number Diff line change 11import moment from 'moment' ;
2- import { Observable , Subject , timer , merge } from 'rxjs' ;
2+ import { Observable , Subject } from 'rxjs' ;
33import { take , tap } from 'rxjs/operators' ;
44import { curry } from 'ramda' ;
55
@@ -24,12 +24,7 @@ export const getStartShutdown$ = (): Observable<unknown> => {
2424 const shutdown$ = new Subject ( ) ;
2525 process . on ( 'SIGINT' , ( ) => shutdown$ . next ( ) ) ;
2626 process . on ( 'SIGTERM' , ( ) => shutdown$ . next ( ) ) ;
27- const ONE_MINUTE = 1000 * 60 ;
28- const ONE_HOUR = ONE_MINUTE * 60 ;
29- const restart$ = timer ( ONE_HOUR ) . pipe (
30- tap ( ( ) => console . log ( 'Restarting Arby to reduce memory usage.' ) )
31- ) ;
32- return merge ( shutdown$ . asObservable ( ) , restart$ ) . pipe ( take ( 1 ) ) ;
27+ return shutdown$ . asObservable ( ) . pipe ( take ( 1 ) ) ;
3328} ;
3429
3530const debugObservable = ( prefix : string , source : Observable < any > ) => {
You can’t perform that action at this time.
0 commit comments