File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,10 @@ class HTTP extends Server {
148148 } ) ;
149149 } ) ;
150150
151+ this . get ( '/uptime' , async ( req , res ) => {
152+ res . json ( 200 , { uptime : this . node . uptime ( ) . toString ( ) } ) ;
153+ } ) ;
154+
151155 // UTXO by address
152156 this . get ( '/coin/address/:address' , async ( req , res ) => {
153157 const valid = Validator . fromRequest ( req ) ;
Original file line number Diff line number Diff line change 6262 "istanbul" : " ^1.1.0-alpha.1" ,
6363 "jsdoc" : " ^3.5.5" ,
6464 "mocha" : " ^5.2.0" ,
65+ "mockdate" : " ^2.0.2" ,
6566 "uglify-es" : " ^3.3.9" ,
6667 "uglifyjs-webpack-plugin" : " ^1.2.5" ,
6768 "webpack" : " ^4.11.1" ,
Original file line number Diff line number Diff line change @@ -69,6 +69,19 @@ describe('HTTP', function() {
6969 assert . strictEqual ( info . chain . height , 0 ) ;
7070 } ) ;
7171
72+ it ( 'should get uptime' , async ( ) => {
73+ const MockDate = require ( 'mockdate' ) ;
74+ const mockedNow = 1225476600 ;
75+ MockDate . set ( mockedNow * 1000 ) ;
76+
77+ node . startTime = ( mockedNow - 100 ) * 1000 ;
78+ const uptime = await nclient . getUptime ( ) ;
79+ assert . strictEqual ( uptime . uptime , '100' ) ;
80+
81+ MockDate . reset ( ) ;
82+ node . startTime = - 1 ;
83+ } ) ;
84+
7285 it ( 'should get wallet info' , async ( ) => {
7386 const info = await wallet . getInfo ( ) ;
7487 assert . strictEqual ( info . id , 'test' ) ;
You can’t perform that action at this time.
0 commit comments