From 7e106ba6157bc75c005364dab5624c9a1b97aa35 Mon Sep 17 00:00:00 2001 From: Karl Ranna Date: Mon, 17 Sep 2018 11:31:07 +0300 Subject: [PATCH] Display blocks height in notification bar while syncing --- src/action/info.js | 5 ++++- test/unit/action/info.spec.js | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/action/info.js b/src/action/info.js index 60484cffe..117e2f76e 100644 --- a/src/action/info.js +++ b/src/action/info.js @@ -32,7 +32,10 @@ class InfoAction { this.startingSyncTimestamp = response.best_header_timestamp || 0; } if (!response.synced_to_chain) { - this._notification.display({ msg: 'Syncing to chain', wait: true }); + this._notification.display({ + msg: `Syncing to chain (block: ${response.block_height})`, + wait: true, + }); log.info(`Syncing to chain ... block height: ${response.block_height}`); this._store.percentSynced = this.calcPercentSynced(response); } diff --git a/test/unit/action/info.spec.js b/test/unit/action/info.spec.js index bf93f044e..7f4c2ab4c 100644 --- a/test/unit/action/info.spec.js +++ b/test/unit/action/info.spec.js @@ -42,6 +42,28 @@ describe('Action Info Unit Tests', () => { expect(store.blockHeight, 'to equal', 'some-height'); }); + it('should show notification if syncing', async () => { + grpc.sendCommand.withArgs('getInfo').resolves({ + synced_to_chain: false, + block_height: 1234, + }); + await info.getInfo(); + expect(notification.display, 'was called once'); + expect(notification.display, 'was called with', { + msg: 'Syncing to chain (block: 1234)', + wait: true, + }); + }); + + it('should not show notification if synced', async () => { + grpc.sendCommand.withArgs('getInfo').resolves({ + synced_to_chain: true, + block_height: 1234, + }); + await info.getInfo(); + expect(notification.display, 'was not called'); + }); + it('should return true if chain is synced', async () => { grpc.sendCommand.withArgs('getInfo').resolves({ synced_to_chain: true,