Skip to content

Commit

Permalink
Merge pull request #4570 from LiskHQ/4569-bugix_forging
Browse files Browse the repository at this point in the history
Fill-pool shouldn't be called when delegate is not enabled to forge or if node is syncing - Closes #4569
  • Loading branch information
ManuGowda committed Nov 28, 2019
2 parents 49cd4aa + ef56de3 commit c5c7236
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion framework/src/modules/chain/chain.js
Expand Up @@ -520,7 +520,6 @@ module.exports = class Chain {
async _forgingTask() {
return this.scope.sequence.add(async () => {
try {
await this.forger.beforeForge();
if (!this.forger.delegatesEnabled()) {
this.logger.debug('No delegates are enabled');
return;
Expand All @@ -529,6 +528,7 @@ module.exports = class Chain {
this.logger.debug('Client not ready to forge');
return;
}
await this.forger.beforeForge();
await this.forger.forge();
} catch (err) {
this.logger.error({ err });
Expand Down
4 changes: 4 additions & 0 deletions framework/test/mocha/unit/modules/chain/chain.js
Expand Up @@ -440,6 +440,7 @@ describe('Chain', () => {
await chain.bootstrap();
sinonSandbox.stub(chain.forger, 'delegatesEnabled').returns(true);
sinonSandbox.stub(chain.forger, 'forge');
sinonSandbox.stub(chain.forger, 'beforeForge');
sinonSandbox.stub(chain.scope.sequence, 'add').callsFake(async fn => {
await fn();
});
Expand All @@ -458,6 +459,7 @@ describe('Chain', () => {
'No delegates are enabled',
);
expect(chain.scope.sequence.add).to.be.called;
expect(chain.forger.beforeForge).to.not.be.called;
expect(chain.forger.forge).to.not.be.called;
});

Expand All @@ -473,13 +475,15 @@ describe('Chain', () => {
'Client not ready to forge',
);
expect(chain.scope.sequence.add).to.be.called;
expect(chain.forger.beforeForge).to.not.be.called;
expect(chain.forger.forge).to.not.be.called;
});

it('should execute forger.forge otherwise', async () => {
await chain._forgingTask();

expect(chain.scope.sequence.add).to.be.called;
expect(chain.forger.beforeForge).to.be.called;
expect(chain.forger.forge).to.be.called;
});
});
Expand Down

0 comments on commit c5c7236

Please sign in to comment.