Skip to content

Commit b0f6c5d

Browse files
committed
[FAB-3980] Subset of consortium for channel create
Allow for the selection of a subset of the consortium for channel membership. Fixed issue with getting latest config update from channel. Now allow for selection of timeout for getting blocks from deliverer stream helper. Now only Admins are in local MSP adminscert folder. Now only the signing orgs cert is in local MSP cacerts folder. Regenerated common/policies.proto related stubs per latest change. Change-Id: I14903de3a2dd27a521bf3fdd8fdb283fa85f5e4c Signed-off-by: Jeff Garratt <[email protected]>
1 parent 52853f8 commit b0f6c5d

File tree

7 files changed

+133
-92
lines changed

7 files changed

+133
-92
lines changed

bddtests/common/policies_pb2.py

+21-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bddtests/common/policies_pb2_grpc.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
import grpc
3-
from grpc.framework.common import cardinality
4-
from grpc.framework.interfaces.face import utilities as face_utilities
53

bddtests/features/bootstrap.feature

+25-22
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ Feature: Bootstrap
3030
| orderer0Signer | orderer0 | ordererOrg0 | |
3131
| orderer1Signer | orderer1 | ordererOrg0 | |
3232
| orderer2Signer | orderer2 | ordererOrg0 | |
33+
| orderer0Admin | orderer0 | ordererOrg0 | |
34+
| orderer1Admin | orderer1 | ordererOrg0 | |
35+
| orderer2Admin | orderer2 | ordererOrg0 | |
3336
| configAdminOrdererOrg0 | configAdmin | ordererOrg0 | config-admin-cert |
3437
# | configAdminOrdererOrg1 | configAdmin | ordererOrg1 | config-admin-cert |
3538

@@ -39,7 +42,7 @@ Feature: Bootstrap
3942
| Organization | Readers | Writers | Admins |
4043
| peerOrg0 | member | member | admin |
4144
| peerOrg1 | member | member | admin |
42-
# | peerOrg2 | member | member | admin |
45+
| peerOrg2 | member | member | admin |
4346

4447

4548

@@ -91,7 +94,7 @@ Feature: Bootstrap
9194
| Organization |
9295
| peerOrg0 |
9396
| peerOrg1 |
94-
# | peerOrg2 |
97+
| peerOrg2 |
9598

9699
And user "configAdminOrdererOrg0" using cert alias "config-admin-cert" connects to deliver function on orderer "<orderer0>"
97100

@@ -114,9 +117,9 @@ Feature: Bootstrap
114117

115118

116119
Given the following application developers are defined for peer organizations and each saves their cert as alias
117-
| Developer | Consortium | Organization | AliasSavedUnder |
118-
| dev0Org0 | consortium1 | peerOrg0 | dev0Org0App1 |
119-
| dev0Org1 | consortium1 | peerOrg1 | dev0Org1App1 |
120+
| Developer | Consortium | Organization | AliasSavedUnder |
121+
| dev0Org0 | consortium1 | peerOrg0 | consortium1-cert |
122+
| dev0Org1 | consortium1 | peerOrg1 | consortium1-cert |
120123

121124
And user "configAdminOrdererOrg0" gives "consortium1" to user "dev0Org0"
122125

@@ -125,38 +128,38 @@ Feature: Bootstrap
125128
# ChannelReaders ConfigItem (using ChannelReaders ref name)AnchorPeers ConfigItem
126129
# and the ChaincodeLifecyclePolicy Config Item
127130
# NOTE: Template1 will simply hold refs to peer orgs that can create in this channel at the moment
128-
And the user "dev0Org0" creates a peer template "template1" with chaincode deployment policy using consortium "consortium1" and peer organizations:
131+
And the user "dev0Org0" creates a peer organization set "peerOrgSet1" with peer organizations:
129132
| Organization |
130133
| peerOrg0 |
131134
| peerOrg1 |
135+
# | peerOrg2 |
132136

133-
And the user "dev0Org0" creates an peer anchor set "anchors1" for channel "com.acme.blockchain.jdoe.Channel1" for orgs:
137+
And the user "dev0Org0" creates an peer anchor set "anchors1" for orgs:
134138
| User | Peer | Organization |
135139
# | peer0Signer | peer0 | peerOrg0 |
136140
# | peer2Signer | peer2 | peerOrg1 |
137141

138-
# TODO: grab the peer orgs from template1 and put into Murali's MSP info SCIs.
139-
# Entry point for creating a channel from existing templates
140-
And the user "dev0Org0" creates a new channel ConfigUpdate "createChannelConfigUpdate1" using consortium config "consortium1"
141-
| ChannelID | Template | Anchors |
142-
| com.acme.blockchain.jdoe.Channel1 | template1 | anchors1 |
142+
# Entry point for creating a channel
143+
And the user "dev0Org0" creates a new channel ConfigUpdate "createChannelConfigUpdate1" using consortium "consortium1"
144+
| ChannelID | PeerOrgSet | PeerAnchorSet |
145+
| com.acme.blockchain.jdoe.Channel1 | peerOrgSet1 | anchors1 |
143146

