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';
2
2
import { testConfig } from '../../test-utils' ;
3
3
import { errors } from '../errors' ;
4
4
import { getXudClient$ } from './client' ;
5
+ import { take } from 'rxjs/operators' ;
5
6
6
7
jest . mock ( '../../proto/xudrpc_grpc_pb' ) ;
7
8
jest . mock ( '../../proto/xudrpc_pb' ) ;
8
9
9
10
describe ( 'getXudClient$' , ( ) => {
10
11
test ( 'success' , done => {
11
- expect . assertions ( 2 ) ;
12
+ expect . assertions ( 3 ) ;
12
13
const config = testConfig ( ) ;
13
14
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
+ } ,
22
29
} ) ;
23
30
} ) ;
24
31
Original file line number Diff line number Diff line change @@ -20,7 +20,9 @@ const getXudClient$ = (config: Config): Observable<XudClient> => {
20
20
options
21
21
) ;
22
22
subscriber . next ( client ) ;
23
- subscriber . complete ( ) ;
23
+ return ( ) => {
24
+ client . close ( ) ;
25
+ } ;
24
26
} ) . pipe (
25
27
catchError ( error => {
26
28
if ( error . code === 'ENOENT' ) {
Original file line number Diff line number Diff line change 1
1
import moment from 'moment' ;
2
- import { Observable , Subject , timer , merge } from 'rxjs' ;
2
+ import { Observable , Subject } from 'rxjs' ;
3
3
import { take , tap } from 'rxjs/operators' ;
4
4
import { curry } from 'ramda' ;
5
5
@@ -24,12 +24,7 @@ export const getStartShutdown$ = (): Observable<unknown> => {
24
24
const shutdown$ = new Subject ( ) ;
25
25
process . on ( 'SIGINT' , ( ) => shutdown$ . next ( ) ) ;
26
26
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 ) ) ;
33
28
} ;
34
29
35
30
const debugObservable = ( prefix : string , source : Observable < any > ) => {
You can’t perform that action at this time.
0 commit comments