From 582ff25b8051ac11ac2df777c5c801eb094bef45 Mon Sep 17 00:00:00 2001 From: shuse2 Date: Sat, 18 May 2019 20:31:57 +0200 Subject: [PATCH] temp --- .../src/modules/http_api/controllers/node.js | 7 ++++--- .../unit/modules/http_api/controllers/node.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/framework/src/modules/http_api/controllers/node.js b/framework/src/modules/http_api/controllers/node.js index efbcbe57b4d..9bf46262b07 100644 --- a/framework/src/modules/http_api/controllers/node.js +++ b/framework/src/modules/http_api/controllers/node.js @@ -44,6 +44,7 @@ function NodeController(scope) { components: { storage: scope.components.storage, cache: scope.components.cache, + logger: scope.components.logger, }, config: scope.config, channel: scope.channel, @@ -354,10 +355,10 @@ async function getConfirmedTransactionCount() { } return confirmed; } catch (error) { - library.logger.warn("Transaction count wasn't cached", error); + library.components.logger.warn("Transaction count wasn't cached", error); } } - const confirmed = await library.storage.entities.Transaction.count(); + const confirmed = await library.components.storage.entities.Transaction.count(); // only update cache if ready if (library.components.cache.cacheReady) { try { @@ -369,7 +370,7 @@ async function getConfirmedTransactionCount() { ); } catch (error) { // Ignore error and just put warn - library.logger.warn("Transaction count wasn't cached", error); + library.components.logger.warn("Transaction count wasn't cached", error); } } return confirmed; diff --git a/framework/test/mocha/unit/modules/http_api/controllers/node.js b/framework/test/mocha/unit/modules/http_api/controllers/node.js index 7f14261d16f..046aac0af89 100644 --- a/framework/test/mocha/unit/modules/http_api/controllers/node.js +++ b/framework/test/mocha/unit/modules/http_api/controllers/node.js @@ -24,6 +24,8 @@ describe('node/api', () => { let library; let privateLibrary; let channelStub; + let cacheStub; + let loggerStub; let storageStub; let configStub; let getStatus; @@ -33,17 +35,30 @@ describe('node/api', () => { invoke: sinonSandbox.stub().resolves(), }; + loggerStub = { + warn: sinonSandbox.stub(), + }; + + cacheStub = { + cacheReady: sinonSandbox.stub(), + }; + storageStub = { entities: { Block: { get: sinonSandbox.stub().resolves([]), }, + Transaction: { + count: sinonSandbox.stub(), + }, }, }; library = { components: { storage: storageStub, + cache: cacheStub, + logger: loggerStub, }, config: configStub, channel: channelStub,