Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
remove connector.update (#2196)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbwhite authored and nklincoln committed Sep 21, 2017
1 parent 693c681 commit 94ee1d5
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 80 deletions.
21 changes: 0 additions & 21 deletions packages/composer-connector-proxy/lib/proxyconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,6 @@ class ProxyConnection extends Connection {
});
}

/**
* Updates an existing deployed business network definition.
* @param {SecurityContext} securityContext The participant's security context.
* @param {BusinessNetworkDefinition} businessNetworkDefinition The BusinessNetworkDefinition to deploy
* @return {Promise} A promise that is resolved once the business network
* artifacts have been updated, or rejected with an error.
*/
update(securityContext, businessNetworkDefinition) {
return businessNetworkDefinition.toArchive()
.then((businessNetworkArchive) => {
return new Promise((resolve, reject) => {
this.socket.emit('/api/connectionUpdate', this.connectionID, securityContext.securityContextID, businessNetworkArchive.toString('base64'), (error) => {
if (error) {
return reject(ProxyUtil.inflaterr(error));
}
resolve();
});
});
});
}

/**
* Undeploy a business network definition.
* @param {SecurityContext} securityContext The participant's security context.
Expand Down
26 changes: 1 addition & 25 deletions packages/composer-connector-proxy/test/proxyconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('ProxyConnection', () => {
const connectionProfile = 'defaultProfile';
const businessNetworkIdentifier = 'org-acme-biznet';
const connectionID = '3d382385-47a5-4be9-99b0-6b10166b9497';
const enrollmentID = 'alice1';
const enrollmentID = 'alice1';this;
const enrollmentSecret = 'suchs3cret';
const securityContextID = '9d05d73e-81bf-4d8a-a874-4b561670432e';
const serializedError = serializerr(new TypeError('such type error'));
Expand Down Expand Up @@ -167,31 +167,7 @@ describe('ProxyConnection', () => {

});

describe('#update', () => {

let mockBusinessNetworkDefinition;

beforeEach(() => {
mockBusinessNetworkDefinition = sinon.createStubInstance(BusinessNetworkDefinition);
mockBusinessNetworkDefinition.toArchive.resolves(Buffer.from('hello world'));
});

it('should send a update call to the connector server', () => {
mockSocket.emit.withArgs('/api/connectionUpdate', connectionID, securityContextID, 'aGVsbG8gd29ybGQ=', sinon.match.func).yields(null);
return connection.update(mockSecurityContext, mockBusinessNetworkDefinition)
.then(() => {
sinon.assert.calledOnce(mockSocket.emit);
sinon.assert.calledWith(mockSocket.emit, '/api/connectionUpdate', connectionID, securityContextID, 'aGVsbG8gd29ybGQ=', sinon.match.func);
});
});

it('should handle an error from the connector server', () => {
mockSocket.emit.withArgs('/api/connectionUpdate', connectionID, securityContextID, 'aGVsbG8gd29ybGQ=', sinon.match.func).yields(serializedError);
return connection.update(mockSecurityContext, mockBusinessNetworkDefinition)
.should.be.rejectedWith(TypeError, /such type error/);
});

});

describe('#undeploy', () => {

Expand Down
15 changes: 0 additions & 15 deletions packages/composer-connector-web/lib/webconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,21 +235,6 @@ class WebConnection extends Connection {
});
}

/**
* Updates an existing deployed business network definition.
* @abstract
* @param {SecurityContext} securityContext The participant's security context.
* @param {BusinessNetworkDefinition} businessNetworkDefinition The BusinessNetworkDefinition to deploy
* @return {Promise} A promise that is resolved once the business network
* artifacts have been updated, or rejected with an error.
*/
update(securityContext, businessNetworkDefinition) {
return businessNetworkDefinition.toArchive()
.then((buffer) => {
return this.invokeChainCode(securityContext, 'updateBusinessNetwork', [buffer.toString('base64')]);
});
}

/**
* Undeploy a business network definition.
* @abstract
Expand Down
19 changes: 0 additions & 19 deletions packages/composer-connector-web/test/webconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,26 +230,7 @@ describe('WebConnection', () => {

});

describe('#update', () => {

it('should update the business network', () => {
let mockBusinessNetwork = sinon.createStubInstance(BusinessNetworkDefinition);
mockBusinessNetwork.toArchive.resolves(Buffer.from('aGVsbG8gd29ybGQ=', 'base64'));
let mockContainer = sinon.createStubInstance(WebContainer);
let mockEngine = sinon.createStubInstance(Engine);
mockEngine.getContainer.returns(mockContainer);
WebConnection.addBusinessNetwork('org.acme.Business', 'devFabric1', '6eeb8858-eced-4a32-b1cd-2491f1e3718f');
WebConnection.addChaincode('6eeb8858-eced-4a32-b1cd-2491f1e3718f', mockContainer, mockEngine);
mockSecurityContext.getChaincodeID.returns('6eeb8858-eced-4a32-b1cd-2491f1e3718f');
sinon.stub(connection, 'invokeChainCode').resolves();
return connection.update(mockSecurityContext, mockBusinessNetwork)
.then(() => {
sinon.assert.calledOnce(connection.invokeChainCode);
sinon.assert.calledWith(connection.invokeChainCode, sinon.match.instanceOf(WebSecurityContext), 'updateBusinessNetwork', ['aGVsbG8gd29ybGQ=']);
});
});

});

describe('#undeploy', () => {

Expand Down

0 comments on commit 94ee1d5

Please sign in to comment.