diff --git a/test/tools/PTE/README.md b/test/tools/PTE/README.md index f85ceb0a554..7e5da8ea10c 100644 --- a/test/tools/PTE/README.md +++ b/test/tools/PTE/README.md @@ -429,16 +429,27 @@ where: The service credentials contain the information of the network and are stored in the `SCFiles` directory. The following is a sample of the service credentials json file: ``` { - "test-network": { - "orderer": { - "name": "OrdererMSP", - "mspid": "OrdererMSP", - "mspPath": "./crypto-config", - "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", - "comName": "example.com", - "url": "grpcs://localhost:5005", - "server-hostname": "orderer0.example.com", - "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp/cacerts/ca.example.com-cert.pem" + "orderer": { + "orderer0": { + "name": "OrdererMSP", + "mspid": "OrdererMSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", + "comName": "example.com", + "url": "grpcs://localhost:7050", + "server-hostname": "orderer0.example.com", + "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp/cacerts/ca.example.com-cert.pem" + }, + "orderer1": { + "name": "OrdererMSP", + "mspid": "OrdererMSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", + "comName": "example.com", + "url": "grpcs://localhost:8050", + "server-hostname": "orderer1.example.com", + "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp/cacerts/ca.example.com-cert.pem" + } }, "org1": { "name": "Org1MSP", @@ -446,6 +457,7 @@ The service credentials contain the information of the network and are stored in "mspPath": "./crypto-config", "adminPath": "./crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp", "comName": "example.com", + "ordererID": "orderer0", "ca": { "url":"https://localhost:7054", "name": "ca-org1" @@ -471,6 +483,7 @@ The service credentials contain the information of the network and are stored in "mspPath": "./crypto-config", "adminPath": "./crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp", "comName": "example.com", + "ordererID": "orderer1", "ca": { "url":"https://localhost:8054", "name": "ca-org2" @@ -494,6 +507,8 @@ The service credentials contain the information of the network and are stored in } ``` +## Sending transactions to multiple orderers +PTE supports multi orderers by specifying an orderer to each organization using `ordererID` in the Service credentials json file. Then PTE will direct all transactions target the peers in that organization to the specified orderer. ## Creating a local Fabric network - If you do not yet have the Fabric docker images in your local docker registry, please either build them from Fabric source or download them from dockerhub. diff --git a/test/tools/PTE/SCFiles/config-chan1-TLS.json b/test/tools/PTE/SCFiles/config-chan1-TLS.json index 5c38a78df0b..12bfc9de51f 100644 --- a/test/tools/PTE/SCFiles/config-chan1-TLS.json +++ b/test/tools/PTE/SCFiles/config-chan1-TLS.json @@ -1,63 +1,71 @@ { "test-network": { "orderer": { - "name": "OrdererOrg1", - "mspid": "OrdererOrg1", - "mspPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config", - "adminPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", - "comName": "example.com", - "url": "grpcs://10.120.223.35:5005", - "server-hostname": "example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp/cacerts/ca.example.com-cert.pem" + "orderer1": { + "name": "OrdererMSP", + "mspid": "OrdererMSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", + "comName": "example.com", + "url": "grpcs://localhost:7050", + "server-hostname": "orderer0.example.com", + "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp/cacerts/ca.example.com-cert.pem" + }, + "orderer2": { + "name": "OrdererMSP", + "mspid": "OrdererMSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", + "comName": "example.com", + "url": "grpcs://localhost:8050", + "server-hostname": "orderer1.example.com", + "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp/cacerts/ca.example.com-cert.pem" + } }, "org1": { - "name": "PeerOrg1", - "mspid": "PeerOrg1", - "mspPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config", - "adminPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp", + "name": "Org1MSP", + "mspid": "Org1MSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp", "comName": "example.com", + "ordererID": "orderer1", "ca": { - "url":"https://10.120.223.35:7054", + "url":"https://localhost:7054", "name": "ca-org1" }, "username": "admin", "secret": "adminpw", "peer1": { - "requests": "grpcs://10.120.223.35:7061", - "events": "grpcs://10.120.223.35:6051", + "requests": "grpcs://localhost:7051", + "events": "grpcs://localhost:7053", "server-hostname": "peer0.org1.example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/cacerts/ca.org1.example.com-cert.pem" - }, - "peer2": { - "requests": "grpcs://10.120.223.35:7062", - "events": "grpcs://10.120.223.35:6052", - "server-hostname": "peer1.org1.example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp/cacerts/ca.org1.example.com-cert.pem" + "tls_cacerts": "./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/cacerts/ca.org1.example.com-cert.pem" } }, "org2": { - "name": "PeerOrg2", - "mspid": "PeerOrg2", - "mspPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config", - "adminPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp", + "name": "Org2MSP", + "mspid": "Org2MSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp", "comName": "example.com", + "ordererID": "orderer2", "ca": { - "url":"https://10.120.223.35:7055", + "url":"https://localhost:8054", "name": "ca-org2" }, "username": "admin", "secret": "adminpw", "peer1": { - "requests": "grpcs://10.120.223.35:7063", - "events": "grpcs://10.120.223.35:6053", + "requests": "grpcs://localhost:9051", + "events": "grpcs://localhost:9053", "server-hostname": "peer0.org2.example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/cacerts/ca.org2.example.com-cert.pem" + "tls_cacerts": "./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/cacerts/ca.org2.example.com-cert.pem" }, "peer2": { - "requests": "grpcs://10.120.223.35:7064", - "events": "grpcs://10.120.223.35:6054", + "requests": "grpcs://localhost:10051", + "events": "grpcs://localhost:10053", "server-hostname": "peer1.org2.example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/cacerts/ca.org2.example.com-cert.pem" + "tls_cacerts": "./crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/cacerts/ca.org2.example.com-cert.pem" } } } diff --git a/test/tools/PTE/SCFiles/config-chan2-TLS.json b/test/tools/PTE/SCFiles/config-chan2-TLS.json index 5c38a78df0b..4549702a941 100644 --- a/test/tools/PTE/SCFiles/config-chan2-TLS.json +++ b/test/tools/PTE/SCFiles/config-chan2-TLS.json @@ -1,63 +1,97 @@ { "test-network": { "orderer": { - "name": "OrdererOrg1", - "mspid": "OrdererOrg1", - "mspPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config", - "adminPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", - "comName": "example.com", - "url": "grpcs://10.120.223.35:5005", - "server-hostname": "example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp/cacerts/ca.example.com-cert.pem" + "orderer0": { + "name": "OrdererMSP", + "mspid": "OrdererMSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", + "comName": "example.com", + "url": "grpcs://localhost:8050", + "server-hostname": "orderer0.example.com", + "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer0.example.com/msp/cacerts/ca.example.com-cert.pem" + }, + "orderer1": { + "name": "OrdererMSP", + "mspid": "OrdererMSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", + "comName": "example.com", + "url": "grpcs://localhost:8050", + "server-hostname": "orderer1.example.com", + "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer1.example.com/msp/cacerts/ca.example.com-cert.pem" + }, + "orderer2": { + "name": "OrdererMSP", + "mspid": "OrdererMSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", + "comName": "example.com", + "url": "grpcs://localhost:9050", + "server-hostname": "orderer2.example.com", + "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer2.example.com/msp/cacerts/ca.example.com-cert.pem" + }, + "orderer3": { + "name": "OrdererMSP", + "mspid": "OrdererMSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/ordererOrganizations/example.com/users/Admin@example.com/msp", + "comName": "example.com", + "url": "grpcs://localhost:10050", + "server-hostname": "orderer3.example.com", + "tls_cacerts": "./crypto-config/ordererOrganizations/example.com/orderers/orderer3.example.com/msp/cacerts/ca.example.com-cert.pem" + } }, "org1": { - "name": "PeerOrg1", - "mspid": "PeerOrg1", - "mspPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config", - "adminPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp", + "name": "Org1MSP", + "mspid": "Org1MSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp", "comName": "example.com", + "ordererID": "orderer2", "ca": { - "url":"https://10.120.223.35:7054", + "url":"https://localhost:7054", "name": "ca-org1" }, "username": "admin", "secret": "adminpw", "peer1": { - "requests": "grpcs://10.120.223.35:7061", - "events": "grpcs://10.120.223.35:6051", + "requests": "grpcs://localhost:7051", + "events": "grpcs://localhost:7053", "server-hostname": "peer0.org1.example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/cacerts/ca.org1.example.com-cert.pem" + "tls_cacerts": "./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/cacerts/ca.org1.example.com-cert.pem" }, "peer2": { - "requests": "grpcs://10.120.223.35:7062", - "events": "grpcs://10.120.223.35:6052", - "server-hostname": "peer1.org1.example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp/cacerts/ca.org1.example.com-cert.pem" - } + "requests": "grpcs://localhost:8051", + "events": "grpcs://localhost:8053", + "server-hostname": "peer1.org1.example.com", + "tls_cacerts": "./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp/cacerts/ca.org1.example.com-cert.pem" +} }, "org2": { - "name": "PeerOrg2", - "mspid": "PeerOrg2", - "mspPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config", - "adminPath": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp", + "name": "Org2MSP", + "mspid": "Org2MSP", + "mspPath": "./crypto-config", + "adminPath": "./crypto-config/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp", "comName": "example.com", + "ordererID": "orderer3", "ca": { - "url":"https://10.120.223.35:7055", + "url":"https://localhost:8054", "name": "ca-org2" }, "username": "admin", "secret": "adminpw", "peer1": { - "requests": "grpcs://10.120.223.35:7063", - "events": "grpcs://10.120.223.35:6053", + "requests": "grpcs://localhost:9051", + "events": "grpcs://localhost:9053", "server-hostname": "peer0.org2.example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/cacerts/ca.org2.example.com-cert.pem" + "tls_cacerts": "./crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/cacerts/ca.org2.example.com-cert.pem" }, "peer2": { - "requests": "grpcs://10.120.223.35:7064", - "events": "grpcs://10.120.223.35:6054", + "requests": "grpcs://localhost:10051", + "events": "grpcs://localhost:10053", "server-hostname": "peer1.org2.example.com", - "tls_cacerts": "/root/gopath/src/github.com/hyperledger/fabric/common/tools/cryptogen/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/cacerts/ca.org2.example.com-cert.pem" + "tls_cacerts": "./crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/cacerts/ca.org2.example.com-cert.pem" } } } diff --git a/test/tools/PTE/pte-execRequest.js b/test/tools/PTE/pte-execRequest.js index 763d8295bc8..ad747745f60 100644 --- a/test/tools/PTE/pte-execRequest.js +++ b/test/tools/PTE/pte-execRequest.js @@ -140,7 +140,7 @@ var transMode = uiContent.transMode; var transType = uiContent.transType; var invokeType = uiContent.invokeType; var nRequest = parseInt(uiContent.nRequest); -var nProc = parseInt(uiContent.nProc); +//var nProc = parseInt(uiContent.nProc); var nOrg = parseInt(uiContent.nOrg); var nPeerPerOrg = parseInt(uiContent.nPeerPerOrg); var nPeer = nOrg * nPeerPerOrg; @@ -422,26 +422,27 @@ function channelAddPeerEvent(chain, client, org) { } function channelAddOrderer(chain, client, org) { - console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] chain name: ', Nid, pid, channelName, org, chain.getName()); + var ordererID = ORGS[org].ordererID; + console.log('[Nid:id:chan:org:ordererID=%d:%d:%s:%s:%s channelAddOrderer] chain name: ', Nid, pid, channelName, org, ordererID, chain.getName()); if (TLS.toUpperCase() == 'ENABLED') { - var caRootsPath = ORGS.orderer.tls_cacerts; + var caRootsPath = ORGS['orderer'][ordererID].tls_cacerts; let data = fs.readFileSync(caRootsPath); let caroots = Buffer.from(data).toString(); chain.addOrderer( new Orderer( - ORGS.orderer.url, + ORGS['orderer'][ordererID].url, { 'pem': caroots, - 'ssl-target-name-override': ORGS.orderer['server-hostname'] + 'ssl-target-name-override': ORGS['orderer'][ordererID]['server-hostname'] } ) ); } else { - chain.addOrderer( new Orderer(ORGS.orderer.url)); - console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] orderer url: ', Nid, pid, channelName, org, ORGS.orderer.url); + chain.addOrderer( new Orderer(ORGS['orderer'][ordererID].url)); + console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] orderer url: ', Nid, pid, channelName, org, ORGS['orderer'][ordererID].url); } - //console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] orderer in the chain: ', Nid, pid, channelName, org, chain.getOrderers()); + console.log('[Nid:id:chan:org=%d:%d:%s:%s channelAddOrderer] orderer in the chain: ', Nid, pid, channelName, org, chain.getOrderers()); } function channelAddAnchorPeer(chain, client, org) { @@ -637,7 +638,7 @@ function eventRegister(tx, cb) { var eventPromises = []; eventHubs.forEach((eh) => { let txPromise = new Promise((resolve, reject) => { - let handle = setTimeout(reject, 600000); + let handle = setTimeout(reject, 120000); eh.registerTxEvent(deployId.toString(), (tx, code) => { clearTimeout(handle); @@ -963,9 +964,14 @@ function invoke_move_const(freq) { } tCurr = new Date().getTime(); t1 = tCurr - t1; + if ( t1 < freq_n ) { + freq_n = freq_n - t1; + } else { + freq_n = 0; + } setTimeout(function(){ invoke_move_const(freq); - },freq_n-t1); + },freq_n); } else { tCurr = new Date().getTime(); console.log('[Nid:id:chan:org=%d:%d:%s:%s invoke_move_const] completed %d %s(%s) in %d ms, timestamp: start %d end %d', Nid, pid, channelName, org, inv_m, transType, invokeType, tCurr-tLocal, tLocal, tCurr); diff --git a/test/tools/PTE/pte-main.js b/test/tools/PTE/pte-main.js index 3df36f98d5d..2483091ca2e 100644 --- a/test/tools/PTE/pte-main.js +++ b/test/tools/PTE/pte-main.js @@ -46,10 +46,10 @@ var FabricCAServices = require('fabric-ca-client/lib/FabricCAClientImpl'); var FabricCAClient = FabricCAServices.FabricCAClient; var User = require('fabric-client/lib/User.js'); var Client = require('fabric-client/lib/Client.js'); -var _commonProto = grpc.load(path.join(__dirname, '../../fabric-client/lib/protos/common/common.proto')).common; +var _commonProto = grpc.load(path.join(__dirname, 'node_modules/fabric-client/lib/protos/common/common.proto')).common; -var gopath=process.env.GOPATH; -console.log('GOPATH: ', gopath); +//var gopath=process.env.GOPATH; +//console.log('GOPATH: ', gopath); utils.setConfigSetting('crypto-keysize', 256); @@ -97,6 +97,7 @@ var users = hfc.getConfigSetting('users'); var transType = uiContent.transType; var nRequest = parseInt(uiContent.nRequest); var nProc = parseInt(uiContent.nProc); +console.log('nProc ', nProc); var tCurr; @@ -129,43 +130,46 @@ function printChainInfo(chain) { } function clientNewOrderer(client, org) { + var ordererID = ORGS[org].ordererID; + console.log('[clientNewOrderer] org: %s, ordererID: %s', org, ordererID); if (TLS.toUpperCase() == 'ENABLED') { - var caRootsPath = ORGS.orderer.tls_cacerts; + var caRootsPath = ORGS['orderer'][ordererID].tls_cacerts; let data = fs.readFileSync(caRootsPath); let caroots = Buffer.from(data).toString(); orderer = client.newOrderer( - ORGS.orderer.url, + ORGS['orderer'][ordererID].url, { 'pem': caroots, - 'ssl-target-name-override': ORGS.orderer['server-hostname'] + 'ssl-target-name-override': ORGS['orderer'][ordererID]['server-hostname'] } ); } else { - orderer = client.newOrderer(ORGS.orderer.url); + orderer = client.newOrderer(ORGS['orderer'][ordererID].url); } - console.log('[clientNewOrderer] orderer: %s', ORGS.orderer.url); + console.log('[clientNewOrderer] orderer: %s', ORGS['orderer'][ordererID].url); } function chainAddOrderer(chain, client, org) { console.log('[chainAddOrderer] chain name: ', chain.getName()); + var ordererID = ORGS[org].ordererID; if (TLS.toUpperCase() == 'ENABLED') { - var caRootsPath = ORGS.orderer.tls_cacerts; + var caRootsPath = ORGS['orderer'][ordererID].tls_cacerts; var data = fs.readFileSync(caRootsPath); let caroots = Buffer.from(data).toString(); chain.addOrderer( client.newOrderer( - ORGS.orderer.url, + ORGS['orderer'][ordererID].url, { 'pem': caroots, - 'ssl-target-name-override': ORGS.orderer['server-hostname'] + 'ssl-target-name-override': ORGS['orderer'][ordererID]['server-hostname'] } ) ); } else { chain.addOrderer( - client.newOrderer(ORGS.orderer.url) + client.newOrderer(ORGS['orderer'][ordererID].url) ); } } @@ -491,6 +495,9 @@ function chaincodeInstall(chain, client, org) { channelAddPeer(chain, client, org); //printChainInfo(chain); + //TODO: Probably this property is configurable ? + process.env.GOPATH = __dirname; + nonce = utils.getNonce(); tx_id = hfc.buildTransactionID(nonce, the_user); nonce = utils.getNonce(); @@ -648,7 +655,7 @@ function chaincodeInstantiate(chain, client, org) { eh.registerTxEvent(deployId.toString(), (tx, code) => { var tCurr1=new Date().getTime(); - console.log('[chaincodeInstantiate] tCurr=%d, The chaincode instantiate transaction time=%d', tCurr, tCurr1-tCurr); + //console.log('[chaincodeInstantiate] tCurr=%d, The chaincode instantiate transaction time=%d', tCurr, tCurr1-tCurr); //console.log('[chaincodeInstantiate] The chaincode instantiate transaction has been committed on peer '+ eh.ep.addr); clearTimeout(handle); eh.unregisterTxEvent(deployId); @@ -729,17 +736,19 @@ function pushMSP(client, msps) { for (let key in ORGS) { console.log('[pushMSP] key: %s, ORGS[key].mspid: %s', key, ORGS[key].mspid); - if (key.indexOf('orderer') === 0) { + if (key.indexOf('org') === 0) { + //orderer var msp = {}; - var comName = ORGS[key].comName; - msp.id = ORGS[key].mspid; - msp.rootCerts = readAllFiles(path.join(ORGS[key].mspPath+'/ordererOrganizations/'+comName+'/msp/', 'cacerts')); - msp.admin = readAllFiles(path.join(ORGS[key].mspPath+'/ordererOrganizations/'+comName+'/msp/', 'admincerts')); + var ordererID = ORGS[key].ordererID; + msp.id = ORGS['orderer'][ordererID].mspid; + var comName = ORGS['orderer'][ordererID].comName; + msp.rootCerts = readAllFiles(path.join(ORGS['orderer'][ordererID].mspPath+'/ordererOrganizations/'+comName+'/msp/', 'cacerts')); + msp.admin = readAllFiles(path.join(ORGS['orderer'][ordererID].mspPath+'/ordererOrganizations/'+comName+'/msp/', 'admincerts')); msps.push(client.newMSP(msp)); - } else if (key.indexOf('org') === 0) { + // org var msp = {}; - var comName = ORGS[key].comName; msp.id = ORGS[key].mspid; + var comName = ORGS[key].comName; msp.rootCerts = readAllFiles(path.join(ORGS[key].mspPath+'/peerOrganizations/'+key+'.'+comName+'/msp/', 'cacerts')); msp.admin = readAllFiles(path.join(ORGS[key].mspPath+'/peerOrganizations/'+key+'.'+comName+'/msp/', 'admincerts')); msps.push(client.newMSP(msp)); @@ -815,7 +824,23 @@ function createOneChannel(client, org) { signatures.push(signature); //console.log('[createOneChannel] org-signature: ', signature); - key='orderer'; + key='org1'; + client._userContext = null; + return testUtil.getOrderAdminSubmitter(client, key, svcFile); + }).then((admin) => { + the_user = admin; + console.log('[createOneChannel] Successfully enrolled user \'admin\' for', key); + var signature = client.signChannelConfig(config); + console.log('[createOneChannel] Successfully signed config update: ', key); + console.log('[createOneChannel] admin : ', admin); + // collect signature from org1 admin + // TODO: signature counting against policies on the orderer + // at the moment is being investigated, but it requires this + // weird double-signature from each org admin + signatures.push(signature); + signatures.push(signature); + //console.log('[createOneChannel] orderer-signature: ', signature); + key='org2'; client._userContext = null; return testUtil.getOrderAdminSubmitter(client, key, svcFile); }).then((admin) => { diff --git a/test/tools/PTE/pte-util.js b/test/tools/PTE/pte-util.js index d67c1ced512..e0f7ddfda51 100644 --- a/test/tools/PTE/pte-util.js +++ b/test/tools/PTE/pte-util.js @@ -167,17 +167,18 @@ function getAdmin(client, userOrg, svcFile) { function getOrdererAdmin(client, userOrg, svcFile) { hfc.addConfigFile(svcFile); ORGS = hfc.getConfigSetting('test-network'); - var mspPath = ORGS.orderer.mspPath; - var keyPath = ORGS.orderer.adminPath + '/keystore'; + var ordererID = ORGS[userOrg].ordererID; + var mspPath = ORGS['orderer'][ordererID].mspPath; + var keyPath = ORGS['orderer'][ordererID].adminPath + '/keystore'; var keyPEM = Buffer.from(readAllFiles(keyPath)[0]).toString(); - var certPath = ORGS.orderer.adminPath + '/signcerts'; + var certPath = ORGS['orderer'][ordererID].adminPath + '/signcerts'; var certPEM = readAllFiles(certPath)[0]; console.log('[getOrdererAdmin] keyPath: %s', keyPath); console.log('[getOrdererAdmin] certPath: %s', certPath); return Promise.resolve(client.createUser({ username: 'ordererAdmin', - mspid: ORGS.orderer.mspid, + mspid: ORGS['orderer'][ordererID].mspid, cryptoContent: { privateKeyPEM: keyPEM.toString(), signedCertPEM: certPEM.toString()