diff --git a/packages/caliper-fabric/lib/FabricConnectorFactory.js b/packages/caliper-fabric/lib/FabricConnectorFactory.js index a6b707e8e..066f50db9 100644 --- a/packages/caliper-fabric/lib/FabricConnectorFactory.js +++ b/packages/caliper-fabric/lib/FabricConnectorFactory.js @@ -40,11 +40,14 @@ const _determineInstalledNodeSDKVersion = () => { } }; -const _loadAppropriateConnectorClass = (installedNodeSDKVersion, useGateway) => { +const _loadAppropriateConnectorClass = (installedNodeSDKVersion) => { let connectorPath; let walletFacadeFactoryPath; if (semver.satisfies(installedNodeSDKVersion, '=1.x')) { + const useGateway = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.Enabled, false); + Logger.info(`Initializing ${useGateway ? 'gateway' : 'standard' } connector compatible with installed SDK: ${installedNodeSDKVersion}`); + if (!useGateway) { connectorPath = NEW_V1_NODE_CONNECTOR; walletFacadeFactoryPath = NEW_V1_WALLET_FACADE_FACTORY; @@ -58,12 +61,9 @@ const _loadAppropriateConnectorClass = (installedNodeSDKVersion, useGateway) => } } } else if (semver.satisfies(installedNodeSDKVersion, '=2.x')) { - if (!useGateway) { - throw new Error(`Caliper currently only supports gateway based operation using the ${installedNodeSDKVersion} Fabric-SDK. Please retry with the gateway flag`); - } else { - connectorPath = NEW_V2_GATEWAY_CONNECTOR; - walletFacadeFactoryPath = NEW_V2_WALLET_FACADE_FACTORY; - } + Logger.info(`Initializing gateway connector compatible with installed SDK: ${installedNodeSDKVersion}`); + connectorPath = NEW_V2_GATEWAY_CONNECTOR; + walletFacadeFactoryPath = NEW_V2_WALLET_FACADE_FACTORY; } else { throw new Error(`Installed SDK version ${installedNodeSDKVersion} did not match any compatible Fabric connectors`); } @@ -96,10 +96,7 @@ const connectorFactory = async (workerIndex) => { } const installedNodeSDKVersion = _determineInstalledNodeSDKVersion(); - const useGateway = ConfigUtil.get(ConfigUtil.keys.Fabric.Gateway.Enabled, false); - - Logger.info(`Initializing ${useGateway ? 'gateway' : 'standard' } connector compatible with installed SDK: ${installedNodeSDKVersion}`); - const {fabricConnectorClass, walletFacadeFactoryClass} = _loadAppropriateConnectorClass(installedNodeSDKVersion, useGateway); + const {fabricConnectorClass, walletFacadeFactoryClass} = _loadAppropriateConnectorClass(installedNodeSDKVersion); const connectorConfiguration = await new ConnectorConfigurationFactory().create(connectorConfigurationFile, new walletFacadeFactoryClass()); const fabricConnector = new fabricConnectorClass(connectorConfiguration, workerIndex, 'fabric'); diff --git a/packages/caliper-fabric/test/FabricConnectorFactory.js b/packages/caliper-fabric/test/FabricConnectorFactory.js index cb0fa3d64..1d5278d34 100644 --- a/packages/caliper-fabric/test/FabricConnectorFactory.js +++ b/packages/caliper-fabric/test/FabricConnectorFactory.js @@ -112,7 +112,7 @@ describe('A Fabric Connector Factory', () => { mockery.deregisterAll(); }); - it('should create a V1 Gateway connector when a 1.4 fabric library is bound, usegateway was specified', async () => { + it('should create a V1 Gateway connector when a 1.4 fabric library is bound and gateway is specified', async () => { mockery.registerMock('fabric-network', { DefaultEventHandlerStrategies, DefaultQueryHandlerStrategies, @@ -129,7 +129,7 @@ describe('A Fabric Connector Factory', () => { mockery.deregisterAll(); }); - it('should create a V2 Gateway connector when a 2.x fabric library is bound, usegateway was specified', async () => { + it('should create a V2 Gateway connector when a 2.x fabric library is bound', async () => { mockery.registerMock('fabric-network', { DefaultEventHandlerStrategies, DefaultQueryHandlerStrategies, @@ -137,13 +137,13 @@ describe('A Fabric Connector Factory', () => { }); mockery.registerMock('fabric-network/package', {version: '2.2.1'}); ConfigUtil.set(ConfigUtil.keys.NetworkConfig, path.resolve(__dirname, v2Config)); - ConfigUtil.set(ConfigUtil.keys.Fabric.Gateway.Enabled, true); + ConfigUtil.set(ConfigUtil.keys.Fabric.Gateway.Enabled, false); const connector = await ConnectorFactory(1); connector.constructor.name.should.equal('V2FabricGateway'); mockery.deregisterAll(); }); - it('should create a V1 Fabric connector if a 1.4 fabric library is bound and usegateway was not specified', async () => { + it('should create a V1 Fabric connector if a 1.4 fabric library is bound gateway not specified', async () => { mockery.registerMock('fabric-network', { DefaultEventHandlerStrategies, DefaultQueryHandlerStrategies, diff --git a/packages/caliper-tests-integration/fabric_tests/run.sh b/packages/caliper-tests-integration/fabric_tests/run.sh index a6fe3af37..e830c124a 100755 --- a/packages/caliper-tests-integration/fabric_tests/run.sh +++ b/packages/caliper-tests-integration/fabric_tests/run.sh @@ -38,7 +38,7 @@ export CALIPER_PROJECTCONFIG=../caliper.yaml dispose () { docker ps -a - ${CALL_METHOD} launch manager --caliper-workspace phase7 --caliper-flow-only-end --caliper-fabric-gateway-enabled + ${CALL_METHOD} launch manager --caliper-workspace phase7 --caliper-flow-only-end } # needed, since the peer looks for the latest, which is no longer on dockerhub @@ -112,7 +112,7 @@ if [[ "${BIND_IN_PACKAGE_DIR}" = "true" ]]; then fi # PHASE 6: testing through the gateway API (v2 SDK) -${CALL_METHOD} launch manager --caliper-workspace phase6 --caliper-flow-only-test --caliper-fabric-gateway-enabled +${CALL_METHOD} launch manager --caliper-workspace phase6 --caliper-flow-only-test rc=$? if [[ ${rc} != 0 ]]; then echo "Failed CI step 7"; @@ -121,7 +121,7 @@ if [[ ${rc} != 0 ]]; then fi # PHASE 7: just disposing of the network -${CALL_METHOD} launch manager --caliper-workspace phase7 --caliper-flow-only-end --caliper-fabric-gateway-enabled +${CALL_METHOD} launch manager --caliper-workspace phase7 --caliper-flow-only-end rc=$? if [[ ${rc} != 0 ]]; then echo "Failed CI step 8";