144147
And the user "dev0Org0" creates a configUpdateEnvelope "createChannelConfigUpdate1Envelope" using configUpdate "createChannelConfigUpdate1"
145148

146149

147150
And the user "dev0Org0" collects signatures for ConfigUpdateEnvelope "createChannelConfigUpdate1Envelope" from developers:
148-
| Developer | Cert Alias |
149-
| dev0Org0 | dev0Org0App1 |
150-
| dev0Org1 | dev0Org1App1 |
151+
| Developer | Cert Alias |
152+
| dev0Org0 | consortium1-cert |
153+
| dev0Org1 | consortium1-cert |
151154

152-
And the user "dev0Org0" creates a ConfigUpdate Tx "configUpdateTx1" using cert alias "dev0Org0App1" using signed ConfigUpdateEnvelope "createChannelConfigUpdate1Envelope"
155+
And the user "dev0Org0" creates a ConfigUpdate Tx "configUpdateTx1" using cert alias "consortium1-cert" using signed ConfigUpdateEnvelope "createChannelConfigUpdate1Envelope"
153156

154-
And the user "dev0Org0" using cert alias "dev0Org0App1" broadcasts ConfigUpdate Tx "configUpdateTx1" to orderer "<orderer0>" to create channel "com.acme.blockchain.jdoe.Channel1"
157+
And the user "dev0Org0" using cert alias "consortium1-cert" broadcasts ConfigUpdate Tx "configUpdateTx1" to orderer "<orderer0>" to create channel "com.acme.blockchain.jdoe.Channel1"
155158

156159
# Sleep as the local orderer ledger needs to create the block that corresponds to the start number of the seek request
157160
And I wait "<BroadcastWaitTime>" seconds
158161

159-
When user "dev0Org0" using cert alias "dev0Org0App1" connects to deliver function on orderer "<orderer0>"
162+
When user "dev0Org0" using cert alias "consortium1-cert" connects to deliver function on orderer "<orderer0>"
160163
And user "dev0Org0" sends deliver a seek request on orderer "<orderer0>" with properties:
161164
| ChainId | Start | End |
162165
| com.acme.blockchain.jdoe.Channel1 | 0 | 0 |
@@ -281,9 +284,9 @@ Feature: Bootstrap
281284
| query | a |
282285

283286
# Under the covers, create a deployment spec, etc.
284-
And user "dev0Org0" using cert alias "dev0Org0App1" creates a proposal "queryProposal1" for channel "com.acme.blockchain.jdoe.Channel1" using chaincode spec "querySpec1"
287+
And user "dev0Org0" using cert alias "consortium1-cert" creates a proposal "queryProposal1" for channel "com.acme.blockchain.jdoe.Channel1" using chaincode spec "querySpec1"
285288

286-
And user "dev0Org0" using cert alias "dev0Org0App1" sends proposal "queryProposal1" to endorsers with timeout of "30" seconds with proposal responses "queryProposal1Responses":
289+
And user "dev0Org0" using cert alias "consortium1-cert" sends proposal "queryProposal1" to endorsers with timeout of "30" seconds with proposal responses "queryProposal1Responses":
287290
| Endorser |
288291
| peer0 |
289292
| peer2 |
@@ -305,9 +308,9 @@ Feature: Bootstrap
305308
| invoke | a | b | 10 |
306309

307310
# Under the covers, create a deployment spec, etc.
308-
And user "dev0Org0" using cert alias "dev0Org0App1" creates a proposal "invokeProposal1" for channel "com.acme.blockchain.jdoe.Channel1" using chaincode spec "invocationSpec1"
311+
And user "dev0Org0" using cert alias "consortium1-cert" creates a proposal "invokeProposal1" for channel "com.acme.blockchain.jdoe.Channel1" using chaincode spec "invocationSpec1"
309312

310-
And user "dev0Org0" using cert alias "dev0Org0App1" sends proposal "invokeProposal1" to endorsers with timeout of "30" seconds with proposal responses "invokeProposal1Responses":
313+
And user "dev0Org0" using cert alias "consortium1-cert" sends proposal "invokeProposal1" to endorsers with timeout of "30" seconds with proposal responses "invokeProposal1Responses":
311314
| Endorser |
312315
| peer0 |
313316
| peer2 |

bddtests/steps/bootstrap_impl.py

