'use strict' ; import * as path from 'path' ; import * as vscode from 'vscode' ; import * as chai from 'chai' ; import * as sinon from 'sinon' ; import * as sinonChai from 'sinon-chai' ; import { TestUtil } from '../TestUtil' ; import { VSCodeBlockchainOutputAdapter } from '../../extension/logging/VSCodeBlockchainOutputAdapter' ; import { ExtensionCommands } from '../../ExtensionCommands' ; import { FabricEnvironmentConnection } from 'ibm-blockchain-platform-environment-v1' ; import { FabricEnvironmentManager } from '../../extension/fabric/environments/FabricEnvironmentManager' ; import { FabricEnvironmentRegistryEntry , FabricRuntimeUtil , LogType , EnvironmentType , FabricSmartContractDefinition , FabricGatewayRegistryEntry } from 'ibm-blockchain-platform-common' ; import { PackageRegistryEntry } from '../../extension/registries/PackageRegistryEntry' ; import { FabricGatewayConnectionManager } from '../../extension/fabric/FabricGatewayConnectionManager' ; import { FabricGatewayConnection } from 'ibm-blockchain-platform-gateway-v1' ; import { TransactionView } from '../../extension/webview/TransactionView' ; import { GlobalState } from '../../extension/util/GlobalState' ; import * as openTransactionViewCommand from '../../extension/commands/openTransactionViewCommand' ; import ISmartContract from '../../extension/interfaces/ISmartContract' ; import ITransaction from '../../extension/interfaces/ITransaction' ; import IAssociatedTxData from '../../extension/interfaces/IAssociatedTxData' ; chai . use ( sinonChai ) ; const mockTransactionViewParams = { gatewayName : 'my gateway' , smartContracts : [ ] , preselectedSmartContract : undefined , preselectedTransaction : undefined , associatedTxdata : { } , } ; const transactionOne = { name : 'transactionOne' , parameters : [ { description : '' , name : 'name' , schema : { } } ] , returns : { type : '' } , tag : [ 'submit' ] } ; const transactionTwo = { name : 'transactionTwo' , parameters : [ { description : '' , name : 'size' , schema : { } } ] , returns : { type : '' } , tag : [ 'submit' ] } ; describe ( 'deployCommand' , ( ) => { const mySandBox = sinon . createSandbox ( ) ; before ( async ( ) => { await TestUtil . setupTests ( mySandBox ) ; } ) ; describe ( 'deploySmartContract' , ( ) => { let fabricRuntimeMock ; let executeCommandStub ; let logSpy ; let environmentConnectionStub ; let environmentRegistryEntry ; let packageRegistryEntry ; let fabricClientConnectionMock ; let getConnectionStub ; let fabricConnectionManager ; let gatewayRegistryEntry ; let getGatewayRegistryStub ; beforeEach ( async ( ) => { executeCommandStub = mySandBox . stub ( vscode . commands , 'executeCommand' ) ; executeCommandStub . withArgs ( ExtensionCommands . INSTALL_SMART_CONTRACT ) . resolves ( [ 'myPackageId' , undefined ] ) ; executeCommandStub . withArgs ( ExtensionCommands . APPROVE_SMART_CONTRACT ) . resolves ( ) ; executeCommandStub . withArgs ( ExtensionCommands . COMMIT_SMART_CONTRACT ) . resolves ( ) ; executeCommandStub . withArgs ( ExtensionCommands . CONNECT_TO_ENVIRONMENT ) . resolves ( ) ; executeCommandStub . withArgs ( ExtensionCommands . CONNECT_TO_GATEWAY ) . resolves ( ) ; executeCommandStub . callThrough ( ) ; fabricRuntimeMock = mySandBox . createStubInstance ( FabricEnvironmentConnection ) ; fabricRuntimeMock . connect . resolves ( ) ; fabricRuntimeMock . commitSmartContractDefinition . resolves ( ) ; environmentConnectionStub = mySandBox . stub ( FabricEnvironmentManager . instance ( ) , 'getConnection' ) . returns ( ( fabricRuntimeMock ) ) ; environmentRegistryEntry = new FabricEnvironmentRegistryEntry ( ) ; environmentRegistryEntry . name = FabricRuntimeUtil . LOCAL_FABRIC ; environmentRegistryEntry . managedRuntime = true ; environmentRegistryEntry . environmentType = EnvironmentType . LOCAL_MICROFAB_ENVIRONMENT ; packageRegistryEntry = new PackageRegistryEntry ( { name : 'vscode-pkg-1' , path : path . join ( 'myPath' , 'vscode-pkg-1@0.0.1.tar.gz' ) , version : '0.0.1' , sizeKB : 23.45 } ) ; logSpy = mySandBox . spy ( VSCodeBlockchainOutputAdapter . instance ( ) , 'log' ) ; fabricClientConnectionMock = mySandBox . createStubInstance ( FabricGatewayConnection ) ; fabricClientConnectionMock . connect . resolves ( ) ; const map = new Map < string , Array < string > > ( ) ; map . set ( 'myChannel' , [ 'peerOne' ] ) ; fabricClientConnectionMock . createChannelMap . resolves ( map ) ; fabricConnectionManager = FabricGatewayConnectionManager . instance ( ) ; getConnectionStub = mySandBox . stub ( fabricConnectionManager , 'getConnection' ) . returns ( fabricClientConnectionMock ) ; fabricConnectionManager = FabricGatewayConnectionManager . instance ( ) ; gatewayRegistryEntry = new FabricGatewayRegistryEntry ( ) ; gatewayRegistryEntry . name = 'myGateway' ; getGatewayRegistryStub = mySandBox . stub ( fabricConnectionManager , 'getGatewayRegistryEntry' ) ; getGatewayRegistryStub . resolves ( gatewayRegistryEntry ) ; fabricClientConnectionMock . getInstantiatedChaincode . resolves ( [ { name : 'mySmartContract' , version : '0.0.1' } ] ) ; fabricClientConnectionMock . getChannelPeersInfo . resolves ( [ { name : 'peerOne' , mspID : 'org1msp' } , { name : 'peerTwo' , mspID : 'org1msp' } ] ) ; fabricClientConnectionMock . getMetadata . resolves ( { contracts : { 'my-contract' : { name : 'my-contract' , transactions : [ transactionOne , transactionTwo , ] , } , 'org.hyperledger.fabric' : { name : 'org.hyperledger.fabric' , transactions : [ { name : 'GetMetadata' } ] } } } ) ; } ) ; afterEach ( async ( ) => { mySandBox . restore ( ) ; } ) ; it ( 'should deploy the smart contract through the command' , async ( ) => { const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; orgMap . set ( 'Org2MSP' , [ 'peerTwo' , 'peerThree' ] ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT , orgMap , packageRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . APPROVE_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . COMMIT_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; logSpy . should . have . been . calledWith ( LogType . INFO , 'Deploy Smart Contract' ) ; logSpy . should . have . been . calledWith ( LogType . SUCCESS , 'Successfully deployed smart contract' ) ; } ) ; it ( 'should deploy the smart contract through the command with endorsement policy' , async ( ) => { const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , undefined , `OutOf(1, 'Org1.member', 'Org2.member')` ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT , orgMap , packageRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . APPROVE_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' , `OutOf(1, 'Org1.member', 'Org2.member')` ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . COMMIT_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' , `OutOf(1, 'Org1.member', 'Org2.member')` ) ) ; logSpy . should . have . been . calledWith ( LogType . INFO , 'Deploy Smart Contract' ) ; logSpy . should . have . been . calledWith ( LogType . SUCCESS , 'Successfully deployed smart contract' ) ; } ) ; it ( 'should deploy the smart contract through the command but not commit' , async ( ) => { const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , false , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT , orgMap , packageRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . APPROVE_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; executeCommandStub . should . not . have . been . calledWith ( ExtensionCommands . COMMIT_SMART_CONTRACT ) ; logSpy . should . have . been . calledWith ( LogType . INFO , 'Deploy Smart Contract' ) ; logSpy . should . have . been . calledWith ( LogType . SUCCESS , 'Partially deployed smart contract - commit not performed' ) ; } ) ; it ( 'should return if no connection' , async ( ) => { const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; environmentConnectionStub . returns ( undefined ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . not . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT ) ; } ) ; it ( 'should handle error from install' , async ( ) => { const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; executeCommandStub . withArgs ( ExtensionCommands . INSTALL_SMART_CONTRACT ) . resolves ( [ undefined , 'other' ] ) ; const error = new Error ( 'Package was not installed. No packageId was returned' ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT , orgMap , packageRegistryEntry ) ; executeCommandStub . should . not . have . been . calledWith ( ExtensionCommands . APPROVE_SMART_CONTRACT ) ; logSpy . should . have . been . calledWith ( LogType . ERROR , `Failed to deploy smart contract, ${ error . message }` , `Failed to deploy smart contract, ${ error . toString ( ) }` ) ; } ) ; it ( 'should handle error from approve' , async ( ) => { const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; const error = new Error ( 'something has gone wrong' ) ; executeCommandStub . withArgs ( ExtensionCommands . APPROVE_SMART_CONTRACT ) . resolves ( error ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT , orgMap , packageRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . APPROVE_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; executeCommandStub . should . not . have . been . calledWith ( ExtensionCommands . COMMIT_SMART_CONTRACT ) ; logSpy . should . have . been . calledWith ( LogType . ERROR , `Failed to deploy smart contract, ${ error . message }` , `Failed to deploy smart contract, ${ error . toString ( ) }` ) ; } ) ; it ( 'should handle error from commit' , async ( ) => { const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; const error = new Error ( 'something has gone wrong' ) ; executeCommandStub . withArgs ( ExtensionCommands . COMMIT_SMART_CONTRACT ) . resolves ( error ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT , orgMap , packageRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . APPROVE_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . COMMIT_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; logSpy . should . have . been . calledWith ( LogType . ERROR , `Failed to deploy smart contract, ${ error . message }` , `Failed to deploy smart contract, ${ error . toString ( ) }` ) ; } ) ; it ( 'should be able to pass a different maps for installing & improving and committing' , async ( ) => { const installApproveMap = new Map < string , string [ ] > ( ) ; const commitMap = new Map < string , string [ ] > ( ) ; installApproveMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; commitMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; commitMap . set ( 'Org2MSP' , [ 'peerTwo' , 'peerThree' ] ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , installApproveMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 ) , commitMap ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT , installApproveMap , packageRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . APPROVE_SMART_CONTRACT , 'myOrderer' , 'myChannel' , installApproveMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . COMMIT_SMART_CONTRACT , 'myOrderer' , 'myChannel' , commitMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; logSpy . should . have . been . calledWith ( LogType . INFO , 'Deploy Smart Contract' ) ; logSpy . should . have . been . calledWith ( LogType . SUCCESS , 'Successfully deployed smart contract' ) ; } ) ; it ( 'should update the TransactionView\'s smart contract when it changes the smart contract' , async ( ) => { const context = GlobalState . getExtensionContext ( ) ; const postMessageStub = mySandBox . stub ( ) . resolves ( ) ; const createWebviewPanelStub = mySandBox . stub ( vscode . window , 'createWebviewPanel' ) ; createWebviewPanelStub . returns ( { title : 'Transaction Page' , webview : { postMessage : postMessageStub , onDidReceiveMessage : mySandBox . stub ( ) , asWebviewUri : mySandBox . stub ( ) } , reveal : mySandBox . stub ( ) , dispose : mySandBox . stub ( ) , onDidDispose : mySandBox . stub ( ) , onDidChangeViewState : mySandBox . stub ( ) } ) ; const transactionView = new TransactionView ( context , mockTransactionViewParams ) ; await transactionView . openView ( false ) ; postMessageStub . should . have . been . calledWith ( { path : '/transaction' , transactionViewData : mockTransactionViewParams , } ) ; const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; orgMap . set ( 'Org2MSP' , [ 'peerTwo' , 'peerThree' ] ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_ENVIRONMENT , environmentRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . INSTALL_SMART_CONTRACT , orgMap , packageRegistryEntry ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . APPROVE_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . COMMIT_SMART_CONTRACT , 'myOrderer' , 'myChannel' , orgMap , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , 'myPackageId' ) ) ; logSpy . should . have . been . calledWith ( LogType . INFO , 'Deploy Smart Contract' ) ; logSpy . should . have . been . calledWith ( LogType . SUCCESS , 'Successfully deployed smart contract' ) ; getConnectionStub . should . have . been . called ; const smartContract = { name : 'mySmartContract' , version : '0.0.1' , channel : 'myChannel' , label : 'mySmartContract@0.0.1' , transactions : [ transactionOne , transactionTwo , ] , contractName : 'my-contract' , namespace : 'my-contract' , peerNames : [ 'peerOne' , 'peerTwo' ] , } ; postMessageStub . should . have . been . calledWith ( { path : '/transaction' , transactionViewData : { ... mockTransactionViewParams , smartContracts : [ smartContract ] } , } ) ; } ) ; it ( 'should handle cancellation when attempting to connect to a gateway when the Transaction View is open' , async ( ) => { const context = GlobalState . getExtensionContext ( ) ; const createWebviewPanelStub = mySandBox . stub ( vscode . window , 'createWebviewPanel' ) ; createWebviewPanelStub . returns ( { title : 'Transaction Page' , webview : { postMessage : mySandBox . stub ( ) . resolves ( ) , onDidReceiveMessage : mySandBox . stub ( ) , asWebviewUri : mySandBox . stub ( ) } , reveal : mySandBox . stub ( ) , dispose : mySandBox . stub ( ) , onDidDispose : mySandBox . stub ( ) , onDidChangeViewState : mySandBox . stub ( ) } ) ; const transactionView = new TransactionView ( context , mockTransactionViewParams ) ; await transactionView . openView ( false ) ; getConnectionStub . returns ( undefined ) ; const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , undefined , `OutOf(1, 'Org1.member', 'Org2.member')` ) ) ; } ) ; it ( 'should call the CONNECT_TO_GATEWAY command if not already connected and submit a smart contract using the connected gateway when the Transaction View is open' , async ( ) => { const context = GlobalState . getExtensionContext ( ) ; const createWebviewPanelStub = mySandBox . stub ( vscode . window , 'createWebviewPanel' ) ; createWebviewPanelStub . returns ( { title : 'Transaction Page' , webview : { postMessage : mySandBox . stub ( ) . resolves ( ) , onDidReceiveMessage : mySandBox . stub ( ) , asWebviewUri : mySandBox . stub ( ) } , reveal : mySandBox . stub ( ) , dispose : mySandBox . stub ( ) , onDidDispose : mySandBox . stub ( ) , onDidChangeViewState : mySandBox . stub ( ) } ) ; const transactionView = new TransactionView ( context , mockTransactionViewParams ) ; await transactionView . openView ( false ) ; getConnectionStub . returns ( undefined ) ; getConnectionStub . onSecondCall ( ) . returns ( 'anotherGateway' ) ; const getSmartContractStub = mySandBox . stub ( openTransactionViewCommand , 'getSmartContracts' ) . resolves ( ) ; const orgMap = new Map < string , string [ ] > ( ) ; orgMap . set ( 'Org1MSP' , [ 'peerOne' ] ) ; await vscode . commands . executeCommand ( ExtensionCommands . DEPLOY_SMART_CONTRACT , true , environmentRegistryEntry , 'myOrderer' , 'myChannel' , orgMap , packageRegistryEntry , new FabricSmartContractDefinition ( 'mySmartContract' , '0.0.1' , 1 , undefined , `OutOf(1, 'Org1.member', 'Org2.member')` ) ) ; executeCommandStub . should . have . been . calledWith ( ExtensionCommands . CONNECT_TO_GATEWAY ) ; getSmartContractStub . should . have . been . calledWith ( 'anotherGateway' ) ; } ) ; } ) ; } ) ;