From 609cdf916f277669023fe3dd287ad9a408740969 Mon Sep 17 00:00:00 2001 From: shuse2 Date: Wed, 11 Sep 2019 23:52:36 +0200 Subject: [PATCH 1/2] :bug: Fix detached function not to throw --- .../src/modules/chain/rounds/delegates.js | 6 +++++- .../modules/chain/submodules/delegates.js | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/framework/src/modules/chain/rounds/delegates.js b/framework/src/modules/chain/rounds/delegates.js index a2679e0ed20..1b0f1263fc3 100644 --- a/framework/src/modules/chain/rounds/delegates.js +++ b/framework/src/modules/chain/rounds/delegates.js @@ -217,7 +217,11 @@ class Delegates { cause, }; - await this.storage.entities.Account.insertFork(fork); + try { + await this.storage.entities.Account.insertFork(fork); + } catch (err) { + this.logger.warn(err, 'Failed to insert fork info'); + } this.channel.publish('chain:delegates:fork', fork); } diff --git a/framework/test/mocha/unit/modules/chain/submodules/delegates.js b/framework/test/mocha/unit/modules/chain/submodules/delegates.js index 0aebbad091a..9ac47add580 100644 --- a/framework/test/mocha/unit/modules/chain/submodules/delegates.js +++ b/framework/test/mocha/unit/modules/chain/submodules/delegates.js @@ -34,6 +34,7 @@ describe('delegates', () => { const mockLogger = { debug: sinonSandbox.stub(), info: sinonSandbox.stub(), + warn: sinonSandbox.stub(), error: sinonSandbox.stub(), }; const mockStorage = { @@ -112,6 +113,25 @@ describe('delegates', () => { fork, ); }); + + it('should not throw an error when the database fails', async () => { + const fork = { + delegatePublicKey: dummyBlock.generatorPublicKey, + blockTimestamp: dummyBlock.timestamp, + blockId: dummyBlock.id, + blockHeight: dummyBlock.height, + previousBlockId: dummyBlock.previousBlock, + cause, + }; + mockStorage.entities.Account.insertFork.rejects( + new Error('invalid DB state'), + ); + await delegatesModule.fork(dummyBlock, cause); + expect(mockChannel.publish).to.be.calledWithExactly( + 'chain:delegates:fork', + fork, + ); + }); }); describe('#generateDelegateList', () => { From 87bf6d04557fc9e9f37c17b9809344ca0378574c Mon Sep 17 00:00:00 2001 From: Shusetsu Toda Date: Thu, 12 Sep 2019 10:59:27 +0200 Subject: [PATCH 2/2] :arrow_up: Bump version --- framework/package-lock.json | 2 +- framework/package.json | 2 +- sdk/package-lock.json | 2 +- sdk/package.json | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/framework/package-lock.json b/framework/package-lock.json index 3d0b3e9d75c..289fade5402 100644 --- a/framework/package-lock.json +++ b/framework/package-lock.json @@ -1,6 +1,6 @@ { "name": "lisk-framework", - "version": "0.4.3", + "version": "0.4.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/framework/package.json b/framework/package.json index 4d95c798f87..958de38afdb 100644 --- a/framework/package.json +++ b/framework/package.json @@ -1,6 +1,6 @@ { "name": "lisk-framework", - "version": "0.4.3", + "version": "0.4.4", "description": "Lisk blockchain application platform", "author": "Lisk Foundation , lightcurve GmbH ", "license": "Apache-2.0", diff --git a/sdk/package-lock.json b/sdk/package-lock.json index 4283116a1ff..12a11815627 100644 --- a/sdk/package-lock.json +++ b/sdk/package-lock.json @@ -1,6 +1,6 @@ { "name": "lisk-sdk", - "version": "2.3.3", + "version": "2.3.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/sdk/package.json b/sdk/package.json index bf119249d69..2a0daa319cc 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -1,6 +1,6 @@ { "name": "lisk-sdk", - "version": "2.3.3", + "version": "2.3.4", "description": "Official SDK for the Lisk blockchain application platform", "author": "Lisk Foundation , lightcurve GmbH ", "license": "Apache-2.0", @@ -25,6 +25,6 @@ "@liskhq/bignum": "1.3.1", "@liskhq/lisk-cryptography": "2.3.0", "@liskhq/lisk-transactions": "2.3.1", - "lisk-framework": "0.4.3" + "lisk-framework": "0.4.4" } }