diff --git a/packages/composer-runtime/lib/engine.js b/packages/composer-runtime/lib/engine.js index 5de640a25c..07ceae836d 100644 --- a/packages/composer-runtime/lib/engine.js +++ b/packages/composer-runtime/lib/engine.js @@ -15,7 +15,6 @@ 'use strict'; const Logger = require('composer-common').Logger; -const semver = require('semver'); const util = require('util'); const LOG = Logger.getLog('Engine'); @@ -208,12 +207,6 @@ class Engine { LOG.debug(method, 'Updating metanetwork in $sysdata collection'); const newRuntimeVersion = this.container.getVersion(); - // Check our new version should be greater than or equal but only a micro version change. - const range = `^${metanetwork.runtimeVersion}`; - if (!semver.satisfies(newRuntimeVersion, range)) { - throw new Error(`Cannot upgrade business network. New composer runtime version of (${newRuntimeVersion}) is not compatible with (${metanetwork.runtimeVersion}). Composer runtime has changed major or minor version and cannot be upgraded.`); - } - try { // update the metanetwork with new identifier and version const networkId = context.getBusinessNetworkDefinition().getIdentifier(); diff --git a/packages/composer-runtime/package.json b/packages/composer-runtime/package.json index 907e46d47f..c8b5fdf33e 100644 --- a/packages/composer-runtime/package.json +++ b/packages/composer-runtime/package.json @@ -89,7 +89,6 @@ "fast-json-patch": "1.1.8", "request": "2.81.0", "request-promise-any": "1.0.5", - "semver": "5.3.0", "sha.js": "2.4.8", "source-map": "0.5.6", "uuid": "3.0.1" diff --git a/packages/composer-runtime/test/engine.js b/packages/composer-runtime/test/engine.js index 73a57d683d..d7e3b4eb41 100644 --- a/packages/composer-runtime/test/engine.js +++ b/packages/composer-runtime/test/engine.js @@ -233,17 +233,21 @@ describe('Engine', () => { sinon.assert.calledOnce(mockContext.transactionEnd); }); - it('should throw error if upgrade not allowed', async () => { + it('should NOT throw error if upgrading from a much older version', async () => { const sysdata = sinon.createStubInstance(DataCollection); mockContainer.getVersion.returns('0.21.0'); + await engine.upgrade(mockContext, '', sysdata, {runtimeVersion:'0.20.0'}); + sinon.assert.calledOnce(sysdata.update); + sinon.assert.calledWith(sysdata.update, 'metanetwork', { + '$class': 'org.hyperledger.composer.system.Network', + 'networkId': 'test-network@1.0.0', + 'runtimeVersion': '0.21.0' + }); + sinon.assert.calledOnce(mockRegistryManager.createDefaults); + sinon.assert.calledOnce(mockContext.transactionPrepare); + sinon.assert.calledOnce(mockContext.transactionCommit); + sinon.assert.calledOnce(mockContext.transactionEnd); - try { - await engine.upgrade(mockContext, '', sysdata, {runtimeVersion:'0.20.0'}); - should.fail('Expected error to be thrown'); - } catch(err) { - err.message.should.match(/Cannot upgrade/); - sinon.assert.notCalled(sysdata.update); - } }); it('should rollback if sysdata update fails', async () => {