@@ -33,41 +33,65 @@ describe('Action Info Unit Tests', () => {
3333 it ( 'should get public key, synced to chain, and block height' , async ( ) => {
3434 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
3535 identity_pubkey : 'some-pubkey' ,
36- synced_to_chain : ' true/false' ,
36+ synced_to_chain : true ,
3737 block_height : 'some-height' ,
3838 } ) ;
39+ grpc . sendCommand . withArgs ( 'getNetworkInfo' ) . resolves ( {
40+ num_nodes : 2 ,
41+ } ) ;
3942 await info . getInfo ( ) ;
4043 expect ( store . pubKey , 'to equal' , 'some-pubkey' ) ;
41- expect ( store . syncedToChain , 'to equal' , 'true/false' ) ;
44+ expect ( store . syncedToChain , 'to be' , true ) ;
45+ expect ( store . isSyncing , 'to be' , false ) ;
4246 expect ( store . blockHeight , 'to equal' , 'some-height' ) ;
4347 } ) ;
4448
45- it ( 'should return true if chain is synced' , async ( ) => {
49+ it ( 'should return true if chain and filter headers are synced' , async ( ) => {
4650 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
4751 synced_to_chain : true ,
4852 } ) ;
53+ grpc . sendCommand . withArgs ( 'getNetworkInfo' ) . resolves ( {
54+ num_nodes : 2 ,
55+ } ) ;
4956 const synced = await info . getInfo ( ) ;
5057 expect ( synced , 'to be' , true ) ;
5158 } ) ;
5259
53- it ( 'should set percentSynced' , async ( ) => {
54- const testTimestamp = new Date ( ) . getTime ( ) ;
60+ it ( 'should return false if chain is synced but not filter headers' , async ( ) => {
5561 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
56- synced_to_chain : false ,
57- best_header_timestamp : testTimestamp / 1000 ,
62+ synced_to_chain : true ,
5863 } ) ;
59- await info . getInfo ( ) ;
60- expect ( store . percentSynced , 'to be within' , 0 , 1 ) ;
64+ grpc . sendCommand . withArgs ( 'getNetworkInfo' ) . resolves ( {
65+ num_nodes : 1 ,
66+ } ) ;
67+ const synced = await info . getInfo ( ) ;
68+ expect ( synced , 'to be' , false ) ;
6169 } ) ;
6270
63- it ( 'should return false if chain is not synced' , async ( ) => {
71+ it ( 'should return false if chain is not synced but filter headers are ' , async ( ) => {
6472 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
6573 synced_to_chain : false ,
6674 } ) ;
75+ grpc . sendCommand . withArgs ( 'getNetworkInfo' ) . resolves ( {
76+ num_nodes : 2 ,
77+ } ) ;
6778 const synced = await info . getInfo ( ) ;
6879 expect ( synced , 'to be' , false ) ;
6980 } ) ;
7081
82+ it ( 'should set percentSynced' , async ( ) => {
83+ const testTimestamp = new Date ( ) . getTime ( ) ;
84+ grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
85+ synced_to_chain : false ,
86+ best_header_timestamp : testTimestamp / 1000 ,
87+ } ) ;
88+ grpc . sendCommand . withArgs ( 'getNetworkInfo' ) . resolves ( {
89+ num_nodes : 2 ,
90+ } ) ;
91+ await info . getInfo ( ) ;
92+ expect ( store . percentSynced , 'to be within' , 0 , 1 ) ;
93+ } ) ;
94+
7195 it ( 'should log error on failure' , async ( ) => {
7296 grpc . sendCommand . rejects ( ) ;
7397 await info . getInfo ( ) ;
@@ -89,6 +113,9 @@ describe('Action Info Unit Tests', () => {
89113 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
90114 synced_to_chain : 'true' ,
91115 } ) ;
116+ grpc . sendCommand . withArgs ( 'getNetworkInfo' ) . resolves ( {
117+ num_nodes : 2 ,
118+ } ) ;
92119 await info . getInfo ( ) ;
93120 info . initLoaderSyncing ( ) ;
94121 expect ( nav . goHome , 'was called once' ) ;
@@ -98,12 +125,18 @@ describe('Action Info Unit Tests', () => {
98125 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
99126 synced_to_chain : false ,
100127 } ) ;
128+ grpc . sendCommand . withArgs ( 'getNetworkInfo' ) . resolves ( {
129+ num_nodes : 1 ,
130+ } ) ;
101131 await info . getInfo ( ) ;
102132 info . initLoaderSyncing ( ) ;
103133 expect ( nav . goLoaderSyncing , 'was called once' ) ;
104134 grpc . sendCommand . withArgs ( 'getInfo' ) . resolves ( {
105135 synced_to_chain : true ,
106136 } ) ;
137+ grpc . sendCommand . withArgs ( 'getNetworkInfo' ) . resolves ( {
138+ num_nodes : 2 ,
139+ } ) ;
107140 await info . getInfo ( ) ;
108141 expect ( nav . goHome , 'was called once' ) ;
109142 } ) ;
0 commit comments