Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed May 18, 2019
1 parent d05b954 commit 582ff25
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 4 additions & 3 deletions framework/src/modules/http_api/controllers/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions framework/test/mocha/unit/modules/http_api/controllers/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ describe('node/api', () => {
let library;
let privateLibrary;
let channelStub;
let cacheStub;
let loggerStub;
let storageStub;
let configStub;
let getStatus;
Expand All @@ -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,
Expand Down

0 comments on commit 582ff25

Please sign in to comment.