-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update e2e test to use multi-org setup
FAB-2617 the end-to-end test has been running against either the default "testchainid" or even for a newly created chain it uses a network of orderers and peers that all share the same MSP config (in fabric/msp/sampleconfig). this tasks is to create a target network using at least two organizations in order to test more realistic user scenarios. This is part I. Goes as far as create chain, join chain from two separate orgs, install chaincode from two orgs, instantiate chaincode, and invoke transaction (which has a policy error at the moment) Change-Id: I24a0745b35ac0f405a4e912f32de8440aca71988 Signed-off-by: Jim Zhang <jzhang@us.ibm.com>
- Loading branch information
1 parent
ffd5775
commit b95036b
Showing
16 changed files
with
935 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('./e2e/create-channel.js'); | ||
require('./e2e/join-channel.js'); | ||
require('./e2e/install-chaincode.js'); | ||
require('./e2e/instantiate-chaincode.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"test-network": { | ||
"orderer": "grpc://localhost:7050", | ||
"org1": { | ||
"name": "peerOrg1", | ||
"mspid": "Org1MSP", | ||
"ca": "http://localhost:7054", | ||
"peer1": { | ||
"requests": "grpc://localhost:7051", | ||
"events": "grpc://localhost:7053" | ||
}, | ||
"peer2": { | ||
"requests": "grpc://localhost:7056", | ||
"events": "grpc://localhost:7058" | ||
} | ||
}, | ||
"org2": { | ||
"name": "peerOrg2", | ||
"mspid": "Org2MSP", | ||
"ca": "http://localhost:8054", | ||
"peer1": { | ||
"requests": "grpc://localhost:8051", | ||
"events": "grpc://localhost:8053" | ||
}, | ||
"peer2": { | ||
"requests": "grpc://localhost:8056", | ||
"events": "grpc://localhost:8058" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/** | ||
* Copyright 2016 IBM All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the 'License'); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an 'AS IS' BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
var tape = require('tape'); | ||
var _test = require('tape-promise'); | ||
var test = _test(tape); | ||
|
||
var hfc = require('fabric-client'); | ||
var util = require('util'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
var testUtil = require('../../unit/util.js'); | ||
var utils = require('fabric-client/lib/utils.js'); | ||
var Orderer = require('fabric-client/lib/Orderer.js'); | ||
|
||
var the_user = null; | ||
|
||
var logger = utils.getLogger('create-channel'); | ||
|
||
hfc.addConfigFile(path.join(__dirname, './config.json')); | ||
var ORGS = hfc.getConfigSetting('test-network'); | ||
|
||
// | ||
//Attempt to send a request to the orderer with the sendCreateChain method | ||
// | ||
test('\n\n***** End-to-end flow: create channel *****\n\n', function(t) { | ||
// | ||
// Create and configure the test chain | ||
// | ||
var client = new hfc(); | ||
var chain = client.newChain('mychannel'); | ||
chain.addOrderer(new Orderer(ORGS.orderer)); | ||
|
||
// Acting as a client in org1 when creating the channel | ||
var org = ORGS.org1.name; | ||
|
||
hfc.newDefaultKeyValueStore({ | ||
path: testUtil.storePathForOrg(org) | ||
}) | ||
.then((store) => { | ||
client.setStateStore(store); | ||
return testUtil.getSubmitter(client, t, 'org1'); | ||
}) | ||
.then((admin) => { | ||
t.pass('Successfully enrolled user \'admin\''); | ||
the_user = admin; | ||
|
||
//FIXME: temporary fix until mspid is configured into Chain | ||
the_user.mspImpl._id = ORGS.org1.mspid; | ||
|
||
// readin the envelope to send to the orderer | ||
return readFile('./test/fixtures/channel/mychannel.tx'); | ||
}, (err) => { | ||
t.fail('Failed to enroll user \'admin\'. ' + err); | ||
t.end(); | ||
}) | ||
.then((data) => { | ||
t.pass('Successfully read file'); | ||
var request = { | ||
envelope : data | ||
}; | ||
// send to orderer | ||
return chain.createChannel(request); | ||
}, (err) => { | ||
t.fail('Failed to read file for channel template: ' + err); | ||
t.end(); | ||
}) | ||
.then((response) => { | ||
logger.debug(' response ::%j',response); | ||
|
||
if (response && response.status === 'SUCCESS') { | ||
t.pass('Successfully created the channel.'); | ||
return sleep(5000); | ||
} else { | ||
t.fail('Failed to create the channel. '); | ||
t.end(); | ||
} | ||
}, (err) => { | ||
t.fail('Failed to initialize the channel: ' + err.stack ? err.stack : err); | ||
t.end(); | ||
}) | ||
.then((nothing) => { | ||
t.pass('Successfully waited to make sure new channel was created.'); | ||
t.end(); | ||
}, (err) => { | ||
t.fail('Failed to sleep due to error: ' + err.stack ? err.stack : err); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
function readFile(path) { | ||
return new Promise(function(resolve, reject) { | ||
fs.readFile(path, function(err, data) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function sleep(ms) { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} |
Oops, something went wrong.