+19-7
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ def step_impl(context, ordererConfigAdmin, consortiumsConfigUpdateName, configNa
139139
config_update = bootstrap_util.create_orderer_consortium_config_update(orderer_system_chain_id, channel_group, config_groups)
140140
ordererConfigAdmin.setTagValue(tagKey=consortiumsConfigUpdateName, tagValue=config_update)
141141

142-
@given(u'the user "{userName}" creates a peer template "{templateName}" with chaincode deployment policy using consortium "{chainCreatePolicyName}" and peer organizations')
143-
def step_impl(context, userName, templateName, chainCreatePolicyName):
142+
@given(u'the user "{userName}" creates a peer organization set "{peerOrgSetName}" with peer organizations')
143+
def step_impl(context, userName, peerOrgSetName):
144144
' At the moment, only really defining MSP Config Items (NOT SIGNED)'
145145
directory = bootstrap_util.getDirectory(context)
146146
user = directory.getUser(userName)
147-
user.setTagValue(templateName, [directory.getOrganization(row['Organization']).name for row in context.table.rows])
147+
user.setTagValue(peerOrgSetName, [directory.getOrganization(row['Organization']).name for row in context.table.rows])
148148

149149
@given(u'the user "{userName}" creates a configUpdateEnvelope "{configUpdateEnvelopeName}" using configUpdate "{configUpdateName}"')
150150
def step_impl(context, userName, configUpdateEnvelopeName, configUpdateName):
@@ -153,14 +153,16 @@ def step_impl(context, userName, configUpdateEnvelopeName, configUpdateName):
153153
config_update_envelope = bootstrap_util.create_config_update_envelope(config_update=user.getTagValue(configUpdateName))
154154
user.setTagValue(tagKey=configUpdateEnvelopeName, tagValue=config_update_envelope)
155155

156-
@given(u'the user "{userName}" creates a new channel ConfigUpdate "{create_channel_config_update_name}" using consortium config "{consortium_name}"')
156+
@given(u'the user "{userName}" creates a new channel ConfigUpdate "{create_channel_config_update_name}" using consortium "{consortium_name}"')
157157
def step_impl(context, userName, create_channel_config_update_name, consortium_name):
158158
directory = bootstrap_util.getDirectory(context)
159159
user = directory.getUser(userName)
160160
consortium_config_group = user.getTagValue(tagKey=consortium_name)
161161

162+
peerOrgSet = user.getTagValue(tagKey=context.table.rows[0]["PeerOrgSet"])
163+
peerAnchorSet = user.getTagValue(tagKey=context.table.rows[0]["PeerAnchorSet"])
164+
162165
channel_id = context.table.rows[0]["ChannelID"]
163-
templateName = context.table.rows[0]["Template"]
164166
# Loop through templates referenced orgs
165167
# mspOrgNames = [org.name for org in user.tags[templateName]]
166168
#TODO: Where does the system_channel_version come from?
@@ -171,6 +173,16 @@ def step_impl(context, userName, create_channel_config_update_name, consortium_n
171173
# anchorSignedConfigItemsName = context.table.rows[0]["Anchors"]
172174
# signedAnchorsConfigItems = user.tags[anchorSignedConfigItemsName]
173175

176+
#Make sure orgs exist in consortium
177+
for orgName in peerOrgSet:
178+
assert orgName in channel_config_update.write_set.groups['Application'].groups.keys(), "PeerOrgSet entry {0} not found in consortium".format(orgName)
179+
180+
# Strip out any organizations that are NOT referenced in peerOrgSet
181+
for orgName in channel_config_update.write_set.groups['Application'].groups.keys():
182+
if not orgName in peerOrgSet:
183+
del(channel_config_update.read_set.groups['Application'].groups[orgName])
184+
del(channel_config_update.write_set.groups['Application'].groups[orgName])
185+
174186
user.setTagValue(create_channel_config_update_name, channel_config_update)
175187

176188

@@ -301,8 +313,8 @@ def step_impl(context, userName, proposalResponseName, proposalResponseResultCod
301313
print("ProposalResponse: \n{0}\n".format(proposalResponse))
302314
print("")
303315

304-
@given(u'the user "{userName}" creates an peer anchor set "{anchorSetName}" for channel "{channelName}" for orgs')
305-
def step_impl(context, userName, anchorSetName, channelName):
316+
@given(u'the user "{userName}" creates an peer anchor set "{anchorSetName}" for orgs')
317+
def step_impl(context, userName, anchorSetName):
306318
directory = bootstrap_util.getDirectory(context)
307319
user = directory.getUser(userName=userName)
308320
nodeAdminTuples = [directory.findNodeAdminTuple(row['User'], row['Peer'], row['Organization']) for row in context.table.rows]

0 commit comments

Comments
 (0)