diff --git a/bddtests/common/common_pb2.py b/bddtests/common/common_pb2.py index f1f681c77b2..eab47a61580 100644 --- a/bddtests/common/common_pb2.py +++ b/bddtests/common/common_pb2.py @@ -21,7 +21,7 @@ name='common/common.proto', package='common', syntax='proto3', - serialized_pb=_b('\n\x13\x63ommon/common.proto\x12\x06\x63ommon\x1a\x1fgoogle/protobuf/timestamp.proto\"\"\n\x11LastConfiguration\x12\r\n\x05index\x18\x01 \x01(\x04\"H\n\x08Metadata\x12\r\n\x05value\x18\x01 \x01(\x0c\x12-\n\nsignatures\x18\x02 \x03(\x0b\x32\x19.common.MetadataSignature\"?\n\x11MetadataSignature\x12\x17\n\x0fsignatureHeader\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\"d\n\x06Header\x12(\n\x0b\x63hainHeader\x18\x01 \x01(\x0b\x32\x13.common.ChainHeader\x12\x30\n\x0fsignatureHeader\x18\x02 \x01(\x0b\x32\x17.common.SignatureHeader\"\x9c\x01\n\x0b\x43hainHeader\x12\x0c\n\x04type\x18\x01 \x01(\x05\x12\x0f\n\x07version\x18\x02 \x01(\x05\x12-\n\ttimestamp\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07\x63hainID\x18\x04 \x01(\t\x12\x0c\n\x04txID\x18\x05 \x01(\t\x12\r\n\x05\x65poch\x18\x06 \x01(\x04\x12\x11\n\textension\x18\x07 \x01(\x0c\"1\n\x0fSignatureHeader\x12\x0f\n\x07\x63reator\x18\x01 \x01(\x0c\x12\r\n\x05nonce\x18\x02 \x01(\x0c\"7\n\x07Payload\x12\x1e\n\x06header\x18\x01 \x01(\x0b\x32\x0e.common.Header\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c\".\n\x08\x45nvelope\x12\x0f\n\x07payload\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\"v\n\x05\x42lock\x12#\n\x06Header\x18\x01 \x01(\x0b\x32\x13.common.BlockHeader\x12\x1f\n\x04\x44\x61ta\x18\x02 \x01(\x0b\x32\x11.common.BlockData\x12\'\n\x08Metadata\x18\x03 \x01(\x0b\x32\x15.common.BlockMetadata\"E\n\x0b\x42lockHeader\x12\x0e\n\x06Number\x18\x01 \x01(\x04\x12\x14\n\x0cPreviousHash\x18\x02 \x01(\x0c\x12\x10\n\x08\x44\x61taHash\x18\x03 \x01(\x0c\"\x19\n\tBlockData\x12\x0c\n\x04\x44\x61ta\x18\x01 \x03(\x0c\"!\n\rBlockMetadata\x12\x10\n\x08Metadata\x18\x01 \x03(\x0c*\xaa\x01\n\x06Status\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x0c\n\x07SUCCESS\x10\xc8\x01\x12\x10\n\x0b\x42\x41\x44_REQUEST\x10\x90\x03\x12\x0e\n\tFORBIDDEN\x10\x93\x03\x12\x0e\n\tNOT_FOUND\x10\x94\x03\x12\x1d\n\x18REQUEST_ENTITY_TOO_LARGE\x10\x9d\x03\x12\x1a\n\x15INTERNAL_SERVER_ERROR\x10\xf4\x03\x12\x18\n\x13SERVICE_UNAVAILABLE\x10\xf7\x03*\x9a\x01\n\nHeaderType\x12\x0b\n\x07MESSAGE\x10\x00\x12\x1d\n\x19\x43ONFIGURATION_TRANSACTION\x10\x01\x12\x16\n\x12\x43ONFIGURATION_ITEM\x10\x02\x12\x18\n\x14\x45NDORSER_TRANSACTION\x10\x03\x12\x17\n\x13ORDERER_TRANSACTION\x10\x04\x12\x15\n\x11\x44\x45LIVER_SEEK_INFO\x10\x05*U\n\x12\x42lockMetadataIndex\x12\x0e\n\nSIGNATURES\x10\x00\x12\x16\n\x12LAST_CONFIGURATION\x10\x01\x12\x17\n\x13TRANSACTIONS_FILTER\x10\x02\x42-Z+github.com/hyperledger/fabric/protos/commonb\x06proto3') + serialized_pb=_b('\n\x13\x63ommon/common.proto\x12\x06\x63ommon\x1a\x1fgoogle/protobuf/timestamp.proto\"\x1b\n\nLastConfig\x12\r\n\x05index\x18\x01 \x01(\x04\"H\n\x08Metadata\x12\r\n\x05value\x18\x01 \x01(\x0c\x12-\n\nsignatures\x18\x02 \x03(\x0b\x32\x19.common.MetadataSignature\"@\n\x11MetadataSignature\x12\x18\n\x10signature_header\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\"j\n\x06Header\x12-\n\x0e\x63hannel_header\x18\x01 \x01(\x0b\x32\x15.common.ChannelHeader\x12\x31\n\x10signature_header\x18\x02 \x01(\x0b\x32\x17.common.SignatureHeader\"\xa2\x01\n\rChannelHeader\x12\x0c\n\x04type\x18\x01 \x01(\x05\x12\x0f\n\x07version\x18\x02 \x01(\x05\x12-\n\ttimestamp\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x12\n\nchannel_id\x18\x04 \x01(\t\x12\r\n\x05tx_id\x18\x05 \x01(\t\x12\r\n\x05\x65poch\x18\x06 \x01(\x04\x12\x11\n\textension\x18\x07 \x01(\x0c\"1\n\x0fSignatureHeader\x12\x0f\n\x07\x63reator\x18\x01 \x01(\x0c\x12\r\n\x05nonce\x18\x02 \x01(\x0c\"7\n\x07Payload\x12\x1e\n\x06header\x18\x01 \x01(\x0b\x32\x0e.common.Header\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c\".\n\x08\x45nvelope\x12\x0f\n\x07payload\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\"v\n\x05\x42lock\x12#\n\x06header\x18\x01 \x01(\x0b\x32\x13.common.BlockHeader\x12\x1f\n\x04\x64\x61ta\x18\x02 \x01(\x0b\x32\x11.common.BlockData\x12\'\n\x08metadata\x18\x03 \x01(\x0b\x32\x15.common.BlockMetadata\"G\n\x0b\x42lockHeader\x12\x0e\n\x06number\x18\x01 \x01(\x04\x12\x15\n\rprevious_hash\x18\x02 \x01(\x0c\x12\x11\n\tdata_hash\x18\x03 \x01(\x0c\"\x19\n\tBlockData\x12\x0c\n\x04\x64\x61ta\x18\x01 \x03(\x0c\"!\n\rBlockMetadata\x12\x10\n\x08metadata\x18\x01 \x03(\x0c*\xaa\x01\n\x06Status\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x0c\n\x07SUCCESS\x10\xc8\x01\x12\x10\n\x0b\x42\x41\x44_REQUEST\x10\x90\x03\x12\x0e\n\tFORBIDDEN\x10\x93\x03\x12\x0e\n\tNOT_FOUND\x10\x94\x03\x12\x1d\n\x18REQUEST_ENTITY_TOO_LARGE\x10\x9d\x03\x12\x1a\n\x15INTERNAL_SERVER_ERROR\x10\xf4\x03\x12\x18\n\x13SERVICE_UNAVAILABLE\x10\xf7\x03*\x82\x01\n\nHeaderType\x12\x0b\n\x07MESSAGE\x10\x00\x12\n\n\x06\x43ONFIG\x10\x01\x12\x11\n\rCONFIG_UPDATE\x10\x02\x12\x18\n\x14\x45NDORSER_TRANSACTION\x10\x03\x12\x17\n\x13ORDERER_TRANSACTION\x10\x04\x12\x15\n\x11\x44\x45LIVER_SEEK_INFO\x10\x05*[\n\x12\x42lockMetadataIndex\x12\x0e\n\nSIGNATURES\x10\x00\x12\x0f\n\x0bLAST_CONFIG\x10\x01\x12\x17\n\x13TRANSACTIONS_FILTER\x10\x02\x12\x0b\n\x07ORDERER\x10\x03\x42-Z+github.com/hyperledger/fabric/protos/commonb\x06proto3') , dependencies=[google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -67,8 +67,8 @@ ], containing_type=None, options=None, - serialized_start=910, - serialized_end=1080, + serialized_start=918, + serialized_end=1088, ) _sym_db.RegisterEnumDescriptor(_STATUS) @@ -84,11 +84,11 @@ options=None, type=None), _descriptor.EnumValueDescriptor( - name='CONFIGURATION_TRANSACTION', index=1, number=1, + name='CONFIG', index=1, number=1, options=None, type=None), _descriptor.EnumValueDescriptor( - name='CONFIGURATION_ITEM', index=2, number=2, + name='CONFIG_UPDATE', index=2, number=2, options=None, type=None), _descriptor.EnumValueDescriptor( @@ -106,8 +106,8 @@ ], containing_type=None, options=None, - serialized_start=1083, - serialized_end=1237, + serialized_start=1091, + serialized_end=1221, ) _sym_db.RegisterEnumDescriptor(_HEADERTYPE) @@ -123,18 +123,22 @@ options=None, type=None), _descriptor.EnumValueDescriptor( - name='LAST_CONFIGURATION', index=1, number=1, + name='LAST_CONFIG', index=1, number=1, options=None, type=None), _descriptor.EnumValueDescriptor( name='TRANSACTIONS_FILTER', index=2, number=2, options=None, type=None), + _descriptor.EnumValueDescriptor( + name='ORDERER', index=3, number=3, + options=None, + type=None), ], containing_type=None, options=None, - serialized_start=1239, - serialized_end=1324, + serialized_start=1223, + serialized_end=1314, ) _sym_db.RegisterEnumDescriptor(_BLOCKMETADATAINDEX) @@ -148,26 +152,27 @@ INTERNAL_SERVER_ERROR = 500 SERVICE_UNAVAILABLE = 503 MESSAGE = 0 -CONFIGURATION_TRANSACTION = 1 -CONFIGURATION_ITEM = 2 +CONFIG = 1 +CONFIG_UPDATE = 2 ENDORSER_TRANSACTION = 3 ORDERER_TRANSACTION = 4 DELIVER_SEEK_INFO = 5 SIGNATURES = 0 -LAST_CONFIGURATION = 1 +LAST_CONFIG = 1 TRANSACTIONS_FILTER = 2 +ORDERER = 3 -_LASTCONFIGURATION = _descriptor.Descriptor( - name='LastConfiguration', - full_name='common.LastConfiguration', +_LASTCONFIG = _descriptor.Descriptor( + name='LastConfig', + full_name='common.LastConfig', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='index', full_name='common.LastConfiguration.index', index=0, + name='index', full_name='common.LastConfig.index', index=0, number=1, type=4, cpp_type=4, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, @@ -186,7 +191,7 @@ oneofs=[ ], serialized_start=64, - serialized_end=98, + serialized_end=91, ) @@ -223,8 +228,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=100, - serialized_end=172, + serialized_start=93, + serialized_end=165, ) @@ -236,7 +241,7 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='signatureHeader', full_name='common.MetadataSignature.signatureHeader', index=0, + name='signature_header', full_name='common.MetadataSignature.signature_header', index=0, number=1, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, @@ -261,8 +266,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=174, - serialized_end=237, + serialized_start=167, + serialized_end=231, ) @@ -274,14 +279,14 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='chainHeader', full_name='common.Header.chainHeader', index=0, + name='channel_header', full_name='common.Header.channel_header', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='signatureHeader', full_name='common.Header.signatureHeader', index=1, + name='signature_header', full_name='common.Header.signature_header', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -299,62 +304,62 @@ extension_ranges=[], oneofs=[ ], - serialized_start=239, + serialized_start=233, serialized_end=339, ) -_CHAINHEADER = _descriptor.Descriptor( - name='ChainHeader', - full_name='common.ChainHeader', +_CHANNELHEADER = _descriptor.Descriptor( + name='ChannelHeader', + full_name='common.ChannelHeader', filename=None, file=DESCRIPTOR, containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='type', full_name='common.ChainHeader.type', index=0, + name='type', full_name='common.ChannelHeader.type', index=0, number=1, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='version', full_name='common.ChainHeader.version', index=1, + name='version', full_name='common.ChannelHeader.version', index=1, number=2, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='timestamp', full_name='common.ChainHeader.timestamp', index=2, + name='timestamp', full_name='common.ChannelHeader.timestamp', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='chainID', full_name='common.ChainHeader.chainID', index=3, + name='channel_id', full_name='common.ChannelHeader.channel_id', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='txID', full_name='common.ChainHeader.txID', index=4, + name='tx_id', full_name='common.ChannelHeader.tx_id', index=4, number=5, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='epoch', full_name='common.ChainHeader.epoch', index=5, + name='epoch', full_name='common.ChannelHeader.epoch', index=5, number=6, type=4, cpp_type=4, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='extension', full_name='common.ChainHeader.extension', index=6, + name='extension', full_name='common.ChannelHeader.extension', index=6, number=7, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, @@ -373,7 +378,7 @@ oneofs=[ ], serialized_start=342, - serialized_end=498, + serialized_end=504, ) @@ -410,8 +415,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=500, - serialized_end=549, + serialized_start=506, + serialized_end=555, ) @@ -448,8 +453,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=551, - serialized_end=606, + serialized_start=557, + serialized_end=612, ) @@ -486,8 +491,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=608, - serialized_end=654, + serialized_start=614, + serialized_end=660, ) @@ -499,21 +504,21 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Header', full_name='common.Block.Header', index=0, + name='header', full_name='common.Block.header', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='Data', full_name='common.Block.Data', index=1, + name='data', full_name='common.Block.data', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='Metadata', full_name='common.Block.Metadata', index=2, + name='metadata', full_name='common.Block.metadata', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -531,8 +536,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=656, - serialized_end=774, + serialized_start=662, + serialized_end=780, ) @@ -544,21 +549,21 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Number', full_name='common.BlockHeader.Number', index=0, + name='number', full_name='common.BlockHeader.number', index=0, number=1, type=4, cpp_type=4, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='PreviousHash', full_name='common.BlockHeader.PreviousHash', index=1, + name='previous_hash', full_name='common.BlockHeader.previous_hash', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='DataHash', full_name='common.BlockHeader.DataHash', index=2, + name='data_hash', full_name='common.BlockHeader.data_hash', index=2, number=3, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, @@ -576,8 +581,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=776, - serialized_end=845, + serialized_start=782, + serialized_end=853, ) @@ -589,7 +594,7 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Data', full_name='common.BlockData.Data', index=0, + name='data', full_name='common.BlockData.data', index=0, number=1, type=12, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, @@ -607,8 +612,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=847, - serialized_end=872, + serialized_start=855, + serialized_end=880, ) @@ -620,7 +625,7 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Metadata', full_name='common.BlockMetadata.Metadata', index=0, + name='metadata', full_name='common.BlockMetadata.metadata', index=0, number=1, type=12, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, @@ -638,23 +643,23 @@ extension_ranges=[], oneofs=[ ], - serialized_start=874, - serialized_end=907, + serialized_start=882, + serialized_end=915, ) _METADATA.fields_by_name['signatures'].message_type = _METADATASIGNATURE -_HEADER.fields_by_name['chainHeader'].message_type = _CHAINHEADER -_HEADER.fields_by_name['signatureHeader'].message_type = _SIGNATUREHEADER -_CHAINHEADER.fields_by_name['timestamp'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_HEADER.fields_by_name['channel_header'].message_type = _CHANNELHEADER +_HEADER.fields_by_name['signature_header'].message_type = _SIGNATUREHEADER +_CHANNELHEADER.fields_by_name['timestamp'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP _PAYLOAD.fields_by_name['header'].message_type = _HEADER -_BLOCK.fields_by_name['Header'].message_type = _BLOCKHEADER -_BLOCK.fields_by_name['Data'].message_type = _BLOCKDATA -_BLOCK.fields_by_name['Metadata'].message_type = _BLOCKMETADATA -DESCRIPTOR.message_types_by_name['LastConfiguration'] = _LASTCONFIGURATION +_BLOCK.fields_by_name['header'].message_type = _BLOCKHEADER +_BLOCK.fields_by_name['data'].message_type = _BLOCKDATA +_BLOCK.fields_by_name['metadata'].message_type = _BLOCKMETADATA +DESCRIPTOR.message_types_by_name['LastConfig'] = _LASTCONFIG DESCRIPTOR.message_types_by_name['Metadata'] = _METADATA DESCRIPTOR.message_types_by_name['MetadataSignature'] = _METADATASIGNATURE DESCRIPTOR.message_types_by_name['Header'] = _HEADER -DESCRIPTOR.message_types_by_name['ChainHeader'] = _CHAINHEADER +DESCRIPTOR.message_types_by_name['ChannelHeader'] = _CHANNELHEADER DESCRIPTOR.message_types_by_name['SignatureHeader'] = _SIGNATUREHEADER DESCRIPTOR.message_types_by_name['Payload'] = _PAYLOAD DESCRIPTOR.message_types_by_name['Envelope'] = _ENVELOPE @@ -666,12 +671,12 @@ DESCRIPTOR.enum_types_by_name['HeaderType'] = _HEADERTYPE DESCRIPTOR.enum_types_by_name['BlockMetadataIndex'] = _BLOCKMETADATAINDEX -LastConfiguration = _reflection.GeneratedProtocolMessageType('LastConfiguration', (_message.Message,), dict( - DESCRIPTOR = _LASTCONFIGURATION, +LastConfig = _reflection.GeneratedProtocolMessageType('LastConfig', (_message.Message,), dict( + DESCRIPTOR = _LASTCONFIG, __module__ = 'common.common_pb2' - # @@protoc_insertion_point(class_scope:common.LastConfiguration) + # @@protoc_insertion_point(class_scope:common.LastConfig) )) -_sym_db.RegisterMessage(LastConfiguration) +_sym_db.RegisterMessage(LastConfig) Metadata = _reflection.GeneratedProtocolMessageType('Metadata', (_message.Message,), dict( DESCRIPTOR = _METADATA, @@ -694,12 +699,12 @@ )) _sym_db.RegisterMessage(Header) -ChainHeader = _reflection.GeneratedProtocolMessageType('ChainHeader', (_message.Message,), dict( - DESCRIPTOR = _CHAINHEADER, +ChannelHeader = _reflection.GeneratedProtocolMessageType('ChannelHeader', (_message.Message,), dict( + DESCRIPTOR = _CHANNELHEADER, __module__ = 'common.common_pb2' - # @@protoc_insertion_point(class_scope:common.ChainHeader) + # @@protoc_insertion_point(class_scope:common.ChannelHeader) )) -_sym_db.RegisterMessage(ChainHeader) +_sym_db.RegisterMessage(ChannelHeader) SignatureHeader = _reflection.GeneratedProtocolMessageType('SignatureHeader', (_message.Message,), dict( DESCRIPTOR = _SIGNATUREHEADER, diff --git a/bddtests/common/configtx_pb2.py b/bddtests/common/configtx_pb2.py new file mode 100644 index 00000000000..0f37e3e44a5 --- /dev/null +++ b/bddtests/common/configtx_pb2.py @@ -0,0 +1,881 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: common/configtx.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from common import common_pb2 as common_dot_common__pb2 +from common import policies_pb2 as common_dot_policies__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='common/configtx.proto', + package='common', + syntax='proto3', + serialized_pb=_b('\n\x15\x63ommon/configtx.proto\x12\x06\x63ommon\x1a\x13\x63ommon/common.proto\x1a\x15\x63ommon/policies.proto\"W\n\x0e\x43onfigEnvelope\x12\x1e\n\x06\x63onfig\x18\x01 \x01(\x0b\x32\x0e.common.Config\x12%\n\x0blast_update\x18\x02 \x01(\x0b\x32\x10.common.Envelope\"\x9d\x03\n\x11\x43onfigGroupSchema\x12\x35\n\x06groups\x18\x01 \x03(\x0b\x32%.common.ConfigGroupSchema.GroupsEntry\x12\x35\n\x06values\x18\x02 \x03(\x0b\x32%.common.ConfigGroupSchema.ValuesEntry\x12\x39\n\x08policies\x18\x03 \x03(\x0b\x32\'.common.ConfigGroupSchema.PoliciesEntry\x1aH\n\x0bGroupsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12(\n\x05value\x18\x02 \x01(\x0b\x32\x19.common.ConfigGroupSchema:\x02\x38\x01\x1aH\n\x0bValuesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12(\n\x05value\x18\x02 \x01(\x0b\x32\x19.common.ConfigValueSchema:\x02\x38\x01\x1aK\n\rPoliciesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12)\n\x05value\x18\x02 \x01(\x0b\x32\x1a.common.ConfigPolicySchema:\x02\x38\x01\"\x13\n\x11\x43onfigValueSchema\"\x14\n\x12\x43onfigPolicySchema\"U\n\x06\x43onfig\x12%\n\x06header\x18\x01 \x01(\x0b\x32\x15.common.ChannelHeader\x12$\n\x07\x63hannel\x18\x02 \x01(\x0b\x32\x13.common.ConfigGroup\"Z\n\x14\x43onfigUpdateEnvelope\x12\x15\n\rconfig_update\x18\x01 \x01(\x0c\x12+\n\nsignatures\x18\x02 \x03(\x0b\x32\x17.common.ConfigSignature\"\x84\x01\n\x0c\x43onfigUpdate\x12%\n\x06header\x18\x01 \x01(\x0b\x32\x15.common.ChannelHeader\x12%\n\x08read_set\x18\x02 \x01(\x0b\x32\x13.common.ConfigGroup\x12&\n\twrite_set\x18\x03 \x01(\x0b\x32\x13.common.ConfigGroup\"\x98\x03\n\x0b\x43onfigGroup\x12\x0f\n\x07version\x18\x01 \x01(\x04\x12/\n\x06groups\x18\x02 \x03(\x0b\x32\x1f.common.ConfigGroup.GroupsEntry\x12/\n\x06values\x18\x03 \x03(\x0b\x32\x1f.common.ConfigGroup.ValuesEntry\x12\x33\n\x08policies\x18\x04 \x03(\x0b\x32!.common.ConfigGroup.PoliciesEntry\x12\x12\n\nmod_policy\x18\x05 \x01(\t\x1a\x42\n\x0bGroupsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\"\n\x05value\x18\x02 \x01(\x0b\x32\x13.common.ConfigGroup:\x02\x38\x01\x1a\x42\n\x0bValuesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\"\n\x05value\x18\x02 \x01(\x0b\x32\x13.common.ConfigValue:\x02\x38\x01\x1a\x45\n\rPoliciesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12#\n\x05value\x18\x02 \x01(\x0b\x32\x14.common.ConfigPolicy:\x02\x38\x01\"A\n\x0b\x43onfigValue\x12\x0f\n\x07version\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x0c\x12\x12\n\nmod_policy\x18\x03 \x01(\t\"S\n\x0c\x43onfigPolicy\x12\x0f\n\x07version\x18\x01 \x01(\x04\x12\x1e\n\x06policy\x18\x02 \x01(\x0b\x32\x0e.common.Policy\x12\x12\n\nmod_policy\x18\x03 \x01(\t\">\n\x0f\x43onfigSignature\x12\x18\n\x10signature_header\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\x42-Z+github.com/hyperledger/fabric/protos/commonb\x06proto3') + , + dependencies=[common_dot_common__pb2.DESCRIPTOR,common_dot_policies__pb2.DESCRIPTOR,]) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + + + + +_CONFIGENVELOPE = _descriptor.Descriptor( + name='ConfigEnvelope', + full_name='common.ConfigEnvelope', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='config', full_name='common.ConfigEnvelope.config', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='last_update', full_name='common.ConfigEnvelope.last_update', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=77, + serialized_end=164, +) + + +_CONFIGGROUPSCHEMA_GROUPSENTRY = _descriptor.Descriptor( + name='GroupsEntry', + full_name='common.ConfigGroupSchema.GroupsEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='common.ConfigGroupSchema.GroupsEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='common.ConfigGroupSchema.GroupsEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=357, + serialized_end=429, +) + +_CONFIGGROUPSCHEMA_VALUESENTRY = _descriptor.Descriptor( + name='ValuesEntry', + full_name='common.ConfigGroupSchema.ValuesEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='common.ConfigGroupSchema.ValuesEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='common.ConfigGroupSchema.ValuesEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=431, + serialized_end=503, +) + +_CONFIGGROUPSCHEMA_POLICIESENTRY = _descriptor.Descriptor( + name='PoliciesEntry', + full_name='common.ConfigGroupSchema.PoliciesEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='common.ConfigGroupSchema.PoliciesEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='common.ConfigGroupSchema.PoliciesEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=505, + serialized_end=580, +) + +_CONFIGGROUPSCHEMA = _descriptor.Descriptor( + name='ConfigGroupSchema', + full_name='common.ConfigGroupSchema', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='groups', full_name='common.ConfigGroupSchema.groups', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='values', full_name='common.ConfigGroupSchema.values', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='policies', full_name='common.ConfigGroupSchema.policies', index=2, + number=3, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[_CONFIGGROUPSCHEMA_GROUPSENTRY, _CONFIGGROUPSCHEMA_VALUESENTRY, _CONFIGGROUPSCHEMA_POLICIESENTRY, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=167, + serialized_end=580, +) + + +_CONFIGVALUESCHEMA = _descriptor.Descriptor( + name='ConfigValueSchema', + full_name='common.ConfigValueSchema', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=582, + serialized_end=601, +) + + +_CONFIGPOLICYSCHEMA = _descriptor.Descriptor( + name='ConfigPolicySchema', + full_name='common.ConfigPolicySchema', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=603, + serialized_end=623, +) + + +_CONFIG = _descriptor.Descriptor( + name='Config', + full_name='common.Config', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='header', full_name='common.Config.header', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='channel', full_name='common.Config.channel', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=625, + serialized_end=710, +) + + +_CONFIGUPDATEENVELOPE = _descriptor.Descriptor( + name='ConfigUpdateEnvelope', + full_name='common.ConfigUpdateEnvelope', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='config_update', full_name='common.ConfigUpdateEnvelope.config_update', index=0, + number=1, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=_b(""), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='signatures', full_name='common.ConfigUpdateEnvelope.signatures', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=712, + serialized_end=802, +) + + +_CONFIGUPDATE = _descriptor.Descriptor( + name='ConfigUpdate', + full_name='common.ConfigUpdate', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='header', full_name='common.ConfigUpdate.header', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='read_set', full_name='common.ConfigUpdate.read_set', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='write_set', full_name='common.ConfigUpdate.write_set', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=805, + serialized_end=937, +) + + +_CONFIGGROUP_GROUPSENTRY = _descriptor.Descriptor( + name='GroupsEntry', + full_name='common.ConfigGroup.GroupsEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='common.ConfigGroup.GroupsEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='common.ConfigGroup.GroupsEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1143, + serialized_end=1209, +) + +_CONFIGGROUP_VALUESENTRY = _descriptor.Descriptor( + name='ValuesEntry', + full_name='common.ConfigGroup.ValuesEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='common.ConfigGroup.ValuesEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='common.ConfigGroup.ValuesEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1211, + serialized_end=1277, +) + +_CONFIGGROUP_POLICIESENTRY = _descriptor.Descriptor( + name='PoliciesEntry', + full_name='common.ConfigGroup.PoliciesEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='common.ConfigGroup.PoliciesEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='common.ConfigGroup.PoliciesEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1279, + serialized_end=1348, +) + +_CONFIGGROUP = _descriptor.Descriptor( + name='ConfigGroup', + full_name='common.ConfigGroup', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='version', full_name='common.ConfigGroup.version', index=0, + number=1, type=4, cpp_type=4, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='groups', full_name='common.ConfigGroup.groups', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='values', full_name='common.ConfigGroup.values', index=2, + number=3, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='policies', full_name='common.ConfigGroup.policies', index=3, + number=4, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='mod_policy', full_name='common.ConfigGroup.mod_policy', index=4, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[_CONFIGGROUP_GROUPSENTRY, _CONFIGGROUP_VALUESENTRY, _CONFIGGROUP_POLICIESENTRY, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=940, + serialized_end=1348, +) + + +_CONFIGVALUE = _descriptor.Descriptor( + name='ConfigValue', + full_name='common.ConfigValue', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='version', full_name='common.ConfigValue.version', index=0, + number=1, type=4, cpp_type=4, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='common.ConfigValue.value', index=1, + number=2, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=_b(""), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='mod_policy', full_name='common.ConfigValue.mod_policy', index=2, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1350, + serialized_end=1415, +) + + +_CONFIGPOLICY = _descriptor.Descriptor( + name='ConfigPolicy', + full_name='common.ConfigPolicy', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='version', full_name='common.ConfigPolicy.version', index=0, + number=1, type=4, cpp_type=4, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='policy', full_name='common.ConfigPolicy.policy', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='mod_policy', full_name='common.ConfigPolicy.mod_policy', index=2, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1417, + serialized_end=1500, +) + + +_CONFIGSIGNATURE = _descriptor.Descriptor( + name='ConfigSignature', + full_name='common.ConfigSignature', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='signature_header', full_name='common.ConfigSignature.signature_header', index=0, + number=1, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=_b(""), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='signature', full_name='common.ConfigSignature.signature', index=1, + number=2, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=_b(""), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1502, + serialized_end=1564, +) + +_CONFIGENVELOPE.fields_by_name['config'].message_type = _CONFIG +_CONFIGENVELOPE.fields_by_name['last_update'].message_type = common_dot_common__pb2._ENVELOPE +_CONFIGGROUPSCHEMA_GROUPSENTRY.fields_by_name['value'].message_type = _CONFIGGROUPSCHEMA +_CONFIGGROUPSCHEMA_GROUPSENTRY.containing_type = _CONFIGGROUPSCHEMA +_CONFIGGROUPSCHEMA_VALUESENTRY.fields_by_name['value'].message_type = _CONFIGVALUESCHEMA +_CONFIGGROUPSCHEMA_VALUESENTRY.containing_type = _CONFIGGROUPSCHEMA +_CONFIGGROUPSCHEMA_POLICIESENTRY.fields_by_name['value'].message_type = _CONFIGPOLICYSCHEMA +_CONFIGGROUPSCHEMA_POLICIESENTRY.containing_type = _CONFIGGROUPSCHEMA +_CONFIGGROUPSCHEMA.fields_by_name['groups'].message_type = _CONFIGGROUPSCHEMA_GROUPSENTRY +_CONFIGGROUPSCHEMA.fields_by_name['values'].message_type = _CONFIGGROUPSCHEMA_VALUESENTRY +_CONFIGGROUPSCHEMA.fields_by_name['policies'].message_type = _CONFIGGROUPSCHEMA_POLICIESENTRY +_CONFIG.fields_by_name['header'].message_type = common_dot_common__pb2._CHANNELHEADER +_CONFIG.fields_by_name['channel'].message_type = _CONFIGGROUP +_CONFIGUPDATEENVELOPE.fields_by_name['signatures'].message_type = _CONFIGSIGNATURE +_CONFIGUPDATE.fields_by_name['header'].message_type = common_dot_common__pb2._CHANNELHEADER +_CONFIGUPDATE.fields_by_name['read_set'].message_type = _CONFIGGROUP +_CONFIGUPDATE.fields_by_name['write_set'].message_type = _CONFIGGROUP +_CONFIGGROUP_GROUPSENTRY.fields_by_name['value'].message_type = _CONFIGGROUP +_CONFIGGROUP_GROUPSENTRY.containing_type = _CONFIGGROUP +_CONFIGGROUP_VALUESENTRY.fields_by_name['value'].message_type = _CONFIGVALUE +_CONFIGGROUP_VALUESENTRY.containing_type = _CONFIGGROUP +_CONFIGGROUP_POLICIESENTRY.fields_by_name['value'].message_type = _CONFIGPOLICY +_CONFIGGROUP_POLICIESENTRY.containing_type = _CONFIGGROUP +_CONFIGGROUP.fields_by_name['groups'].message_type = _CONFIGGROUP_GROUPSENTRY +_CONFIGGROUP.fields_by_name['values'].message_type = _CONFIGGROUP_VALUESENTRY +_CONFIGGROUP.fields_by_name['policies'].message_type = _CONFIGGROUP_POLICIESENTRY +_CONFIGPOLICY.fields_by_name['policy'].message_type = common_dot_policies__pb2._POLICY +DESCRIPTOR.message_types_by_name['ConfigEnvelope'] = _CONFIGENVELOPE +DESCRIPTOR.message_types_by_name['ConfigGroupSchema'] = _CONFIGGROUPSCHEMA +DESCRIPTOR.message_types_by_name['ConfigValueSchema'] = _CONFIGVALUESCHEMA +DESCRIPTOR.message_types_by_name['ConfigPolicySchema'] = _CONFIGPOLICYSCHEMA +DESCRIPTOR.message_types_by_name['Config'] = _CONFIG +DESCRIPTOR.message_types_by_name['ConfigUpdateEnvelope'] = _CONFIGUPDATEENVELOPE +DESCRIPTOR.message_types_by_name['ConfigUpdate'] = _CONFIGUPDATE +DESCRIPTOR.message_types_by_name['ConfigGroup'] = _CONFIGGROUP +DESCRIPTOR.message_types_by_name['ConfigValue'] = _CONFIGVALUE +DESCRIPTOR.message_types_by_name['ConfigPolicy'] = _CONFIGPOLICY +DESCRIPTOR.message_types_by_name['ConfigSignature'] = _CONFIGSIGNATURE + +ConfigEnvelope = _reflection.GeneratedProtocolMessageType('ConfigEnvelope', (_message.Message,), dict( + DESCRIPTOR = _CONFIGENVELOPE, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigEnvelope) + )) +_sym_db.RegisterMessage(ConfigEnvelope) + +ConfigGroupSchema = _reflection.GeneratedProtocolMessageType('ConfigGroupSchema', (_message.Message,), dict( + + GroupsEntry = _reflection.GeneratedProtocolMessageType('GroupsEntry', (_message.Message,), dict( + DESCRIPTOR = _CONFIGGROUPSCHEMA_GROUPSENTRY, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigGroupSchema.GroupsEntry) + )) + , + + ValuesEntry = _reflection.GeneratedProtocolMessageType('ValuesEntry', (_message.Message,), dict( + DESCRIPTOR = _CONFIGGROUPSCHEMA_VALUESENTRY, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigGroupSchema.ValuesEntry) + )) + , + + PoliciesEntry = _reflection.GeneratedProtocolMessageType('PoliciesEntry', (_message.Message,), dict( + DESCRIPTOR = _CONFIGGROUPSCHEMA_POLICIESENTRY, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigGroupSchema.PoliciesEntry) + )) + , + DESCRIPTOR = _CONFIGGROUPSCHEMA, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigGroupSchema) + )) +_sym_db.RegisterMessage(ConfigGroupSchema) +_sym_db.RegisterMessage(ConfigGroupSchema.GroupsEntry) +_sym_db.RegisterMessage(ConfigGroupSchema.ValuesEntry) +_sym_db.RegisterMessage(ConfigGroupSchema.PoliciesEntry) + +ConfigValueSchema = _reflection.GeneratedProtocolMessageType('ConfigValueSchema', (_message.Message,), dict( + DESCRIPTOR = _CONFIGVALUESCHEMA, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigValueSchema) + )) +_sym_db.RegisterMessage(ConfigValueSchema) + +ConfigPolicySchema = _reflection.GeneratedProtocolMessageType('ConfigPolicySchema', (_message.Message,), dict( + DESCRIPTOR = _CONFIGPOLICYSCHEMA, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigPolicySchema) + )) +_sym_db.RegisterMessage(ConfigPolicySchema) + +Config = _reflection.GeneratedProtocolMessageType('Config', (_message.Message,), dict( + DESCRIPTOR = _CONFIG, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.Config) + )) +_sym_db.RegisterMessage(Config) + +ConfigUpdateEnvelope = _reflection.GeneratedProtocolMessageType('ConfigUpdateEnvelope', (_message.Message,), dict( + DESCRIPTOR = _CONFIGUPDATEENVELOPE, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigUpdateEnvelope) + )) +_sym_db.RegisterMessage(ConfigUpdateEnvelope) + +ConfigUpdate = _reflection.GeneratedProtocolMessageType('ConfigUpdate', (_message.Message,), dict( + DESCRIPTOR = _CONFIGUPDATE, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigUpdate) + )) +_sym_db.RegisterMessage(ConfigUpdate) + +ConfigGroup = _reflection.GeneratedProtocolMessageType('ConfigGroup', (_message.Message,), dict( + + GroupsEntry = _reflection.GeneratedProtocolMessageType('GroupsEntry', (_message.Message,), dict( + DESCRIPTOR = _CONFIGGROUP_GROUPSENTRY, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigGroup.GroupsEntry) + )) + , + + ValuesEntry = _reflection.GeneratedProtocolMessageType('ValuesEntry', (_message.Message,), dict( + DESCRIPTOR = _CONFIGGROUP_VALUESENTRY, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigGroup.ValuesEntry) + )) + , + + PoliciesEntry = _reflection.GeneratedProtocolMessageType('PoliciesEntry', (_message.Message,), dict( + DESCRIPTOR = _CONFIGGROUP_POLICIESENTRY, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigGroup.PoliciesEntry) + )) + , + DESCRIPTOR = _CONFIGGROUP, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigGroup) + )) +_sym_db.RegisterMessage(ConfigGroup) +_sym_db.RegisterMessage(ConfigGroup.GroupsEntry) +_sym_db.RegisterMessage(ConfigGroup.ValuesEntry) +_sym_db.RegisterMessage(ConfigGroup.PoliciesEntry) + +ConfigValue = _reflection.GeneratedProtocolMessageType('ConfigValue', (_message.Message,), dict( + DESCRIPTOR = _CONFIGVALUE, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigValue) + )) +_sym_db.RegisterMessage(ConfigValue) + +ConfigPolicy = _reflection.GeneratedProtocolMessageType('ConfigPolicy', (_message.Message,), dict( + DESCRIPTOR = _CONFIGPOLICY, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigPolicy) + )) +_sym_db.RegisterMessage(ConfigPolicy) + +ConfigSignature = _reflection.GeneratedProtocolMessageType('ConfigSignature', (_message.Message,), dict( + DESCRIPTOR = _CONFIGSIGNATURE, + __module__ = 'common.configtx_pb2' + # @@protoc_insertion_point(class_scope:common.ConfigSignature) + )) +_sym_db.RegisterMessage(ConfigSignature) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('Z+github.com/hyperledger/fabric/protos/common')) +_CONFIGGROUPSCHEMA_GROUPSENTRY.has_options = True +_CONFIGGROUPSCHEMA_GROUPSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +_CONFIGGROUPSCHEMA_VALUESENTRY.has_options = True +_CONFIGGROUPSCHEMA_VALUESENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +_CONFIGGROUPSCHEMA_POLICIESENTRY.has_options = True +_CONFIGGROUPSCHEMA_POLICIESENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +_CONFIGGROUP_GROUPSENTRY.has_options = True +_CONFIGGROUP_GROUPSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +_CONFIGGROUP_VALUESENTRY.has_options = True +_CONFIGGROUP_VALUESENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +_CONFIGGROUP_POLICIESENTRY.has_options = True +_CONFIGGROUP_POLICIESENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) +try: + # THESE ELEMENTS WILL BE DEPRECATED. + # Please use the generated *_pb2_grpc.py files instead. + import grpc + from grpc.framework.common import cardinality + from grpc.framework.interfaces.face import utilities as face_utilities + from grpc.beta import implementations as beta_implementations + from grpc.beta import interfaces as beta_interfaces +except ImportError: + pass +# @@protoc_insertion_point(module_scope) diff --git a/bddtests/common/configtx_pb2_grpc.py b/bddtests/common/configtx_pb2_grpc.py new file mode 100644 index 00000000000..c374a4d7d5b --- /dev/null +++ b/bddtests/common/configtx_pb2_grpc.py @@ -0,0 +1,4 @@ +import grpc +from grpc.framework.common import cardinality +from grpc.framework.interfaces.face import utilities as face_utilities + diff --git a/bddtests/common/configuration_pb2.py b/bddtests/common/configuration_pb2.py index a8bf9328156..e224a6882d4 100644 --- a/bddtests/common/configuration_pb2.py +++ b/bddtests/common/configuration_pb2.py @@ -13,447 +13,17 @@ _sym_db = _symbol_database.Default() -from common import common_pb2 as common_dot_common__pb2 -from common import msp_principal_pb2 as common_dot_msp__principal__pb2 DESCRIPTOR = _descriptor.FileDescriptor( name='common/configuration.proto', package='common', syntax='proto3', - serialized_pb=_b('\n\x1a\x63ommon/configuration.proto\x12\x06\x63ommon\x1a\x13\x63ommon/common.proto\x1a\x1a\x63ommon/msp_principal.proto\"G\n\x15\x43onfigurationEnvelope\x12.\n\x05Items\x18\x01 \x03(\x0b\x32\x1f.common.SignedConfigurationItem\"A\n\x15\x43onfigurationTemplate\x12(\n\x05Items\x18\x01 \x03(\x0b\x32\x19.common.ConfigurationItem\"h\n\x17SignedConfigurationItem\x12\x19\n\x11\x43onfigurationItem\x18\x01 \x01(\x0c\x12\x32\n\nSignatures\x18\x02 \x03(\x0b\x32\x1e.common.ConfigurationSignature\"\x8d\x02\n\x11\x43onfigurationItem\x12#\n\x06Header\x18\x01 \x01(\x0b\x32\x13.common.ChainHeader\x12\x39\n\x04Type\x18\x02 \x01(\x0e\x32+.common.ConfigurationItem.ConfigurationType\x12\x14\n\x0cLastModified\x18\x03 \x01(\x04\x12\x1a\n\x12ModificationPolicy\x18\x04 \x01(\t\x12\x0b\n\x03Key\x18\x05 \x01(\t\x12\r\n\x05Value\x18\x06 \x01(\x0c\"J\n\x11\x43onfigurationType\x12\n\n\x06Policy\x10\x00\x12\t\n\x05\x43hain\x10\x01\x12\x0b\n\x07Orderer\x10\x02\x12\x08\n\x04Peer\x10\x03\x12\x07\n\x03MSP\x10\x04\"D\n\x16\x43onfigurationSignature\x12\x17\n\x0fsignatureHeader\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\"Y\n\x06Policy\x12\x0c\n\x04type\x18\x01 \x01(\x05\x12\x0e\n\x06policy\x18\x02 \x01(\x0c\"1\n\nPolicyType\x12\x0b\n\x07UNKNOWN\x10\x00\x12\r\n\tSIGNATURE\x10\x01\x12\x07\n\x03MSP\x10\x02\"}\n\x17SignaturePolicyEnvelope\x12\x0f\n\x07Version\x18\x01 \x01(\x05\x12\'\n\x06Policy\x18\x02 \x01(\x0b\x32\x17.common.SignaturePolicy\x12(\n\nIdentities\x18\x03 \x03(\x0b\x32\x14.common.MSPPrincipal\"\x9d\x01\n\x0fSignaturePolicy\x12\x12\n\x08SignedBy\x18\x01 \x01(\x05H\x00\x12.\n\x04\x46rom\x18\x02 \x01(\x0b\x32\x1e.common.SignaturePolicy.NOutOfH\x00\x1a>\n\x06NOutOf\x12\t\n\x01N\x18\x01 \x01(\x05\x12)\n\x08Policies\x18\x02 \x03(\x0b\x32\x17.common.SignaturePolicyB\x06\n\x04Type\" \n\x10HashingAlgorithm\x12\x0c\n\x04name\x18\x01 \x01(\t\"*\n\x19\x42lockDataHashingStructure\x12\r\n\x05width\x18\x01 \x01(\r\"%\n\x10OrdererAddresses\x12\x11\n\taddresses\x18\x01 \x03(\tB-Z+github.com/hyperledger/fabric/protos/commonb\x06proto3') - , - dependencies=[common_dot_common__pb2.DESCRIPTOR,common_dot_msp__principal__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - - - -_CONFIGURATIONITEM_CONFIGURATIONTYPE = _descriptor.EnumDescriptor( - name='ConfigurationType', - full_name='common.ConfigurationItem.ConfigurationType', - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name='Policy', index=0, number=0, - options=None, - type=None), - _descriptor.EnumValueDescriptor( - name='Chain', index=1, number=1, - options=None, - type=None), - _descriptor.EnumValueDescriptor( - name='Orderer', index=2, number=2, - options=None, - type=None), - _descriptor.EnumValueDescriptor( - name='Peer', index=3, number=3, - options=None, - type=None), - _descriptor.EnumValueDescriptor( - name='MSP', index=4, number=4, - options=None, - type=None), - ], - containing_type=None, - options=None, - serialized_start=529, - serialized_end=603, -) -_sym_db.RegisterEnumDescriptor(_CONFIGURATIONITEM_CONFIGURATIONTYPE) - -_POLICY_POLICYTYPE = _descriptor.EnumDescriptor( - name='PolicyType', - full_name='common.Policy.PolicyType', - filename=None, - file=DESCRIPTOR, - values=[ - _descriptor.EnumValueDescriptor( - name='UNKNOWN', index=0, number=0, - options=None, - type=None), - _descriptor.EnumValueDescriptor( - name='SIGNATURE', index=1, number=1, - options=None, - type=None), - _descriptor.EnumValueDescriptor( - name='MSP', index=2, number=2, - options=None, - type=None), - ], - containing_type=None, - options=None, - serialized_start=715, - serialized_end=764, -) -_sym_db.RegisterEnumDescriptor(_POLICY_POLICYTYPE) - - -_CONFIGURATIONENVELOPE = _descriptor.Descriptor( - name='ConfigurationEnvelope', - full_name='common.ConfigurationEnvelope', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='Items', full_name='common.ConfigurationEnvelope.Items', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=87, - serialized_end=158, -) - - -_CONFIGURATIONTEMPLATE = _descriptor.Descriptor( - name='ConfigurationTemplate', - full_name='common.ConfigurationTemplate', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='Items', full_name='common.ConfigurationTemplate.Items', index=0, - number=1, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=160, - serialized_end=225, -) - - -_SIGNEDCONFIGURATIONITEM = _descriptor.Descriptor( - name='SignedConfigurationItem', - full_name='common.SignedConfigurationItem', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='ConfigurationItem', full_name='common.SignedConfigurationItem.ConfigurationItem', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=_b(""), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='Signatures', full_name='common.SignedConfigurationItem.Signatures', index=1, - number=2, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=227, - serialized_end=331, -) - - -_CONFIGURATIONITEM = _descriptor.Descriptor( - name='ConfigurationItem', - full_name='common.ConfigurationItem', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='Header', full_name='common.ConfigurationItem.Header', index=0, - number=1, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='Type', full_name='common.ConfigurationItem.Type', index=1, - number=2, type=14, cpp_type=8, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='LastModified', full_name='common.ConfigurationItem.LastModified', index=2, - number=3, type=4, cpp_type=4, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='ModificationPolicy', full_name='common.ConfigurationItem.ModificationPolicy', index=3, - number=4, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=_b("").decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='Key', full_name='common.ConfigurationItem.Key', index=4, - number=5, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=_b("").decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='Value', full_name='common.ConfigurationItem.Value', index=5, - number=6, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=_b(""), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - _CONFIGURATIONITEM_CONFIGURATIONTYPE, - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=334, - serialized_end=603, -) - - -_CONFIGURATIONSIGNATURE = _descriptor.Descriptor( - name='ConfigurationSignature', - full_name='common.ConfigurationSignature', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='signatureHeader', full_name='common.ConfigurationSignature.signatureHeader', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=_b(""), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='signature', full_name='common.ConfigurationSignature.signature', index=1, - number=2, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=_b(""), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=605, - serialized_end=673, -) - - -_POLICY = _descriptor.Descriptor( - name='Policy', - full_name='common.Policy', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='type', full_name='common.Policy.type', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='policy', full_name='common.Policy.policy', index=1, - number=2, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=_b(""), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - _POLICY_POLICYTYPE, - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=675, - serialized_end=764, + serialized_pb=_b('\n\x1a\x63ommon/configuration.proto\x12\x06\x63ommon\" \n\x10HashingAlgorithm\x12\x0c\n\x04name\x18\x01 \x01(\t\"*\n\x19\x42lockDataHashingStructure\x12\r\n\x05width\x18\x01 \x01(\r\"%\n\x10OrdererAddresses\x12\x11\n\taddresses\x18\x01 \x03(\tB-Z+github.com/hyperledger/fabric/protos/commonb\x06proto3') ) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) -_SIGNATUREPOLICYENVELOPE = _descriptor.Descriptor( - name='SignaturePolicyEnvelope', - full_name='common.SignaturePolicyEnvelope', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='Version', full_name='common.SignaturePolicyEnvelope.Version', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='Policy', full_name='common.SignaturePolicyEnvelope.Policy', index=1, - number=2, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='Identities', full_name='common.SignaturePolicyEnvelope.Identities', index=2, - number=3, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=766, - serialized_end=891, -) - - -_SIGNATUREPOLICY_NOUTOF = _descriptor.Descriptor( - name='NOutOf', - full_name='common.SignaturePolicy.NOutOf', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='N', full_name='common.SignaturePolicy.NOutOf.N', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='Policies', full_name='common.SignaturePolicy.NOutOf.Policies', index=1, - number=2, type=11, cpp_type=10, label=3, - has_default_value=False, default_value=[], - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=981, - serialized_end=1043, -) - -_SIGNATUREPOLICY = _descriptor.Descriptor( - name='SignaturePolicy', - full_name='common.SignaturePolicy', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='SignedBy', full_name='common.SignaturePolicy.SignedBy', index=0, - number=1, type=5, cpp_type=1, label=1, - has_default_value=False, default_value=0, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='From', full_name='common.SignaturePolicy.From', index=1, - number=2, type=11, cpp_type=10, label=1, - has_default_value=False, default_value=None, - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[_SIGNATUREPOLICY_NOUTOF, ], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - _descriptor.OneofDescriptor( - name='Type', full_name='common.SignaturePolicy.Type', - index=0, containing_type=None, fields=[]), - ], - serialized_start=894, - serialized_end=1051, -) _HASHINGALGORITHM = _descriptor.Descriptor( @@ -482,8 +52,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1053, - serialized_end=1085, + serialized_start=38, + serialized_end=70, ) @@ -513,8 +83,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1087, - serialized_end=1129, + serialized_start=72, + serialized_end=114, ) @@ -544,104 +114,14 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1131, - serialized_end=1168, + serialized_start=116, + serialized_end=153, ) -_CONFIGURATIONENVELOPE.fields_by_name['Items'].message_type = _SIGNEDCONFIGURATIONITEM -_CONFIGURATIONTEMPLATE.fields_by_name['Items'].message_type = _CONFIGURATIONITEM -_SIGNEDCONFIGURATIONITEM.fields_by_name['Signatures'].message_type = _CONFIGURATIONSIGNATURE -_CONFIGURATIONITEM.fields_by_name['Header'].message_type = common_dot_common__pb2._CHAINHEADER -_CONFIGURATIONITEM.fields_by_name['Type'].enum_type = _CONFIGURATIONITEM_CONFIGURATIONTYPE -_CONFIGURATIONITEM_CONFIGURATIONTYPE.containing_type = _CONFIGURATIONITEM -_POLICY_POLICYTYPE.containing_type = _POLICY -_SIGNATUREPOLICYENVELOPE.fields_by_name['Policy'].message_type = _SIGNATUREPOLICY -_SIGNATUREPOLICYENVELOPE.fields_by_name['Identities'].message_type = common_dot_msp__principal__pb2._MSPPRINCIPAL -_SIGNATUREPOLICY_NOUTOF.fields_by_name['Policies'].message_type = _SIGNATUREPOLICY -_SIGNATUREPOLICY_NOUTOF.containing_type = _SIGNATUREPOLICY -_SIGNATUREPOLICY.fields_by_name['From'].message_type = _SIGNATUREPOLICY_NOUTOF -_SIGNATUREPOLICY.oneofs_by_name['Type'].fields.append( - _SIGNATUREPOLICY.fields_by_name['SignedBy']) -_SIGNATUREPOLICY.fields_by_name['SignedBy'].containing_oneof = _SIGNATUREPOLICY.oneofs_by_name['Type'] -_SIGNATUREPOLICY.oneofs_by_name['Type'].fields.append( - _SIGNATUREPOLICY.fields_by_name['From']) -_SIGNATUREPOLICY.fields_by_name['From'].containing_oneof = _SIGNATUREPOLICY.oneofs_by_name['Type'] -DESCRIPTOR.message_types_by_name['ConfigurationEnvelope'] = _CONFIGURATIONENVELOPE -DESCRIPTOR.message_types_by_name['ConfigurationTemplate'] = _CONFIGURATIONTEMPLATE -DESCRIPTOR.message_types_by_name['SignedConfigurationItem'] = _SIGNEDCONFIGURATIONITEM -DESCRIPTOR.message_types_by_name['ConfigurationItem'] = _CONFIGURATIONITEM -DESCRIPTOR.message_types_by_name['ConfigurationSignature'] = _CONFIGURATIONSIGNATURE -DESCRIPTOR.message_types_by_name['Policy'] = _POLICY -DESCRIPTOR.message_types_by_name['SignaturePolicyEnvelope'] = _SIGNATUREPOLICYENVELOPE -DESCRIPTOR.message_types_by_name['SignaturePolicy'] = _SIGNATUREPOLICY DESCRIPTOR.message_types_by_name['HashingAlgorithm'] = _HASHINGALGORITHM DESCRIPTOR.message_types_by_name['BlockDataHashingStructure'] = _BLOCKDATAHASHINGSTRUCTURE DESCRIPTOR.message_types_by_name['OrdererAddresses'] = _ORDERERADDRESSES -ConfigurationEnvelope = _reflection.GeneratedProtocolMessageType('ConfigurationEnvelope', (_message.Message,), dict( - DESCRIPTOR = _CONFIGURATIONENVELOPE, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.ConfigurationEnvelope) - )) -_sym_db.RegisterMessage(ConfigurationEnvelope) - -ConfigurationTemplate = _reflection.GeneratedProtocolMessageType('ConfigurationTemplate', (_message.Message,), dict( - DESCRIPTOR = _CONFIGURATIONTEMPLATE, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.ConfigurationTemplate) - )) -_sym_db.RegisterMessage(ConfigurationTemplate) - -SignedConfigurationItem = _reflection.GeneratedProtocolMessageType('SignedConfigurationItem', (_message.Message,), dict( - DESCRIPTOR = _SIGNEDCONFIGURATIONITEM, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.SignedConfigurationItem) - )) -_sym_db.RegisterMessage(SignedConfigurationItem) - -ConfigurationItem = _reflection.GeneratedProtocolMessageType('ConfigurationItem', (_message.Message,), dict( - DESCRIPTOR = _CONFIGURATIONITEM, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.ConfigurationItem) - )) -_sym_db.RegisterMessage(ConfigurationItem) - -ConfigurationSignature = _reflection.GeneratedProtocolMessageType('ConfigurationSignature', (_message.Message,), dict( - DESCRIPTOR = _CONFIGURATIONSIGNATURE, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.ConfigurationSignature) - )) -_sym_db.RegisterMessage(ConfigurationSignature) - -Policy = _reflection.GeneratedProtocolMessageType('Policy', (_message.Message,), dict( - DESCRIPTOR = _POLICY, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.Policy) - )) -_sym_db.RegisterMessage(Policy) - -SignaturePolicyEnvelope = _reflection.GeneratedProtocolMessageType('SignaturePolicyEnvelope', (_message.Message,), dict( - DESCRIPTOR = _SIGNATUREPOLICYENVELOPE, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.SignaturePolicyEnvelope) - )) -_sym_db.RegisterMessage(SignaturePolicyEnvelope) - -SignaturePolicy = _reflection.GeneratedProtocolMessageType('SignaturePolicy', (_message.Message,), dict( - - NOutOf = _reflection.GeneratedProtocolMessageType('NOutOf', (_message.Message,), dict( - DESCRIPTOR = _SIGNATUREPOLICY_NOUTOF, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.SignaturePolicy.NOutOf) - )) - , - DESCRIPTOR = _SIGNATUREPOLICY, - __module__ = 'common.configuration_pb2' - # @@protoc_insertion_point(class_scope:common.SignaturePolicy) - )) -_sym_db.RegisterMessage(SignaturePolicy) -_sym_db.RegisterMessage(SignaturePolicy.NOutOf) - HashingAlgorithm = _reflection.GeneratedProtocolMessageType('HashingAlgorithm', (_message.Message,), dict( DESCRIPTOR = _HASHINGALGORITHM, __module__ = 'common.configuration_pb2' diff --git a/bddtests/common/policies_pb2.py b/bddtests/common/policies_pb2.py new file mode 100644 index 00000000000..45c154dd96b --- /dev/null +++ b/bddtests/common/policies_pb2.py @@ -0,0 +1,355 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: common/policies.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from common import msp_principal_pb2 as common_dot_msp__principal__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='common/policies.proto', + package='common', + syntax='proto3', + serialized_pb=_b('\n\x15\x63ommon/policies.proto\x12\x06\x63ommon\x1a\x1a\x63ommon/msp_principal.proto\"l\n\x06Policy\x12\x0c\n\x04type\x18\x01 \x01(\x05\x12\x0e\n\x06policy\x18\x02 \x01(\x0c\"D\n\nPolicyType\x12\x0b\n\x07UNKNOWN\x10\x00\x12\r\n\tSIGNATURE\x10\x01\x12\x07\n\x03MSP\x10\x02\x12\x11\n\rIMPLICIT_META\x10\x03\"}\n\x17SignaturePolicyEnvelope\x12\x0f\n\x07version\x18\x01 \x01(\x05\x12\'\n\x06policy\x18\x02 \x01(\x0b\x32\x17.common.SignaturePolicy\x12(\n\nidentities\x18\x03 \x03(\x0b\x32\x14.common.MSPPrincipal\"\xa2\x01\n\x0fSignaturePolicy\x12\x13\n\tsigned_by\x18\x01 \x01(\x05H\x00\x12\x32\n\x08n_out_of\x18\x02 \x01(\x0b\x32\x1e.common.SignaturePolicy.NOutOfH\x00\x1a>\n\x06NOutOf\x12\t\n\x01N\x18\x01 \x01(\x05\x12)\n\x08policies\x18\x02 \x03(\x0b\x32\x17.common.SignaturePolicyB\x06\n\x04Type\"\x7f\n\x12ImplicitMetaPolicy\x12\x12\n\nsub_policy\x18\x01 \x01(\t\x12-\n\x04rule\x18\x02 \x01(\x0e\x32\x1f.common.ImplicitMetaPolicy.Rule\"&\n\x04Rule\x12\x07\n\x03\x41NY\x10\x00\x12\x07\n\x03\x41LL\x10\x01\x12\x0c\n\x08MAJORITY\x10\x02\x42-Z+github.com/hyperledger/fabric/protos/commonb\x06proto3') + , + dependencies=[common_dot_msp__principal__pb2.DESCRIPTOR,]) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + + + +_POLICY_POLICYTYPE = _descriptor.EnumDescriptor( + name='PolicyType', + full_name='common.Policy.PolicyType', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='UNKNOWN', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SIGNATURE', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='MSP', index=2, number=2, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='IMPLICIT_META', index=3, number=3, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=101, + serialized_end=169, +) +_sym_db.RegisterEnumDescriptor(_POLICY_POLICYTYPE) + +_IMPLICITMETAPOLICY_RULE = _descriptor.EnumDescriptor( + name='Rule', + full_name='common.ImplicitMetaPolicy.Rule', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='ANY', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='ALL', index=1, number=1, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='MAJORITY', index=2, number=2, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=552, + serialized_end=590, +) +_sym_db.RegisterEnumDescriptor(_IMPLICITMETAPOLICY_RULE) + + +_POLICY = _descriptor.Descriptor( + name='Policy', + full_name='common.Policy', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='type', full_name='common.Policy.type', index=0, + number=1, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='policy', full_name='common.Policy.policy', index=1, + number=2, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=_b(""), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + _POLICY_POLICYTYPE, + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=61, + serialized_end=169, +) + + +_SIGNATUREPOLICYENVELOPE = _descriptor.Descriptor( + name='SignaturePolicyEnvelope', + full_name='common.SignaturePolicyEnvelope', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='version', full_name='common.SignaturePolicyEnvelope.version', index=0, + number=1, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='policy', full_name='common.SignaturePolicyEnvelope.policy', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='identities', full_name='common.SignaturePolicyEnvelope.identities', index=2, + number=3, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=171, + serialized_end=296, +) + + +_SIGNATUREPOLICY_NOUTOF = _descriptor.Descriptor( + name='NOutOf', + full_name='common.SignaturePolicy.NOutOf', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='N', full_name='common.SignaturePolicy.NOutOf.N', index=0, + number=1, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='policies', full_name='common.SignaturePolicy.NOutOf.policies', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=391, + serialized_end=453, +) + +_SIGNATUREPOLICY = _descriptor.Descriptor( + name='SignaturePolicy', + full_name='common.SignaturePolicy', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='signed_by', full_name='common.SignaturePolicy.signed_by', index=0, + number=1, type=5, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='n_out_of', full_name='common.SignaturePolicy.n_out_of', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[_SIGNATUREPOLICY_NOUTOF, ], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name='Type', full_name='common.SignaturePolicy.Type', + index=0, containing_type=None, fields=[]), + ], + serialized_start=299, + serialized_end=461, +) + + +_IMPLICITMETAPOLICY = _descriptor.Descriptor( + name='ImplicitMetaPolicy', + full_name='common.ImplicitMetaPolicy', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='sub_policy', full_name='common.ImplicitMetaPolicy.sub_policy', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='rule', full_name='common.ImplicitMetaPolicy.rule', index=1, + number=2, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + _IMPLICITMETAPOLICY_RULE, + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=463, + serialized_end=590, +) + +_POLICY_POLICYTYPE.containing_type = _POLICY +_SIGNATUREPOLICYENVELOPE.fields_by_name['policy'].message_type = _SIGNATUREPOLICY +_SIGNATUREPOLICYENVELOPE.fields_by_name['identities'].message_type = common_dot_msp__principal__pb2._MSPPRINCIPAL +_SIGNATUREPOLICY_NOUTOF.fields_by_name['policies'].message_type = _SIGNATUREPOLICY +_SIGNATUREPOLICY_NOUTOF.containing_type = _SIGNATUREPOLICY +_SIGNATUREPOLICY.fields_by_name['n_out_of'].message_type = _SIGNATUREPOLICY_NOUTOF +_SIGNATUREPOLICY.oneofs_by_name['Type'].fields.append( + _SIGNATUREPOLICY.fields_by_name['signed_by']) +_SIGNATUREPOLICY.fields_by_name['signed_by'].containing_oneof = _SIGNATUREPOLICY.oneofs_by_name['Type'] +_SIGNATUREPOLICY.oneofs_by_name['Type'].fields.append( + _SIGNATUREPOLICY.fields_by_name['n_out_of']) +_SIGNATUREPOLICY.fields_by_name['n_out_of'].containing_oneof = _SIGNATUREPOLICY.oneofs_by_name['Type'] +_IMPLICITMETAPOLICY.fields_by_name['rule'].enum_type = _IMPLICITMETAPOLICY_RULE +_IMPLICITMETAPOLICY_RULE.containing_type = _IMPLICITMETAPOLICY +DESCRIPTOR.message_types_by_name['Policy'] = _POLICY +DESCRIPTOR.message_types_by_name['SignaturePolicyEnvelope'] = _SIGNATUREPOLICYENVELOPE +DESCRIPTOR.message_types_by_name['SignaturePolicy'] = _SIGNATUREPOLICY +DESCRIPTOR.message_types_by_name['ImplicitMetaPolicy'] = _IMPLICITMETAPOLICY + +Policy = _reflection.GeneratedProtocolMessageType('Policy', (_message.Message,), dict( + DESCRIPTOR = _POLICY, + __module__ = 'common.policies_pb2' + # @@protoc_insertion_point(class_scope:common.Policy) + )) +_sym_db.RegisterMessage(Policy) + +SignaturePolicyEnvelope = _reflection.GeneratedProtocolMessageType('SignaturePolicyEnvelope', (_message.Message,), dict( + DESCRIPTOR = _SIGNATUREPOLICYENVELOPE, + __module__ = 'common.policies_pb2' + # @@protoc_insertion_point(class_scope:common.SignaturePolicyEnvelope) + )) +_sym_db.RegisterMessage(SignaturePolicyEnvelope) + +SignaturePolicy = _reflection.GeneratedProtocolMessageType('SignaturePolicy', (_message.Message,), dict( + + NOutOf = _reflection.GeneratedProtocolMessageType('NOutOf', (_message.Message,), dict( + DESCRIPTOR = _SIGNATUREPOLICY_NOUTOF, + __module__ = 'common.policies_pb2' + # @@protoc_insertion_point(class_scope:common.SignaturePolicy.NOutOf) + )) + , + DESCRIPTOR = _SIGNATUREPOLICY, + __module__ = 'common.policies_pb2' + # @@protoc_insertion_point(class_scope:common.SignaturePolicy) + )) +_sym_db.RegisterMessage(SignaturePolicy) +_sym_db.RegisterMessage(SignaturePolicy.NOutOf) + +ImplicitMetaPolicy = _reflection.GeneratedProtocolMessageType('ImplicitMetaPolicy', (_message.Message,), dict( + DESCRIPTOR = _IMPLICITMETAPOLICY, + __module__ = 'common.policies_pb2' + # @@protoc_insertion_point(class_scope:common.ImplicitMetaPolicy) + )) +_sym_db.RegisterMessage(ImplicitMetaPolicy) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('Z+github.com/hyperledger/fabric/protos/common')) +try: + # THESE ELEMENTS WILL BE DEPRECATED. + # Please use the generated *_pb2_grpc.py files instead. + import grpc + from grpc.framework.common import cardinality + from grpc.framework.interfaces.face import utilities as face_utilities + from grpc.beta import implementations as beta_implementations + from grpc.beta import interfaces as beta_interfaces +except ImportError: + pass +# @@protoc_insertion_point(module_scope) diff --git a/bddtests/common/policies_pb2_grpc.py b/bddtests/common/policies_pb2_grpc.py new file mode 100644 index 00000000000..c374a4d7d5b --- /dev/null +++ b/bddtests/common/policies_pb2_grpc.py @@ -0,0 +1,4 @@ +import grpc +from grpc.framework.common import cardinality +from grpc.framework.interfaces.face import utilities as face_utilities + diff --git a/bddtests/docker-compose-next-4.yml b/bddtests/docker-compose-next-4.yml index c1e9db6d4b2..29e8e93fa1e 100644 --- a/bddtests/docker-compose-next-4.yml +++ b/bddtests/docker-compose-next-4.yml @@ -6,6 +6,8 @@ services: extends: file: docker-compose-orderer-solo.yml service: orderer0 + environment: + - ORDERER_GENERAL_LOCALMSPDIR=${ORDERER0_ORDERER_GENERAL_LOCALMSPDIR} peer0: diff --git a/bddtests/environment.py b/bddtests/environment.py index a0b0415ae43..a3dd873c549 100644 --- a/bddtests/environment.py +++ b/bddtests/environment.py @@ -1,9 +1,8 @@ import subprocess -import os -import glob +from steps.docgen import DocumentGenerator from steps.bdd_test_util import cli_call - +from steps.contexthelper import ContextHelper from steps.coverage import saveCoverageFiles, createCoverageAggregate def coverageEnabled(context): @@ -17,7 +16,21 @@ def getDockerComposeFileArgsFromYamlFile(compose_yaml): args = args + ["-f"] + [part] return args +def before_step(context, step): + contextHelper = ContextHelper.GetHelper(context=context) + contextHelper.before_step(step) + +def before_scenario(context, scenario): + contextHelper = ContextHelper.GetHelper(context=context) + contextHelper.before_scenario(scenario) + if 'generateDocs' in scenario.tags: + DocumentGenerator(contextHelper=contextHelper, scenario=scenario) + + def after_scenario(context, scenario): + contextHelper = ContextHelper.GetHelper(context=context) + contextHelper.after_scenario(scenario) + get_logs = context.config.userdata.get("logs", "N") if get_logs.lower() == "force" or (scenario.status == "failed" and get_logs.lower() == "y" and "compose_containers" in context): print("Scenario {0} failed. Getting container logs".format(scenario.name)) diff --git a/bddtests/features/bootstrap.feature b/bddtests/features/bootstrap.feature index c3fa2017892..9392ebb4a16 100644 --- a/bddtests/features/bootstrap.feature +++ b/bddtests/features/bootstrap.feature @@ -12,7 +12,8 @@ Feature: Bootstrap I want to bootstrap a new blockchain network @doNotDecompose - Scenario Outline: Bootstrap a development network with 1 peer and 1 orderer, each having a single independent root of trust (No COP) + @generateDocs + Scenario Outline: Bootstrap a development network with 4 peers (2 orgs) and 1 orderer (1 org), each having a single independent root of trust (No fabric-ca, just openssl) #creates 1 self-signed key/cert pair per orderer organization Given the orderer network has organizations: | Organization | @@ -32,34 +33,28 @@ Feature: Bootstrap And the ordererBootstrapAdmin generates a GUUID to identify the orderer system chain and refer to it by name as "OrdererSystemChainId" - # Actually creating proto ordere_dot_confoiguration.ChainCreators - # Creates SignedConfigItems - # Policy And the ordererBootstrapAdmin creates a chain creators policy "chainCreatePolicy1" (network name) for peer orgs who wish to form a network using orderer system chain "OrdererSystemChainId": | Organization | | peerOrg0 | | peerOrg1 | | peerOrg2 | - # Creates SignedConfigItems - And the ordererBoostrapAdmin creates the chain creation policy names "chainCreationPolicyNames" signedConfigurationItem for orderer system chain "OrdererSystemChainId" with policies: + And the ordererBoostrapAdmin creates the chain creation policy names "chainCreationPolicyNames" for orderer system chain "OrdererSystemChainId" with policies: |PolicyName | |chainCreatePolicy1 | - - # Creates SignedConfigItems - And the ordererBoostrapAdmin creates MSP Configuration Items "mspConfigItems1" for orderer system chain "OrdererSystemChainId" for every MSP referenced by the policies: + And the ordererBoostrapAdmin creates MSP configuration "mspConfig1" for orderer system chain "OrdererSystemChainId" for every MSP referenced by the policies: |PolicyName | |chainCreatePolicy1 | # Order info includes orderer admin/orderer information and address (host:port) from previous steps # Only the peer organizations can vary. - And the ordererBootstrapAdmin creates the genesis block for chain "OrdererSystemChainId" for network config policy "" and consensus "" using chain creators policies: - | SignedConfigItemsName | + And the ordererBootstrapAdmin creates the genesis block "ordererGenesisBlock" for chain "OrdererSystemChainId" for network config policy "" and consensus "" using chain creators policies: + | ConfigGroup Names | | chainCreatePolicy1 | | chainCreationPolicyNames | - | mspConfigItems1 | + | mspConfig1 | And the orderer admins inspect and approve the genesis block for chain "OrdererSystemChainId" @@ -103,18 +98,18 @@ Feature: Bootstrap # TODO: grab the peer orgs from template1 and put into Murali's MSP info SCIs. # Entry point for creating a channel from existing templates - And the user "dev0Org0" creates a signedConfigEnvelope "createChannelSignedConfigEnvelope1" + And the user "dev0Org0" creates a ConfigUpdateEnvelope "createChannelConfigUpdate1" | ChannelID | Template | Chain Creation Policy Name | Anchors | | com.acme.blockchain.jdoe.Channel1 | template1 | chainCreatePolicy1 | anchors1 | - And the user "dev0Org0" collects signatures for signedConfigEnvelope "createChannelSignedConfigEnvelope1" from peer orgs: + And the user "dev0Org0" collects signatures for ConfigUpdateEnvelope "createChannelConfigUpdate1" from peer orgs: | Organization | | peerOrg0 | | peerOrg1 | - And the user "dev0Org0" creates config Tx "configTx1" using signedConfigEnvelope "createChannelSignedConfigEnvelope1" + And the user "dev0Org0" creates a ConfigUpdate Tx "configUpdateTx1" using signed ConfigUpdateEnvelope "createChannelConfigUpdate1" - And the user "dev0Org0" broadcasts config Tx "configTx1" to orderer "orderer0" to create channel "com.acme.blockchain.jdoe.Channel1" + And the user "dev0Org0" broadcasts ConfigUpdate Tx "configUpdateTx1" to orderer "orderer0" to create channel "com.acme.blockchain.jdoe.Channel1" # Sleep as the deliver takes a bit to have the first block ready And I wait "2" seconds diff --git a/bddtests/msp/mspconfig_pb2.py b/bddtests/msp/mspconfig_pb2.py index 5e1ef462504..62cabda568e 100644 --- a/bddtests/msp/mspconfig_pb2.py +++ b/bddtests/msp/mspconfig_pb2.py @@ -19,7 +19,7 @@ name='msp/mspconfig.proto', package='msp', syntax='proto3', - serialized_pb=_b('\n\x13msp/mspconfig.proto\x12\x03msp\")\n\tMSPConfig\x12\x0c\n\x04Type\x18\x01 \x01(\x05\x12\x0e\n\x06\x43onfig\x18\x02 \x01(\x0c\"\x8d\x01\n\x0f\x46\x61\x62ricMSPConfig\x12\x0c\n\x04Name\x18\x01 \x01(\t\x12\x11\n\tRootCerts\x18\x02 \x03(\x0c\x12\x0e\n\x06\x41\x64mins\x18\x03 \x03(\x0c\x12\x16\n\x0eRevocationList\x18\x04 \x03(\x0c\x12\x31\n\x0fSigningIdentity\x18\x05 \x01(\x0b\x32\x18.msp.SigningIdentityInfo\"P\n\x13SigningIdentityInfo\x12\x14\n\x0cPublicSigner\x18\x01 \x01(\x0c\x12#\n\rPrivateSigner\x18\x02 \x01(\x0b\x32\x0c.msp.KeyInfo\"5\n\x07KeyInfo\x12\x15\n\rKeyIdentifier\x18\x01 \x01(\t\x12\x13\n\x0bKeyMaterial\x18\x02 \x01(\x0c\x42*Z(github.com/hyperledger/fabric/protos/mspb\x06proto3') + serialized_pb=_b('\n\x13msp/mspconfig.proto\x12\x03msp\")\n\tMSPConfig\x12\x0c\n\x04type\x18\x01 \x01(\x05\x12\x0e\n\x06\x63onfig\x18\x02 \x01(\x0c\"\xac\x01\n\x0f\x46\x61\x62ricMSPConfig\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nroot_certs\x18\x02 \x03(\x0c\x12\x1a\n\x12intermediate_certs\x18\x03 \x03(\x0c\x12\x0e\n\x06\x61\x64mins\x18\x04 \x03(\x0c\x12\x17\n\x0frevocation_list\x18\x05 \x03(\x0c\x12\x32\n\x10signing_identity\x18\x06 \x01(\x0b\x32\x18.msp.SigningIdentityInfo\"R\n\x13SigningIdentityInfo\x12\x15\n\rpublic_signer\x18\x01 \x01(\x0c\x12$\n\x0eprivate_signer\x18\x02 \x01(\x0b\x32\x0c.msp.KeyInfo\"7\n\x07KeyInfo\x12\x16\n\x0ekey_identifier\x18\x01 \x01(\t\x12\x14\n\x0ckey_material\x18\x02 \x01(\x0c\x42*Z(github.com/hyperledger/fabric/protos/mspb\x06proto3') ) _sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -34,14 +34,14 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Type', full_name='msp.MSPConfig.Type', index=0, + name='type', full_name='msp.MSPConfig.type', index=0, number=1, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='Config', full_name='msp.MSPConfig.Config', index=1, + name='config', full_name='msp.MSPConfig.config', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, @@ -72,36 +72,43 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Name', full_name='msp.FabricMSPConfig.Name', index=0, + name='name', full_name='msp.FabricMSPConfig.name', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='RootCerts', full_name='msp.FabricMSPConfig.RootCerts', index=1, + name='root_certs', full_name='msp.FabricMSPConfig.root_certs', index=1, number=2, type=12, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='Admins', full_name='msp.FabricMSPConfig.Admins', index=2, + name='intermediate_certs', full_name='msp.FabricMSPConfig.intermediate_certs', index=2, number=3, type=12, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='RevocationList', full_name='msp.FabricMSPConfig.RevocationList', index=3, + name='admins', full_name='msp.FabricMSPConfig.admins', index=3, number=4, type=12, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='SigningIdentity', full_name='msp.FabricMSPConfig.SigningIdentity', index=4, - number=5, type=11, cpp_type=10, label=1, + name='revocation_list', full_name='msp.FabricMSPConfig.revocation_list', index=4, + number=5, type=12, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='signing_identity', full_name='msp.FabricMSPConfig.signing_identity', index=5, + number=6, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, @@ -119,7 +126,7 @@ oneofs=[ ], serialized_start=72, - serialized_end=213, + serialized_end=244, ) @@ -131,14 +138,14 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='PublicSigner', full_name='msp.SigningIdentityInfo.PublicSigner', index=0, + name='public_signer', full_name='msp.SigningIdentityInfo.public_signer', index=0, number=1, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='PrivateSigner', full_name='msp.SigningIdentityInfo.PrivateSigner', index=1, + name='private_signer', full_name='msp.SigningIdentityInfo.private_signer', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -156,8 +163,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=215, - serialized_end=295, + serialized_start=246, + serialized_end=328, ) @@ -169,14 +176,14 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='KeyIdentifier', full_name='msp.KeyInfo.KeyIdentifier', index=0, + name='key_identifier', full_name='msp.KeyInfo.key_identifier', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='KeyMaterial', full_name='msp.KeyInfo.KeyMaterial', index=1, + name='key_material', full_name='msp.KeyInfo.key_material', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, @@ -194,12 +201,12 @@ extension_ranges=[], oneofs=[ ], - serialized_start=297, - serialized_end=350, + serialized_start=330, + serialized_end=385, ) -_FABRICMSPCONFIG.fields_by_name['SigningIdentity'].message_type = _SIGNINGIDENTITYINFO -_SIGNINGIDENTITYINFO.fields_by_name['PrivateSigner'].message_type = _KEYINFO +_FABRICMSPCONFIG.fields_by_name['signing_identity'].message_type = _SIGNINGIDENTITYINFO +_SIGNINGIDENTITYINFO.fields_by_name['private_signer'].message_type = _KEYINFO DESCRIPTOR.message_types_by_name['MSPConfig'] = _MSPCONFIG DESCRIPTOR.message_types_by_name['FabricMSPConfig'] = _FABRICMSPCONFIG DESCRIPTOR.message_types_by_name['SigningIdentityInfo'] = _SIGNINGIDENTITYINFO diff --git a/bddtests/peer/chaincode_pb2.py b/bddtests/peer/chaincode_pb2.py index 37b8b5dfdf2..c3bcd44e9d0 100644 --- a/bddtests/peer/chaincode_pb2.py +++ b/bddtests/peer/chaincode_pb2.py @@ -22,7 +22,7 @@ name='peer/chaincode.proto', package='protos', syntax='proto3', - serialized_pb=_b('\n\x14peer/chaincode.proto\x12\x06protos\x1a\x19peer/chaincodeevent.proto\x1a\x1fgoogle/protobuf/timestamp.proto\")\n\x0b\x43haincodeID\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\"\x1e\n\x0e\x43haincodeInput\x12\x0c\n\x04\x61rgs\x18\x01 \x03(\x0c\"\xdb\x01\n\rChaincodeSpec\x12(\n\x04type\x18\x01 \x01(\x0e\x32\x1a.protos.ChaincodeSpec.Type\x12(\n\x0b\x63haincodeID\x18\x02 \x01(\x0b\x32\x13.protos.ChaincodeID\x12%\n\x05input\x18\x03 \x01(\x0b\x32\x16.protos.ChaincodeInput\x12\x0f\n\x07timeout\x18\x04 \x01(\x05\">\n\x04Type\x12\r\n\tUNDEFINED\x10\x00\x12\n\n\x06GOLANG\x10\x01\x12\x08\n\x04NODE\x10\x02\x12\x07\n\x03\x43\x41R\x10\x03\x12\x08\n\x04JAVA\x10\x04\"\x86\x02\n\x17\x43haincodeDeploymentSpec\x12,\n\rchaincodeSpec\x18\x01 \x01(\x0b\x32\x15.protos.ChaincodeSpec\x12\x31\n\reffectiveDate\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x13\n\x0b\x63odePackage\x18\x03 \x01(\x0c\x12\x45\n\x07\x65xecEnv\x18\x04 \x01(\x0e\x32\x34.protos.ChaincodeDeploymentSpec.ExecutionEnvironment\".\n\x14\x45xecutionEnvironment\x12\n\n\x06\x44OCKER\x10\x00\x12\n\n\x06SYSTEM\x10\x01\"`\n\x17\x43haincodeInvocationSpec\x12,\n\rchaincodeSpec\x18\x01 \x01(\x0b\x32\x15.protos.ChaincodeSpec\x12\x17\n\x0fidGenerationAlg\x18\x02 \x01(\t\">\n\x18\x43haincodeProposalContext\x12\x0f\n\x07\x63reator\x18\x01 \x01(\x0c\x12\x11\n\ttransient\x18\x02 \x01(\x0c\"\xab\x04\n\x10\x43haincodeMessage\x12+\n\x04type\x18\x01 \x01(\x0e\x32\x1d.protos.ChaincodeMessage.Type\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07payload\x18\x03 \x01(\x0c\x12\x0c\n\x04txid\x18\x04 \x01(\t\x12\x39\n\x0fproposalContext\x18\x05 \x01(\x0b\x32 .protos.ChaincodeProposalContext\x12.\n\x0e\x63haincodeEvent\x18\x06 \x01(\x0b\x32\x16.protos.ChaincodeEvent\"\xb0\x02\n\x04Type\x12\r\n\tUNDEFINED\x10\x00\x12\x0c\n\x08REGISTER\x10\x01\x12\x0e\n\nREGISTERED\x10\x02\x12\x08\n\x04INIT\x10\x03\x12\t\n\x05READY\x10\x04\x12\x0f\n\x0bTRANSACTION\x10\x05\x12\r\n\tCOMPLETED\x10\x06\x12\t\n\x05\x45RROR\x10\x07\x12\r\n\tGET_STATE\x10\x08\x12\r\n\tPUT_STATE\x10\t\x12\r\n\tDEL_STATE\x10\n\x12\x14\n\x10INVOKE_CHAINCODE\x10\x0b\x12\x0c\n\x08RESPONSE\x10\r\x12\x15\n\x11GET_STATE_BY_RANGE\x10\x0e\x12\x17\n\x13\x45XECUTE_QUERY_STATE\x10\x0f\x12\x14\n\x10QUERY_STATE_NEXT\x10\x10\x12\x15\n\x11QUERY_STATE_CLOSE\x10\x11\x12\r\n\tKEEPALIVE\x10\x12\"*\n\x0cPutStateInfo\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\"3\n\x0fGetStateByRange\x12\x10\n\x08startKey\x18\x01 \x01(\t\x12\x0e\n\x06\x65ndKey\x18\x02 \x01(\t\"\"\n\x11\x45xecuteQueryState\x12\r\n\x05query\x18\x01 \x01(\t\"\x1c\n\x0eQueryStateNext\x12\n\n\x02ID\x18\x01 \x01(\t\"\x1d\n\x0fQueryStateClose\x12\n\n\x02ID\x18\x01 \x01(\t\"0\n\x12QueryStateKeyValue\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\"d\n\x12QueryStateResponse\x12\x31\n\rkeysAndValues\x18\x01 \x03(\x0b\x32\x1a.protos.QueryStateKeyValue\x12\x0f\n\x07hasMore\x18\x02 \x01(\x08\x12\n\n\x02ID\x18\x03 \x01(\t*4\n\x14\x43onfidentialityLevel\x12\n\n\x06PUBLIC\x10\x00\x12\x10\n\x0c\x43ONFIDENTIAL\x10\x01\x32X\n\x10\x43haincodeSupport\x12\x44\n\x08Register\x12\x18.protos.ChaincodeMessage\x1a\x18.protos.ChaincodeMessage\"\x00(\x01\x30\x01\x42\x43\n\x16org.hyperledger.protosZ)github.com/hyperledger/fabric/protos/peerb\x06proto3') + serialized_pb=_b('\n\x14peer/chaincode.proto\x12\x06protos\x1a\x19peer/chaincodeevent.proto\x1a\x1fgoogle/protobuf/timestamp.proto\":\n\x0b\x43haincodeID\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0f\n\x07version\x18\x03 \x01(\t\"\x1e\n\x0e\x43haincodeInput\x12\x0c\n\x04\x61rgs\x18\x01 \x03(\x0c\"\xdc\x01\n\rChaincodeSpec\x12(\n\x04type\x18\x01 \x01(\x0e\x32\x1a.protos.ChaincodeSpec.Type\x12)\n\x0c\x63haincode_id\x18\x02 \x01(\x0b\x32\x13.protos.ChaincodeID\x12%\n\x05input\x18\x03 \x01(\x0b\x32\x16.protos.ChaincodeInput\x12\x0f\n\x07timeout\x18\x04 \x01(\x05\">\n\x04Type\x12\r\n\tUNDEFINED\x10\x00\x12\n\n\x06GOLANG\x10\x01\x12\x08\n\x04NODE\x10\x02\x12\x07\n\x03\x43\x41R\x10\x03\x12\x08\n\x04JAVA\x10\x04\"\x8a\x02\n\x17\x43haincodeDeploymentSpec\x12-\n\x0e\x63haincode_spec\x18\x01 \x01(\x0b\x32\x15.protos.ChaincodeSpec\x12\x32\n\x0e\x65\x66\x66\x65\x63tive_date\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x14\n\x0c\x63ode_package\x18\x03 \x01(\x0c\x12\x46\n\x08\x65xec_env\x18\x04 \x01(\x0e\x32\x34.protos.ChaincodeDeploymentSpec.ExecutionEnvironment\".\n\x14\x45xecutionEnvironment\x12\n\n\x06\x44OCKER\x10\x00\x12\n\n\x06SYSTEM\x10\x01\"c\n\x17\x43haincodeInvocationSpec\x12-\n\x0e\x63haincode_spec\x18\x01 \x01(\x0b\x32\x15.protos.ChaincodeSpec\x12\x19\n\x11id_generation_alg\x18\x02 \x01(\t\">\n\x18\x43haincodeProposalContext\x12\x0f\n\x07\x63reator\x18\x01 \x01(\x0c\x12\x11\n\ttransient\x18\x02 \x01(\x0c\"\xc4\x04\n\x10\x43haincodeMessage\x12+\n\x04type\x18\x01 \x01(\x0e\x32\x1d.protos.ChaincodeMessage.Type\x12-\n\ttimestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0f\n\x07payload\x18\x03 \x01(\x0c\x12\x0c\n\x04txid\x18\x04 \x01(\t\x12:\n\x10proposal_context\x18\x05 \x01(\x0b\x32 .protos.ChaincodeProposalContext\x12/\n\x0f\x63haincode_event\x18\x06 \x01(\x0b\x32\x16.protos.ChaincodeEvent\"\xc7\x02\n\x04Type\x12\r\n\tUNDEFINED\x10\x00\x12\x0c\n\x08REGISTER\x10\x01\x12\x0e\n\nREGISTERED\x10\x02\x12\x08\n\x04INIT\x10\x03\x12\t\n\x05READY\x10\x04\x12\x0f\n\x0bTRANSACTION\x10\x05\x12\r\n\tCOMPLETED\x10\x06\x12\t\n\x05\x45RROR\x10\x07\x12\r\n\tGET_STATE\x10\x08\x12\r\n\tPUT_STATE\x10\t\x12\r\n\tDEL_STATE\x10\n\x12\x14\n\x10INVOKE_CHAINCODE\x10\x0b\x12\x0c\n\x08RESPONSE\x10\r\x12\x16\n\x12GET_STATE_BY_RANGE\x10\x0e\x12\x14\n\x10GET_QUERY_RESULT\x10\x0f\x12\x14\n\x10QUERY_STATE_NEXT\x10\x10\x12\x15\n\x11QUERY_STATE_CLOSE\x10\x11\x12\r\n\tKEEPALIVE\x10\x12\x12\x17\n\x13GET_HISTORY_FOR_KEY\x10\x13\"*\n\x0cPutStateInfo\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\"3\n\x0fGetStateByRange\x12\x10\n\x08startKey\x18\x01 \x01(\t\x12\x0e\n\x06\x65ndKey\x18\x02 \x01(\t\"\x1f\n\x0eGetQueryResult\x12\r\n\x05query\x18\x01 \x01(\t\"\x1f\n\x10GetHistoryForKey\x12\x0b\n\x03key\x18\x01 \x01(\t\"\x1c\n\x0eQueryStateNext\x12\n\n\x02id\x18\x01 \x01(\t\"\x1d\n\x0fQueryStateClose\x12\n\n\x02id\x18\x01 \x01(\t\"0\n\x12QueryStateKeyValue\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\"g\n\x12QueryStateResponse\x12\x33\n\x0fkeys_and_values\x18\x01 \x03(\x0b\x32\x1a.protos.QueryStateKeyValue\x12\x10\n\x08has_more\x18\x02 \x01(\x08\x12\n\n\x02id\x18\x03 \x01(\t*4\n\x14\x43onfidentialityLevel\x12\n\n\x06PUBLIC\x10\x00\x12\x10\n\x0c\x43ONFIDENTIAL\x10\x01\x32X\n\x10\x43haincodeSupport\x12\x44\n\x08Register\x12\x18.protos.ChaincodeMessage\x1a\x18.protos.ChaincodeMessage\"\x00(\x01\x30\x01\x42\x43\n\x16org.hyperledger.protosZ)github.com/hyperledger/fabric/protos/peerb\x06proto3') , dependencies=[peer_dot_chaincodeevent__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -44,8 +44,8 @@ ], containing_type=None, options=None, - serialized_start=1720, - serialized_end=1772, + serialized_start=1803, + serialized_end=1855, ) _sym_db.RegisterEnumDescriptor(_CONFIDENTIALITYLEVEL) @@ -83,8 +83,8 @@ ], containing_type=None, options=None, - serialized_start=325, - serialized_end=387, + serialized_start=343, + serialized_end=405, ) _sym_db.RegisterEnumDescriptor(_CHAINCODESPEC_TYPE) @@ -105,8 +105,8 @@ ], containing_type=None, options=None, - serialized_start=606, - serialized_end=652, + serialized_start=628, + serialized_end=674, ) _sym_db.RegisterEnumDescriptor(_CHAINCODEDEPLOYMENTSPEC_EXECUTIONENVIRONMENT) @@ -188,11 +188,15 @@ name='KEEPALIVE', index=17, number=18, options=None, type=None), + _descriptor.EnumValueDescriptor( + name='GET_HISTORY_FOR_KEY', index=18, number=19, + options=None, + type=None), ], containing_type=None, options=None, - serialized_start=1068, - serialized_end=1372, + serialized_start=1095, + serialized_end=1422, ) _sym_db.RegisterEnumDescriptor(_CHAINCODEMESSAGE_TYPE) @@ -218,6 +222,13 @@ message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), + _descriptor.FieldDescriptor( + name='version', full_name='protos.ChaincodeID.version', index=2, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), ], extensions=[ ], @@ -231,7 +242,7 @@ oneofs=[ ], serialized_start=92, - serialized_end=133, + serialized_end=150, ) @@ -261,8 +272,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=135, - serialized_end=165, + serialized_start=152, + serialized_end=182, ) @@ -281,7 +292,7 @@ is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='chaincodeID', full_name='protos.ChaincodeSpec.chaincodeID', index=1, + name='chaincode_id', full_name='protos.ChaincodeSpec.chaincode_id', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -314,8 +325,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=168, - serialized_end=387, + serialized_start=185, + serialized_end=405, ) @@ -327,28 +338,28 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='chaincodeSpec', full_name='protos.ChaincodeDeploymentSpec.chaincodeSpec', index=0, + name='chaincode_spec', full_name='protos.ChaincodeDeploymentSpec.chaincode_spec', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='effectiveDate', full_name='protos.ChaincodeDeploymentSpec.effectiveDate', index=1, + name='effective_date', full_name='protos.ChaincodeDeploymentSpec.effective_date', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='codePackage', full_name='protos.ChaincodeDeploymentSpec.codePackage', index=2, + name='code_package', full_name='protos.ChaincodeDeploymentSpec.code_package', index=2, number=3, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='execEnv', full_name='protos.ChaincodeDeploymentSpec.execEnv', index=3, + name='exec_env', full_name='protos.ChaincodeDeploymentSpec.exec_env', index=3, number=4, type=14, cpp_type=8, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, @@ -367,8 +378,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=390, - serialized_end=652, + serialized_start=408, + serialized_end=674, ) @@ -380,14 +391,14 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='chaincodeSpec', full_name='protos.ChaincodeInvocationSpec.chaincodeSpec', index=0, + name='chaincode_spec', full_name='protos.ChaincodeInvocationSpec.chaincode_spec', index=0, number=1, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='idGenerationAlg', full_name='protos.ChaincodeInvocationSpec.idGenerationAlg', index=1, + name='id_generation_alg', full_name='protos.ChaincodeInvocationSpec.id_generation_alg', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -405,8 +416,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=654, - serialized_end=750, + serialized_start=676, + serialized_end=775, ) @@ -443,8 +454,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=752, - serialized_end=814, + serialized_start=777, + serialized_end=839, ) @@ -484,14 +495,14 @@ is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='proposalContext', full_name='protos.ChaincodeMessage.proposalContext', index=4, + name='proposal_context', full_name='protos.ChaincodeMessage.proposal_context', index=4, number=5, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='chaincodeEvent', full_name='protos.ChaincodeMessage.chaincodeEvent', index=5, + name='chaincode_event', full_name='protos.ChaincodeMessage.chaincode_event', index=5, number=6, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -510,8 +521,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=817, - serialized_end=1372, + serialized_start=842, + serialized_end=1422, ) @@ -548,8 +559,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1374, - serialized_end=1416, + serialized_start=1424, + serialized_end=1466, ) @@ -586,8 +597,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1418, - serialized_end=1469, + serialized_start=1468, + serialized_end=1519, ) @@ -617,8 +628,39 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1471, - serialized_end=1505, + serialized_start=1521, + serialized_end=1552, +) + + +_GETHISTORYFORKEY = _descriptor.Descriptor( + name='GetHistoryForKey', + full_name='protos.GetHistoryForKey', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='protos.GetHistoryForKey.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1554, + serialized_end=1585, ) @@ -630,7 +672,7 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='ID', full_name='protos.QueryStateNext.ID', index=0, + name='id', full_name='protos.QueryStateNext.id', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -648,8 +690,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1507, - serialized_end=1535, + serialized_start=1587, + serialized_end=1615, ) @@ -661,7 +703,7 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='ID', full_name='protos.QueryStateClose.ID', index=0, + name='id', full_name='protos.QueryStateClose.id', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -679,8 +721,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1537, - serialized_end=1566, + serialized_start=1617, + serialized_end=1646, ) @@ -717,8 +759,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1568, - serialized_end=1616, + serialized_start=1648, + serialized_end=1696, ) @@ -730,21 +772,21 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='keysAndValues', full_name='protos.QueryStateResponse.keysAndValues', index=0, + name='keys_and_values', full_name='protos.QueryStateResponse.keys_and_values', index=0, number=1, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='hasMore', full_name='protos.QueryStateResponse.hasMore', index=1, + name='has_more', full_name='protos.QueryStateResponse.has_more', index=1, number=2, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='ID', full_name='protos.QueryStateResponse.ID', index=2, + name='id', full_name='protos.QueryStateResponse.id', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, @@ -762,25 +804,25 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1618, - serialized_end=1718, + serialized_start=1698, + serialized_end=1801, ) _CHAINCODESPEC.fields_by_name['type'].enum_type = _CHAINCODESPEC_TYPE -_CHAINCODESPEC.fields_by_name['chaincodeID'].message_type = _CHAINCODEID +_CHAINCODESPEC.fields_by_name['chaincode_id'].message_type = _CHAINCODEID _CHAINCODESPEC.fields_by_name['input'].message_type = _CHAINCODEINPUT _CHAINCODESPEC_TYPE.containing_type = _CHAINCODESPEC -_CHAINCODEDEPLOYMENTSPEC.fields_by_name['chaincodeSpec'].message_type = _CHAINCODESPEC -_CHAINCODEDEPLOYMENTSPEC.fields_by_name['effectiveDate'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP -_CHAINCODEDEPLOYMENTSPEC.fields_by_name['execEnv'].enum_type = _CHAINCODEDEPLOYMENTSPEC_EXECUTIONENVIRONMENT +_CHAINCODEDEPLOYMENTSPEC.fields_by_name['chaincode_spec'].message_type = _CHAINCODESPEC +_CHAINCODEDEPLOYMENTSPEC.fields_by_name['effective_date'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_CHAINCODEDEPLOYMENTSPEC.fields_by_name['exec_env'].enum_type = _CHAINCODEDEPLOYMENTSPEC_EXECUTIONENVIRONMENT _CHAINCODEDEPLOYMENTSPEC_EXECUTIONENVIRONMENT.containing_type = _CHAINCODEDEPLOYMENTSPEC -_CHAINCODEINVOCATIONSPEC.fields_by_name['chaincodeSpec'].message_type = _CHAINCODESPEC +_CHAINCODEINVOCATIONSPEC.fields_by_name['chaincode_spec'].message_type = _CHAINCODESPEC _CHAINCODEMESSAGE.fields_by_name['type'].enum_type = _CHAINCODEMESSAGE_TYPE _CHAINCODEMESSAGE.fields_by_name['timestamp'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP -_CHAINCODEMESSAGE.fields_by_name['proposalContext'].message_type = _CHAINCODEPROPOSALCONTEXT -_CHAINCODEMESSAGE.fields_by_name['chaincodeEvent'].message_type = peer_dot_chaincodeevent__pb2._CHAINCODEEVENT +_CHAINCODEMESSAGE.fields_by_name['proposal_context'].message_type = _CHAINCODEPROPOSALCONTEXT +_CHAINCODEMESSAGE.fields_by_name['chaincode_event'].message_type = peer_dot_chaincodeevent__pb2._CHAINCODEEVENT _CHAINCODEMESSAGE_TYPE.containing_type = _CHAINCODEMESSAGE -_QUERYSTATERESPONSE.fields_by_name['keysAndValues'].message_type = _QUERYSTATEKEYVALUE +_QUERYSTATERESPONSE.fields_by_name['keys_and_values'].message_type = _QUERYSTATEKEYVALUE DESCRIPTOR.message_types_by_name['ChaincodeID'] = _CHAINCODEID DESCRIPTOR.message_types_by_name['ChaincodeInput'] = _CHAINCODEINPUT DESCRIPTOR.message_types_by_name['ChaincodeSpec'] = _CHAINCODESPEC @@ -791,6 +833,7 @@ DESCRIPTOR.message_types_by_name['PutStateInfo'] = _PUTSTATEINFO DESCRIPTOR.message_types_by_name['GetStateByRange'] = _GETSTATEBYRANGE DESCRIPTOR.message_types_by_name['GetQueryResult'] = _GETQUERYRESULT +DESCRIPTOR.message_types_by_name['GetHistoryForKey'] = _GETHISTORYFORKEY DESCRIPTOR.message_types_by_name['QueryStateNext'] = _QUERYSTATENEXT DESCRIPTOR.message_types_by_name['QueryStateClose'] = _QUERYSTATECLOSE DESCRIPTOR.message_types_by_name['QueryStateKeyValue'] = _QUERYSTATEKEYVALUE @@ -867,6 +910,13 @@ )) _sym_db.RegisterMessage(GetQueryResult) +GetHistoryForKey = _reflection.GeneratedProtocolMessageType('GetHistoryForKey', (_message.Message,), dict( + DESCRIPTOR = _GETHISTORYFORKEY, + __module__ = 'peer.chaincode_pb2' + # @@protoc_insertion_point(class_scope:protos.GetHistoryForKey) + )) +_sym_db.RegisterMessage(GetHistoryForKey) + QueryStateNext = _reflection.GeneratedProtocolMessageType('QueryStateNext', (_message.Message,), dict( DESCRIPTOR = _QUERYSTATENEXT, __module__ = 'peer.chaincode_pb2' diff --git a/bddtests/peer/configuration_pb2.py b/bddtests/peer/configuration_pb2.py index eaa0525d43b..735689534ff 100644 --- a/bddtests/peer/configuration_pb2.py +++ b/bddtests/peer/configuration_pb2.py @@ -19,7 +19,7 @@ name='peer/configuration.proto', package='protos', syntax='proto3', - serialized_pb=_b('\n\x18peer/configuration.proto\x12\x06protos\"6\n\x0b\x41nchorPeers\x12\'\n\x0b\x61nchorPeers\x18\x01 \x03(\x0b\x32\x12.protos.AnchorPeer\"6\n\nAnchorPeer\x12\x0c\n\x04Host\x18\x01 \x01(\t\x12\x0c\n\x04Port\x18\x02 \x01(\x05\x12\x0c\n\x04\x43\x65rt\x18\x03 \x01(\x0c\x42+Z)github.com/hyperledger/fabric/protos/peerb\x06proto3') + serialized_pb=_b('\n\x18peer/configuration.proto\x12\x06protos\"7\n\x0b\x41nchorPeers\x12(\n\x0c\x61nchor_peers\x18\x01 \x03(\x0b\x32\x12.protos.AnchorPeer\"6\n\nAnchorPeer\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0c\n\x04port\x18\x02 \x01(\x05\x12\x0c\n\x04\x63\x65rt\x18\x03 \x01(\x0c\x42+Z)github.com/hyperledger/fabric/protos/peerb\x06proto3') ) _sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -34,7 +34,7 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='anchorPeers', full_name='protos.AnchorPeers.anchorPeers', index=0, + name='anchor_peers', full_name='protos.AnchorPeers.anchor_peers', index=0, number=1, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, @@ -53,7 +53,7 @@ oneofs=[ ], serialized_start=36, - serialized_end=90, + serialized_end=91, ) @@ -65,21 +65,21 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Host', full_name='protos.AnchorPeer.Host', index=0, + name='host', full_name='protos.AnchorPeer.host', index=0, number=1, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='Port', full_name='protos.AnchorPeer.Port', index=1, + name='port', full_name='protos.AnchorPeer.port', index=1, number=2, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='Cert', full_name='protos.AnchorPeer.Cert', index=2, + name='cert', full_name='protos.AnchorPeer.cert', index=2, number=3, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, @@ -97,11 +97,11 @@ extension_ranges=[], oneofs=[ ], - serialized_start=92, - serialized_end=146, + serialized_start=93, + serialized_end=147, ) -_ANCHORPEERS.fields_by_name['anchorPeers'].message_type = _ANCHORPEER +_ANCHORPEERS.fields_by_name['anchor_peers'].message_type = _ANCHORPEER DESCRIPTOR.message_types_by_name['AnchorPeers'] = _ANCHORPEERS DESCRIPTOR.message_types_by_name['AnchorPeer'] = _ANCHORPEER diff --git a/bddtests/peer/proposal_pb2.py b/bddtests/peer/proposal_pb2.py index 3a3aaba4e8f..4fc817c78e6 100644 --- a/bddtests/peer/proposal_pb2.py +++ b/bddtests/peer/proposal_pb2.py @@ -21,7 +21,7 @@ name='peer/proposal.proto', package='protos', syntax='proto3', - serialized_pb=_b('\n\x13peer/proposal.proto\x12\x06protos\x1a\x14peer/chaincode.proto\x1a\x1cpeer/proposal_response.proto\":\n\x0eSignedProposal\x12\x15\n\rproposalBytes\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\">\n\x08Proposal\x12\x0e\n\x06header\x18\x01 \x01(\x0c\x12\x0f\n\x07payload\x18\x02 \x01(\x0c\x12\x11\n\textension\x18\x03 \x01(\x0c\"_\n\x18\x43haincodeHeaderExtension\x12\x19\n\x11payloadVisibility\x18\x01 \x01(\x0c\x12(\n\x0b\x63haincodeID\x18\x02 \x01(\x0b\x32\x13.protos.ChaincodeID\"<\n\x18\x43haincodeProposalPayload\x12\r\n\x05Input\x18\x01 \x01(\x0c\x12\x11\n\tTransient\x18\x02 \x01(\x0c\"V\n\x0f\x43haincodeAction\x12\x0f\n\x07results\x18\x01 \x01(\x0c\x12\x0e\n\x06\x65vents\x18\x02 \x01(\x0c\x12\"\n\x08response\x18\x03 \x01(\x0b\x32\x10.protos.ResponseB+Z)github.com/hyperledger/fabric/protos/peerb\x06proto3') + serialized_pb=_b('\n\x13peer/proposal.proto\x12\x06protos\x1a\x14peer/chaincode.proto\x1a\x1cpeer/proposal_response.proto\";\n\x0eSignedProposal\x12\x16\n\x0eproposal_bytes\x18\x01 \x01(\x0c\x12\x11\n\tsignature\x18\x02 \x01(\x0c\">\n\x08Proposal\x12\x0e\n\x06header\x18\x01 \x01(\x0c\x12\x0f\n\x07payload\x18\x02 \x01(\x0c\x12\x11\n\textension\x18\x03 \x01(\x0c\"a\n\x18\x43haincodeHeaderExtension\x12\x1a\n\x12payload_visibility\x18\x01 \x01(\x0c\x12)\n\x0c\x63haincode_id\x18\x02 \x01(\x0b\x32\x13.protos.ChaincodeID\"\xa8\x01\n\x18\x43haincodeProposalPayload\x12\r\n\x05input\x18\x01 \x01(\x0c\x12H\n\x0cTransientMap\x18\x02 \x03(\x0b\x32\x32.protos.ChaincodeProposalPayload.TransientMapEntry\x1a\x33\n\x11TransientMapEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c:\x02\x38\x01\"V\n\x0f\x43haincodeAction\x12\x0f\n\x07results\x18\x01 \x01(\x0c\x12\x0e\n\x06\x65vents\x18\x02 \x01(\x0c\x12\"\n\x08response\x18\x03 \x01(\x0b\x32\x10.protos.ResponseB+Z)github.com/hyperledger/fabric/protos/peerb\x06proto3') , dependencies=[peer_dot_chaincode__pb2.DESCRIPTOR,peer_dot_proposal__response__pb2.DESCRIPTOR,]) _sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -37,7 +37,7 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='proposalBytes', full_name='protos.SignedProposal.proposalBytes', index=0, + name='proposal_bytes', full_name='protos.SignedProposal.proposal_bytes', index=0, number=1, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, @@ -63,7 +63,7 @@ oneofs=[ ], serialized_start=83, - serialized_end=141, + serialized_end=142, ) @@ -107,8 +107,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=143, - serialized_end=205, + serialized_start=144, + serialized_end=206, ) @@ -120,14 +120,14 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='payloadVisibility', full_name='protos.ChaincodeHeaderExtension.payloadVisibility', index=0, + name='payload_visibility', full_name='protos.ChaincodeHeaderExtension.payload_visibility', index=0, number=1, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='chaincodeID', full_name='protos.ChaincodeHeaderExtension.chaincodeID', index=1, + name='chaincode_id', full_name='protos.ChaincodeHeaderExtension.chaincode_id', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, @@ -145,11 +145,48 @@ extension_ranges=[], oneofs=[ ], - serialized_start=207, - serialized_end=302, + serialized_start=208, + serialized_end=305, ) +_CHAINCODEPROPOSALPAYLOAD_TRANSIENTMAPENTRY = _descriptor.Descriptor( + name='TransientMapEntry', + full_name='protos.ChaincodeProposalPayload.TransientMapEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='protos.ChaincodeProposalPayload.TransientMapEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value', full_name='protos.ChaincodeProposalPayload.TransientMapEntry.value', index=1, + number=2, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=_b(""), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=_descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')), + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=425, + serialized_end=476, +) + _CHAINCODEPROPOSALPAYLOAD = _descriptor.Descriptor( name='ChaincodeProposalPayload', full_name='protos.ChaincodeProposalPayload', @@ -158,23 +195,23 @@ containing_type=None, fields=[ _descriptor.FieldDescriptor( - name='Input', full_name='protos.ChaincodeProposalPayload.Input', index=0, + name='input', full_name='protos.ChaincodeProposalPayload.input', index=0, number=1, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), _descriptor.FieldDescriptor( - name='Transient', full_name='protos.ChaincodeProposalPayload.Transient', index=1, - number=2, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=_b(""), + name='TransientMap', full_name='protos.ChaincodeProposalPayload.TransientMap', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None), ], extensions=[ ], - nested_types=[], + nested_types=[_CHAINCODEPROPOSALPAYLOAD_TRANSIENTMAPENTRY, ], enum_types=[ ], options=None, @@ -183,8 +220,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=304, - serialized_end=364, + serialized_start=308, + serialized_end=476, ) @@ -228,11 +265,13 @@ extension_ranges=[], oneofs=[ ], - serialized_start=366, - serialized_end=452, + serialized_start=478, + serialized_end=564, ) -_CHAINCODEHEADEREXTENSION.fields_by_name['chaincodeID'].message_type = peer_dot_chaincode__pb2._CHAINCODEID +_CHAINCODEHEADEREXTENSION.fields_by_name['chaincode_id'].message_type = peer_dot_chaincode__pb2._CHAINCODEID +_CHAINCODEPROPOSALPAYLOAD_TRANSIENTMAPENTRY.containing_type = _CHAINCODEPROPOSALPAYLOAD +_CHAINCODEPROPOSALPAYLOAD.fields_by_name['TransientMap'].message_type = _CHAINCODEPROPOSALPAYLOAD_TRANSIENTMAPENTRY _CHAINCODEACTION.fields_by_name['response'].message_type = peer_dot_proposal__response__pb2._RESPONSE DESCRIPTOR.message_types_by_name['SignedProposal'] = _SIGNEDPROPOSAL DESCRIPTOR.message_types_by_name['Proposal'] = _PROPOSAL @@ -262,11 +301,19 @@ _sym_db.RegisterMessage(ChaincodeHeaderExtension) ChaincodeProposalPayload = _reflection.GeneratedProtocolMessageType('ChaincodeProposalPayload', (_message.Message,), dict( + + TransientMapEntry = _reflection.GeneratedProtocolMessageType('TransientMapEntry', (_message.Message,), dict( + DESCRIPTOR = _CHAINCODEPROPOSALPAYLOAD_TRANSIENTMAPENTRY, + __module__ = 'peer.proposal_pb2' + # @@protoc_insertion_point(class_scope:protos.ChaincodeProposalPayload.TransientMapEntry) + )) + , DESCRIPTOR = _CHAINCODEPROPOSALPAYLOAD, __module__ = 'peer.proposal_pb2' # @@protoc_insertion_point(class_scope:protos.ChaincodeProposalPayload) )) _sym_db.RegisterMessage(ChaincodeProposalPayload) +_sym_db.RegisterMessage(ChaincodeProposalPayload.TransientMapEntry) ChaincodeAction = _reflection.GeneratedProtocolMessageType('ChaincodeAction', (_message.Message,), dict( DESCRIPTOR = _CHAINCODEACTION, @@ -278,6 +325,8 @@ DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('Z)github.com/hyperledger/fabric/protos/peer')) +_CHAINCODEPROPOSALPAYLOAD_TRANSIENTMAPENTRY.has_options = True +_CHAINCODEPROPOSALPAYLOAD_TRANSIENTMAPENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) try: # THESE ELEMENTS WILL BE DEPRECATED. # Please use the generated *_pb2_grpc.py files instead. diff --git a/bddtests/steps/bootstrap_impl.py b/bddtests/steps/bootstrap_impl.py index d1b0e767857..48b1656aa97 100644 --- a/bddtests/steps/bootstrap_impl.py +++ b/bddtests/steps/bootstrap_impl.py @@ -13,6 +13,7 @@ # limitations under the License. # +from behave import * import bdd_grpc_util import endorser_util import bdd_test_util @@ -25,7 +26,13 @@ class ChannelCreationInfo: def __init__(self, channelId, channelCreationPolicyName, signedConfigEnvelope): self.channelId = channelId self.channelCreationPolicyName = channelCreationPolicyName - self.signedConfigEnvelope = signedConfigEnvelope + self.config_update_envelope = signedConfigEnvelope + + def __repr__(self): + return "channelId = {0}\nchannelCreationPolicyName={1}\nconfigUpdateEnvelope={2}\n".format(self.channelId, + self.channelCreationPolicyName, + str( + self.config_update_envelope)) @@ -67,20 +74,20 @@ def step_impl(context): # Simply create the user bootstrap_util.getOrdererBootstrapAdmin(context, shouldCreate=True) -@given(u'the ordererBootstrapAdmin creates the genesis block for chain "{ordererSystemChainIdName}" for network config policy "{networkConfigPolicy}" and consensus "{consensusType}" using chain creators policies') -def step_impl(context, ordererSystemChainIdName, networkConfigPolicy, consensusType): +@given(u'the ordererBootstrapAdmin creates the genesis block "{ordererGenesisBlockName}" for chain "{ordererSystemChainIdName}" for network config policy "{networkConfigPolicy}" and consensus "{consensusType}" using chain creators policies') +def step_impl(context, ordererGenesisBlockName, ordererSystemChainIdName, networkConfigPolicy, consensusType): ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context) ordererSystemChainIdGUUID = ordererBootstrapAdmin.tags[ordererSystemChainIdName] # Now collect the named signed config items - signedConfigItems =[] + configGroups =[] for row in context.table.rows: - signedConfigItemName = row['SignedConfigItemsName'] - signedConfigItems += ordererBootstrapAdmin.tags[signedConfigItemName] - + configGroupName = row['ConfigGroup Names'] + configGroups += ordererBootstrapAdmin.tags[configGroupName] # Concatenate signedConfigItems # Construct block - (genesisBlock,envelope) = bootstrap_util.createGenesisBlock(context, ordererSystemChainIdGUUID, consensusType, signedConfigItems=signedConfigItems) + (genesisBlock,envelope) = bootstrap_util.createGenesisBlock(context, ordererSystemChainIdGUUID, consensusType, signedConfigItems=configGroups) + ordererBootstrapAdmin.setTagValue(ordererGenesisBlockName, genesisBlock) bootstrap_util.OrdererGensisBlockCompositionCallback(context, genesisBlock) bootstrap_util.PeerCompositionCallback(context) @@ -97,7 +104,7 @@ def step_impl(context, chainId): def step_impl(context, ordererSystemChainId): directory = bootstrap_util.getDirectory(context) ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context) - ordererBootstrapAdmin.tags[ordererSystemChainId] = bootstrap_util.GetUUID() + ordererBootstrapAdmin.setTagValue(ordererSystemChainId, bootstrap_util.GetUUID()) @given(u'the ordererBootstrapAdmin creates a chain creators policy "{chainCreatePolicyName}" (network name) for peer orgs who wish to form a network using orderer system chain "{ordererSystemChainId}"') @@ -115,7 +122,7 @@ def step_impl(context, chainCreatePolicyName, ordererSystemChainId): chainCreatorsOrgsPolicySignedConfigItem = \ bootstrap_util.createChainCreatorsPolicy(context=context, chainCreatePolicyName=chainCreatePolicyName, chaindId=ordererSystemChainIdGuuid, orgNames=orgNames) - ordererBootstrapAdmin.tags[chainCreatePolicyName] = [chainCreatorsOrgsPolicySignedConfigItem] + ordererBootstrapAdmin.setTagValue(chainCreatePolicyName, [chainCreatorsOrgsPolicySignedConfigItem]) @given(u'the ordererBootstrapAdmin runs the channel template tool to create the orderer configuration template "{templateName}" for application developers using orderer "{ordererComposeService}"') @@ -133,10 +140,10 @@ def step_impl(context, userName, templateName, chainCreatePolicyName): ' At the moment, only really defining MSP Config Items (NOT SIGNED)' directory = bootstrap_util.getDirectory(context) user = directory.getUser(userName) - user.tags[templateName] = [directory.getOrganization(row['Organization']) for row in context.table.rows] + user.setTagValue(templateName, [directory.getOrganization(row['Organization']) for row in context.table.rows]) -@given(u'the user "{userName}" creates a signedConfigEnvelope "{createChannelSignedConfigEnvelope}"') +@given(u'the user "{userName}" creates a ConfigUpdateEnvelope "{createChannelSignedConfigEnvelope}"') def step_impl(context, userName, createChannelSignedConfigEnvelope): directory = bootstrap_util.getDirectory(context) user = directory.getUser(userName) @@ -148,19 +155,21 @@ def step_impl(context, userName, createChannelSignedConfigEnvelope): templateName = context.table.rows[0]["Template"] # Loop through templates referenced orgs mspOrgNames = [org.name for org in user.tags[templateName]] - signedMspConfigItems = bootstrap_util.getSignedMSPConfigItems(context=context, chainId=channelID, orgNames=mspOrgNames) + signedMspConfigItems = bootstrap_util.getSignedMSPConfigItems(context=context, orgNames=mspOrgNames) # Add the anchors signed config Items anchorSignedConfigItemsName = context.table.rows[0]["Anchors"] signedAnchorsConfigItems = user.tags[anchorSignedConfigItemsName] # Intermediate step until template tool is ready - signedConfigItems = bootstrap_util.createSignedConfigItems(context, channelID, "solo", signedConfigItems=signedMspConfigItems + signedAnchorsConfigItems) + signedConfigItems = bootstrap_util.createSignedConfigItems(configGroups=signedMspConfigItems + signedAnchorsConfigItems) + + #NOTE: Conidered passing signing key for appDeveloper, but decided that the peer org signatures they need to collect subsequently should be proper way - signedConfigEnvelope = bootstrap_util.signInitialChainConfig(signedConfigItems=signedConfigItems, chainId=channelID, chainCreationPolicyName=chainCreationPolicyName) + config_update_envelope = bootstrap_util.createConfigUpdateEnvelope(channelConfigGroup=signedConfigItems, chainId=channelID, chainCreationPolicyName=chainCreationPolicyName) - user.tags[createChannelSignedConfigEnvelope] = ChannelCreationInfo(channelID, chainCreationPolicyName, signedConfigEnvelope) + user.setTagValue(createChannelSignedConfigEnvelope, ChannelCreationInfo(channelID, chainCreationPolicyName, config_update_envelope)) # Construct TX Config Envelope, broadcast, expect success, and then connect to deliver to revtrieve block. # Make sure the blockdata exactly the TxConfigEnvelope I submitted. @@ -175,30 +184,33 @@ def step_impl(context): userName = row['Developer'] nodeAdminNamedTuple = directory.registerOrdererAdminTuple(userName, row['ChainCreationPolicyName'], row['Organization']) user = directory.getUser(userName) - user.tags[row['AliasSavedUnder']] = nodeAdminNamedTuple + user.setTagValue(row['AliasSavedUnder'], nodeAdminNamedTuple) -@given(u'the user "{userName}" collects signatures for signedConfigEnvelope "{createChannelSignedConfigEnvelopeName}" from peer orgs') +@given(u'the user "{userName}" collects signatures for ConfigUpdateEnvelope "{createChannelSignedConfigEnvelopeName}" from peer orgs') def step_impl(context, userName, createChannelSignedConfigEnvelopeName): assert 'table' in context, "Expected table of peer organizations" directory = bootstrap_util.getDirectory(context) user = directory.getUser(userName=userName) # Get the ChannelCreationInfo object that holds the signedConfigEnvelope channelCreationInfo = user.tags[createChannelSignedConfigEnvelopeName] - signedConfigEnvelope = channelCreationInfo.signedConfigEnvelope + config_update_envelope = channelCreationInfo.config_update_envelope for row in context.table.rows: org = directory.getOrganization(row['Organization']) assert bootstrap_util.Network.Peer in org.networks, "Organization '{0}' not in Peer network".format(org.name) - bootstrap_util.BootstrapHelper.addSignatureToSignedConfigItem(signedConfigEnvelope.Items[0], (org, org.getSelfSignedCert())) + bootstrap_util.BootstrapHelper.addSignatureToSignedConfigItem(config_update_envelope, (org, org.getSelfSignedCert())) # print("Signatures for signedConfigEnvelope:\n {0}\n".format(signedConfigEnvelope.Items[0])) -@given(u'the user "{userName}" creates config Tx "{configTxName}" using signedConfigEnvelope "{createChannelSignedConfigEnvelopeName}"') -def step_impl(context, userName, configTxName, createChannelSignedConfigEnvelopeName): +@given(u'the user "{userName}" creates a ConfigUpdate Tx "{configUpdateTxName}" using signed ConfigUpdateEnvelope "{createChannelSignedConfigEnvelopeName}"') +def step_impl(context, userName, configUpdateTxName, createChannelSignedConfigEnvelopeName): directory = bootstrap_util.getDirectory(context) user = directory.getUser(userName=userName) channelCreationInfo = user.tags[createChannelSignedConfigEnvelopeName] - user.tags[configTxName] = bootstrap_util.createConfigTxEnvelope(channelCreationInfo.channelId, channelCreationInfo.signedConfigEnvelope) + #TODO: this is temporary until partial update is supported. Normally you would just return + # this message and send directly to broadcast. + envelope_for_config_update = bootstrap_util.createConfigUpdateTxEnvelope(channelCreationInfo.channelId, channelCreationInfo.config_update_envelope) + user.setTagValue(configUpdateTxName, envelope_for_config_update) -@given(u'the user "{userName}" broadcasts config Tx "{configTxName}" to orderer "{orderer}" to create channel "{channelId}"') +@given(u'the user "{userName}" broadcasts ConfigUpdate Tx "{configTxName}" to orderer "{orderer}" to create channel "{channelId}"') def step_impl(context, userName, configTxName, orderer, channelId): directory = bootstrap_util.getDirectory(context) user = directory.getUser(userName=userName) @@ -232,7 +244,7 @@ def step_impl(context, userName, deliveryName, composeService, expectedBlocks, n # Verify block count assert len(blocks) == int(expectedBlocks), "Expected {0} blocks, received {1}".format(expectedBlocks, len(blocks)) - user.tags[deliveryName] = blocks + user.setTagValue(deliveryName, blocks) @when(u'user "{userName}" using cert alias "{certAlias}" requests to join channel using genesis block "{genisisBlockName}" on peers with result "{joinChannelResult}"') def step_impl(context, userName, certAlias, genisisBlockName, joinChannelResult): @@ -245,33 +257,33 @@ def step_impl(context, userName, certAlias, genisisBlockName, joinChannelResult) # Retrieve the genesis block from the returned value of deliver (Will be list with first block as genesis block) genesisBlock = user.tags[genisisBlockName][0] ccSpec = endorser_util.getChaincodeSpec("GOLANG", "", "cscc", ["JoinChain", genesisBlock.SerializeToString()]) - proposal = endorser_util.createInvokeProposalForBDD(ccSpec=ccSpec, chainID="",signersCert=signersCert, Mspid="DEFAULT", type="CONFIGURATION_TRANSACTION") + proposal = endorser_util.createInvokeProposalForBDD(context, ccSpec=ccSpec, chainID="",signersCert=signersCert, Mspid="DEFAULT", type="CONFIG") signedProposal = endorser_util.signProposal(proposal=proposal, entity=user, signersCert=signersCert) # Send proposal to each specified endorser, waiting 'timeout' seconds for response/error endorsers = [row['Peer'] for row in context.table.rows] proposalResponseFutures = [endorserStub.ProcessProposal.future(signedProposal, int(timeout)) for endorserStub in endorser_util.getEndorserStubs(context, endorsers)] resultsDict = dict(zip(endorsers, [respFuture.result() for respFuture in proposalResponseFutures])) - user.tags[joinChannelResult] = resultsDict + user.setTagValue(joinChannelResult, resultsDict) -@given(u'the ordererBoostrapAdmin creates MSP Configuration Items "{mspConfigItemsName}" for orderer system chain "{ordererSystemChainIdName}" for every MSP referenced by the policies') +@given(u'the ordererBoostrapAdmin creates MSP configuration "{mspConfigItemsName}" for orderer system chain "{ordererSystemChainIdName}" for every MSP referenced by the policies') def step_impl(context, ordererSystemChainIdName, mspConfigItemsName): assert 'table' in context, "Expected table of policy names" directory = bootstrap_util.getDirectory(context) ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context) ordererSystemChainIdGUUID = ordererBootstrapAdmin.tags[ordererSystemChainIdName] - mspSignedConfigItems = bootstrap_util.getMspConfigItemsForPolicyNames(context, chainId=ordererSystemChainIdGUUID, policyNames=[row['PolicyName'] for row in context.table.rows]) - ordererBootstrapAdmin.tags[mspConfigItemsName] = mspSignedConfigItems + mspSignedConfigItems = bootstrap_util.getMspConfigItemsForPolicyNames(context, policyNames=[row['PolicyName'] for row in context.table.rows]) + ordererBootstrapAdmin.setTagValue(mspConfigItemsName, mspSignedConfigItems) -@given(u'the ordererBoostrapAdmin creates the chain creation policy names "{chainCreationPolicyNames}" signedConfigurationItem for orderer system chain "{ordererSystemChainIdName}" with policies') +@given(u'the ordererBoostrapAdmin creates the chain creation policy names "{chainCreationPolicyNames}" for orderer system chain "{ordererSystemChainIdName}" with policies') def step_impl(context, chainCreationPolicyNames, ordererSystemChainIdName): ordererBootstrapAdmin = bootstrap_util.getOrdererBootstrapAdmin(context) ordererSystemChainIdGUUID = ordererBootstrapAdmin.tags[ordererSystemChainIdName] policyNames = [row['PolicyName'] for row in context.table.rows] chainCreationPolicyNamesConfigItem = bootstrap_util.createChainCreationPolicyNames(context, chainCreationPolicyNames=policyNames, chaindId=ordererSystemChainIdGUUID) - ordererBootstrapAdmin.tags[chainCreationPolicyNames] = [chainCreationPolicyNamesConfigItem] + ordererBootstrapAdmin.setTagValue(chainCreationPolicyNames, [chainCreationPolicyNamesConfigItem]) @then(u'user "{userName}" expects result code for "{proposalResponseName}" of "{proposalResponseResultCode}" from peers') def step_impl(context, userName, proposalResponseName, proposalResponseResultCode): @@ -287,4 +299,4 @@ def step_impl(context, userName, anchorSetName, channelName): directory = bootstrap_util.getDirectory(context) user = directory.getUser(userName=userName) nodeAdminTuples = [directory.findNodeAdminTuple(row['User'], row['Peer'], row['Organization']) for row in context.table.rows] - user.tags[anchorSetName] = bootstrap_util.getSignedAnchorConfigItems(context=context, chainId=channelName, nodeAdminTuples=nodeAdminTuples) + user.setTagValue(anchorSetName, bootstrap_util.getAnchorPeersConfigGroup(context=context, nodeAdminTuples=nodeAdminTuples)) diff --git a/bddtests/steps/bootstrap_util.py b/bddtests/steps/bootstrap_util.py index 3cfdea6323a..e01efa9954f 100644 --- a/bddtests/steps/bootstrap_util.py +++ b/bddtests/steps/bootstrap_util.py @@ -16,114 +16,65 @@ import time import sys import hashlib + if sys.version_info < (3, 6): import sha3 from OpenSSL import crypto from OpenSSL import rand import ecdsa -import shutil - -from slugify import slugify from collections import namedtuple +from itertools import groupby from enum import Enum from google.protobuf import timestamp_pb2 from common import common_pb2 as common_dot_common_pb2 +from common import configtx_pb2 as common_dot_configtx_pb2 from common import configuration_pb2 as common_dot_configuration_pb2 +from common import policies_pb2 as common_dot_policies_pb2 from common import msp_principal_pb2 from msp import mspconfig_pb2 from peer import configuration_pb2 as peer_dot_configuration_pb2 - -# import orderer from orderer import configuration_pb2 as orderer_dot_configuration_pb2 import orderer_util +from contexthelper import ContextHelper + import os import re import shutil import compose -import uuid # Type to represent tuple of user, nodeName, ogranization NodeAdminTuple = namedtuple("NodeAdminTuple", ['user', 'nodeName', 'organization']) -class ContextHelper: - def __init__(self, context): - self.context = context - self.guuid = GetUUID() - - def getGuuid(self): - return self.guuid - - def getTmpPath(self): - pathToReturn = "tmp" - if not os.path.isdir(pathToReturn): - os.makedirs(pathToReturn) - return pathToReturn - - def getCachePath(self): - pathToReturn = os.path.join(self.getTmpPath(), "cache") - if not os.path.isdir(pathToReturn): - os.makedirs(pathToReturn) - return pathToReturn - - - def getTmpProjectPath(self): - pathToReturn = os.path.join(self.getTmpPath(), self.guuid) - if not os.path.isdir(pathToReturn): - os.makedirs(pathToReturn) - return pathToReturn - - def getTmpPathForName(self, name, copyFromCache=False): - 'Returns the tmp path for a file, and a flag indicating if the file exists. Will also check in the cache and copy to tmp if copyFromCache==True' - slugifiedName = slugify(name) - tmpPath = os.path.join(self.getTmpProjectPath(), slugifiedName) - fileExists = False - if os.path.isfile(tmpPath): - # file already exists in tmp path, return path and exists flag - fileExists = True - elif copyFromCache: - # See if the file exists in cache, and copy over to project folder. - cacheFilePath = os.path.join(self.getCachePath(), slugifiedName) - if os.path.isfile(cacheFilePath): - shutil.copy(cacheFilePath, tmpPath) - fileExists = True - return (tmpPath, fileExists) - - def copyToCache(self, name): - srcPath, fileExists = self.getTmpPathForName(name, copyFromCache=False) - assert fileExists, "Tried to copy source file to cache, but file not found for: {0}".format(srcPath) - # Now copy to the cache if it does not already exist - cacheFilePath = os.path.join(self.getCachePath(), slugify(name)) - if not os.path.isfile(cacheFilePath): - shutil.copy(srcPath, cacheFilePath) - - - def isConfigEnabled(self, configName): - return self.context.config.userdata.get(configName, "false") == "true" +ApplicationGroup = "Application" +OrdererGroup = "Orderer" +MSPKey = "MSP" +toValue = lambda message: message.SerializeToString() + + +class Network(Enum): + Orderer = 1 + Peer = 2 - @classmethod - def GetHelper(cls, context): - if not "contextHelper" in context: - context.contextHelper = ContextHelper(context) - return context.contextHelper def GetUUID(): return compose.Composition.GetUUID() def createRSAKey(): - #Create RSA key, 2048 bit + # Create RSA key, 2048 bit pk = crypto.PKey() - pk.generate_key(crypto.TYPE_RSA,2048) - assert pk.check()==True + pk.generate_key(crypto.TYPE_RSA, 2048) + assert pk.check() == True return pk + def createECDSAKey(curve=ecdsa.NIST256p): - #Create ECDSA key + # Create ECDSA key sk = ecdsa.SigningKey.generate(curve=curve) return sk @@ -131,9 +82,11 @@ def createECDSAKey(curve=ecdsa.NIST256p): def computeCryptoHash(data): ' This will currently return 128 hex characters' # s = hashlib.sha3_256() - s = hashlib.shake_256() + s = hashlib.sha256() + # s = hashlib.shake_256() + #return s.digest(64) s.update(data) - return s.digest(64) + return s.digest() def createCertRequest(pkey, digest="sha256", **name): @@ -162,7 +115,8 @@ def createCertRequest(pkey, digest="sha256", **name): req.sign(pkey, digest) return req -def createCertificate(req, issuerCertKey, serial, validityPeriod, digest="sha256"): + +def createCertificate(req, issuerCertKey, serial, validityPeriod, digest="sha256", isCA=False): """ Generate a certificate given a certificate request. Arguments: req - Certificate request to use @@ -179,33 +133,47 @@ def createCertificate(req, issuerCertKey, serial, validityPeriod, digest="sha256 issuerCert, issuerKey = issuerCertKey notBefore, notAfter = validityPeriod cert = crypto.X509() + cert.set_version(3) cert.set_serial_number(serial) cert.gmtime_adj_notBefore(notBefore) cert.gmtime_adj_notAfter(notAfter) cert.set_issuer(issuerCert.get_subject()) cert.set_subject(req.get_subject()) cert.set_pubkey(req.get_pubkey()) + if isCA: + cert.add_extensions([crypto.X509Extension("basicConstraints", True, + "CA:TRUE, pathlen:0"), + crypto.X509Extension("subjectKeyIdentifier", False, "hash", + subject=cert)]) + #TODO: This only is appropriate for root self signed!!!! + cert.add_extensions([crypto.X509Extension("authorityKeyIdentifier", False, "keyid:always", issuer=cert)]) + else: + cert.add_extensions([crypto.X509Extension("basicConstraints", True, + "CA:FALSE"), + crypto.X509Extension("subjectKeyIdentifier", False, "hash", + subject=cert)]) + cert.add_extensions([crypto.X509Extension("authorityKeyIdentifier", False, "keyid:always", issuer=issuerCert)]) + cert.sign(issuerKey, digest) return cert -#SUBJECT_DEFAULT = {countryName : "US", stateOrProvinceName : "NC", localityName : "RTP", organizationName : "IBM", organizationalUnitName : "Blockchain"} -class Entity: +# SUBJECT_DEFAULT = {countryName : "US", stateOrProvinceName : "NC", localityName : "RTP", organizationName : "IBM", organizationalUnitName : "Blockchain"} +class Entity: def __init__(self, name): self.name = name - #Create a ECDSA key, then a crypto pKey from the DER for usage with cert requests, etc. + # Create a ECDSA key, then a crypto pKey from the DER for usage with cert requests, etc. self.ecdsaSigningKey = createECDSAKey() self.pKey = crypto.load_privatekey(crypto.FILETYPE_ASN1, self.ecdsaSigningKey.to_der()) # Signing related ecdsa config self.hashfunc = hashlib.sha256 - self.sigencode=ecdsa.util.sigencode_der_canonize - self.sigdecode=ecdsa.util.sigdecode_der - + self.sigencode = ecdsa.util.sigencode_der_canonize + self.sigdecode = ecdsa.util.sigdecode_der def createCertRequest(self, nodeName): req = createCertRequest(self.pKey, CN=nodeName) - #print("request => {0}".format(crypto.dump_certificate_request(crypto.FILETYPE_PEM, req))) + # print("request => {0}".format(crypto.dump_certificate_request(crypto.FILETYPE_PEM, req))) return req def computeHash(self, data): @@ -221,6 +189,9 @@ def verifySignature(self, signature, signersCert, data): vk = ecdsa.VerifyingKey.from_der(crypto.dump_publickey(crypto.FILETYPE_ASN1, signersCert.get_pubkey())) assert vk.verify(signature, data, hashfunc=self.hashfunc, sigdecode=self.sigdecode), "Invalid signature!!" + def getPrivateKeyAsPEM(self): + return self.ecdsaSigningKey.to_pem() + class User(Entity, orderer_util.UserRegistration): def __init__(self, name): @@ -228,9 +199,12 @@ def __init__(self, name): orderer_util.UserRegistration.__init__(self, name) self.tags = {} -class Network(Enum): - Orderer = 1 - Peer = 2 + def setTagValue(self, tagKey, tagValue, overwrite=False): + if tagKey in self.tags: + assert not overwrite,"TagKey '{0}' already exists for user {1}, and did not provide overwrite=True".format(tagKey, self.getUserName()) + self.tags[tagKey] = tagValue + return tagValue + class Organization(Entity): @@ -238,13 +212,16 @@ def __init__(self, name): Entity.__init__(self, name) req = createCertRequest(self.pKey, CN=name) numYrs = 1 - self.signedCert = createCertificate(req, (req, self.pKey), 1000, (0, 60*60*24*365*numYrs)) + self.signedCert = createCertificate(req, (req, self.pKey), 1000, (0, 60 * 60 * 24 * 365 * numYrs), isCA=True) # Which networks this organization belongs to self.networks = [] def getSelfSignedCert(self): return self.signedCert + def getCertAsPEM(self): + return crypto.dump_certificate(crypto.FILETYPE_PEM, self.getSelfSignedCert()) + def getMSPConfig(self): certPemsList = [crypto.dump_certificate(crypto.FILETYPE_PEM, self.getSelfSignedCert())] # For now, admin certs and CA certs are the same per @ASO @@ -253,70 +230,83 @@ def getMSPConfig(self): # Currently only 1 component, CN= # name = self.getSelfSignedCert().get_subject().getComponents()[0][1] name = self.name - fabricMSPConfig = mspconfig_pb2.FabricMSPConfig(Admins=adminCerts, RootCerts=cacerts, Name=name) - mspConfig = mspconfig_pb2.MSPConfig(Config=fabricMSPConfig.SerializeToString(), Type=0) + fabricMSPConfig = mspconfig_pb2.FabricMSPConfig(admins=adminCerts, root_certs=cacerts, name=name) + mspConfig = mspconfig_pb2.MSPConfig(config=fabricMSPConfig.SerializeToString(), type=0) return mspConfig - pass - def createCertificate(self, certReq): numYrs = 1 - return createCertificate(certReq, (self.signedCert, self.pKey), 1000, (0, 60*60*24*365*numYrs)) + return createCertificate(certReq, (self.signedCert, self.pKey), 1000, (0, 60 * 60 * 24 * 365 * numYrs)) def addToNetwork(self, network): 'Used to track which network this organization is defined in.' - assert network in Network, 'Network not recognized ({0}), expected to be one of ({1})'.format(network, list(Network)) + # assert network in Network, 'Network not recognized ({0}), expected to be one of ({1})'.format(network, list(Network)) if not network in self.networks: self.networks.append(network) class Directory: - def __init__(self): self.organizations = {} self.users = {} self.ordererAdminTuples = {} - def registerOrg(self, orgName, network): + def getNamedCtxTuples(self): + return self.ordererAdminTuples + + def _registerOrg(self, orgName): assert orgName not in self.organizations, "Organization already registered {0}".format(orgName) self.organizations[orgName] = Organization(orgName) return self.organizations[orgName] - def registerUser(self, userName): + def _registerUser(self, userName): assert userName not in self.users, "User already registered {0}".format(userName) self.users[userName] = User(userName) return self.users[userName] - def getUser(self, userName, shouldCreate = False): + def getUser(self, userName, shouldCreate=False): if not userName in self.users and shouldCreate: - self.users[userName] = User(userName) + # self.users[userName] = User(userName) + self._registerUser(userName) return self.users[userName] - def getOrganization(self, orgName, shouldCreate = False): + def getUsers(self): + return self.users + + def getOrganization(self, orgName, shouldCreate=False): if not orgName in self.organizations and shouldCreate: - self.organizations[orgName] = Organization(orgName) + # self.organizations[orgName] = Organization(orgName) + self._registerOrg(orgName) return self.organizations[orgName] + def getOrganizations(self): + return self.organizations + def findCertByTuple(self, userName, contextName, orgName): - ordererAdminTuple = NodeAdminTuple(user = userName, nodeName = contextName, organization = orgName) + ordererAdminTuple = NodeAdminTuple(user=userName, nodeName=contextName, organization=orgName) return self.ordererAdminTuples[ordererAdminTuple] def findCertForNodeAdminTuple(self, nodeAdminTuple): assert nodeAdminTuple in self.ordererAdminTuples, "Node admin tuple not found for: {0}".format(nodeAdminTuple) return self.ordererAdminTuples[nodeAdminTuple] + def getCertAsPEM(self, nodeAdminTuple): + assert nodeAdminTuple in self.ordererAdminTuples, "Node admin tuple not found for: {0}".format(nodeAdminTuple) + return crypto.dump_certificate(crypto.FILETYPE_PEM, self.ordererAdminTuples[nodeAdminTuple]) + def findNodeAdminTuple(self, userName, contextName, orgName): - nodeAdminTuple = NodeAdminTuple(user = userName, nodeName = contextName, organization = orgName) + nodeAdminTuple = NodeAdminTuple(user=userName, nodeName=contextName, organization=orgName) assert nodeAdminTuple in self.ordererAdminTuples, "Node admin tuple not found for: {0}".format(nodeAdminTuple) return nodeAdminTuple def registerOrdererAdminTuple(self, userName, ordererName, organizationName): ' Assign the user as orderer admin' - ordererAdminTuple = NodeAdminTuple(user = userName, nodeName = ordererName, organization = organizationName) - assert ordererAdminTuple not in self.ordererAdminTuples, "Orderer admin tuple already registered {0}".format(ordererAdminTuple) + ordererAdminTuple = NodeAdminTuple(user=userName, nodeName=ordererName, organization=organizationName) + assert ordererAdminTuple not in self.ordererAdminTuples, "Orderer admin tuple already registered {0}".format( + ordererAdminTuple) assert organizationName in self.organizations, "Orderer Organization not defined {0}".format(organizationName) - user = self.getUser(userName, shouldCreate = True) + user = self.getUser(userName, shouldCreate=True) certReq = user.createCertRequest(ordererAdminTuple.nodeName) userCert = self.getOrganization(organizationName).createCertificate(certReq) @@ -334,27 +324,24 @@ def registerOrdererAdminTuple(self, userName, ordererName, organizationName): class AuthDSLHelper: - @classmethod def Envelope(cls, signaturePolicy, identities): 'Envelope builds an envelope message embedding a SignaturePolicy' - return common_dot_configuration_pb2.SignaturePolicyEnvelope( - Version=0, - Policy=signaturePolicy, - Identities=identities) + return common_dot_policies_pb2.SignaturePolicyEnvelope( + version=0, + policy=signaturePolicy, + identities=identities) @classmethod def NOutOf(cls, n, policies): 'NOutOf creates a policy which requires N out of the slice of policies to evaluate to true' - return common_dot_configuration_pb2.SignaturePolicy( - From=common_dot_configuration_pb2.SignaturePolicy.NOutOf( + return common_dot_policies_pb2.SignaturePolicy( + n_out_of=common_dot_policies_pb2.SignaturePolicy.NOutOf( N=n, - Policies=policies, + policies=policies, ), ) - - class BootstrapHelper: KEY_CONSENSUS_TYPE = "ConsensusType" KEY_CHAIN_CREATION_POLICY_NAMES = "ChainCreationPolicyNames" @@ -373,7 +360,24 @@ class BootstrapHelper: DEFAULT_NONCE_SIZE = 24 - def __init__(self, chainId = "TestChain", lastModified = 0, msgVersion = 1, epoch = 0, consensusType = "solo", batchSize = 10, batchTimeout="10s", absoluteMaxBytes=100000000, preferredMaxBytes=512*1024, signers=[]): + @classmethod + def getNonce(cls): + return rand.bytes(BootstrapHelper.DEFAULT_NONCE_SIZE) + + @classmethod + def addSignatureToSignedConfigItem(cls, configUpdateEnvelope, (entity, cert)): + sigHeader = common_dot_common_pb2.SignatureHeader(creator=crypto.dump_certificate(crypto.FILETYPE_ASN1, cert), + nonce=BootstrapHelper.getNonce()) + sigHeaderBytes = sigHeader.SerializeToString() + # Signature over the concatenation of configurationItem bytes and signatureHeader bytes + signature = entity.sign(sigHeaderBytes + configUpdateEnvelope.config_update) + # Now add new signature to Signatures repeated field + newConfigSig = configUpdateEnvelope.signatures.add() + newConfigSig.signature_header = sigHeaderBytes + newConfigSig.signature = signature + + def __init__(self, chainId, lastModified=0, msgVersion=1, epoch=0, consensusType="solo", batchSize=10, + batchTimeout="10s", absoluteMaxBytes=100000000, preferredMaxBytes=512 * 1024, signers=[]): self.chainId = str(chainId) self.lastModified = lastModified self.msgVersion = msgVersion @@ -385,139 +389,132 @@ def __init__(self, chainId = "TestChain", lastModified = 0, msgVersion = 1, epoc self.preferredMaxBytes = preferredMaxBytes self.signers = signers - @classmethod - def getNonce(cls): - return rand.bytes(BootstrapHelper.DEFAULT_NONCE_SIZE) + def makeChainHeader(self, type, txID="", extension='', + version=1, + timestamp=timestamp_pb2.Timestamp(seconds=int(time.time()), nanos=0)): + return common_dot_common_pb2.ChannelHeader(type=type, + version=version, + timestamp=timestamp, + channel_id=self.chainId, + epoch=self.epoch, + tx_id=txID, + extension=extension) - @classmethod - def addSignatureToSignedConfigItem(cls, signedConfigItem, (entity, cert)): - sigHeader = common_dot_common_pb2.SignatureHeader(creator=crypto.dump_certificate(crypto.FILETYPE_ASN1,cert),nonce=BootstrapHelper.getNonce()) - sigHeaderBytes = sigHeader.SerializeToString() - # Signature over the concatenation of configurationItem bytes and signatureHeader bytes - signature = entity.sign(signedConfigItem.ConfigurationItem + sigHeaderBytes) - # Now add new signature to Signatures repeated field - newConfigSig = signedConfigItem.Signatures.add() - newConfigSig.signatureHeader=sigHeaderBytes - newConfigSig.signature=signature - - - def makeChainHeader(self, type = common_dot_common_pb2.HeaderType.Value("CONFIGURATION_ITEM"), txID = "", extension='', version = 1, - timestamp = timestamp_pb2.Timestamp(seconds = int(time.time()), nanos = 0)): - return common_dot_common_pb2.ChainHeader(type = type, - version = version, - timestamp = timestamp, - chainID = self.chainId, - epoch = self.epoch, - txID = txID, - extension = extension) def makeSignatureHeader(self, serializeCertChain, nonce): - return common_dot_common_pb2.SignatureHeader(creator = serializeCertChain, - nonce = nonce) + return common_dot_common_pb2.SignatureHeader(creator=serializeCertChain, + nonce=nonce) def signConfigItem(self, configItem): - signedConfigItem = common_dot_configuration_pb2.SignedConfigurationItem(ConfigurationItem=configItem.SerializeToString(), Signatures=None) - return signedConfigItem + # signedConfigItem = common_dot_configuration_pb2.SignedConfigurationItem( + # ConfigurationItem=configItem.SerializeToString(), Signatures=None) + # return signedConfigItem + return configItem def getConfigItem(self, commonConfigType, key, value): - configItem = common_dot_configuration_pb2.ConfigurationItem( - Header=self.makeChainHeader(type=common_dot_common_pb2.HeaderType.Value("CONFIGURATION_ITEM")), - Type=commonConfigType, - LastModified=self.lastModified, - ModificationPolicy=BootstrapHelper.KEY_NEW_CONFIGURATION_ITEM_POLICY, - Key=key, - Value=value) + configItem = common_dot_configtx_pb2.ConfigItem( + version=self.lastModified, + configPath=commonConfigType, + key=key, + mod_policy=BootstrapHelper.KEY_NEW_CONFIGURATION_ITEM_POLICY, + value=value) return configItem - def encodeAnchorInfo(self, ciValue): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Peer"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("PEER"), key=BootstrapHelper.KEY_ANCHOR_PEERS, value=ciValue.SerializeToString()) return self.signConfigItem(configItem) def encodeMspInfo(self, mspUniqueId, ciValue): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("MSP"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("MSP"), key=mspUniqueId, value=ciValue.SerializeToString()) return self.signConfigItem(configItem) def encodeHashingAlgorithm(self, hashingAlgorithm="SHAKE256"): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Chain"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("CHAIN"), key=BootstrapHelper.KEY_HASHING_ALGORITHM, value=common_dot_configuration_pb2.HashingAlgorithm(name=hashingAlgorithm).SerializeToString()) return self.signConfigItem(configItem) def encodeBatchSize(self): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Orderer"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("ORDERER"), key=BootstrapHelper.KEY_BATCH_SIZE, - value=orderer_dot_configuration_pb2.BatchSize(maxMessageCount=self.batchSize, absoluteMaxBytes=self.absoluteMaxBytes, preferredMaxBytes=self.preferredMaxBytes).SerializeToString()) + value=orderer_dot_configuration_pb2.BatchSize(maxMessageCount=self.batchSize, + absoluteMaxBytes=self.absoluteMaxBytes, + preferredMaxBytes=self.preferredMaxBytes).SerializeToString()) return self.signConfigItem(configItem) def encodeBatchTimeout(self): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Orderer"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("ORDERER"), key=BootstrapHelper.KEY_BATCH_TIMEOUT, value=orderer_dot_configuration_pb2.BatchTimeout(timeout=self.batchTimeout).SerializeToString()) return self.signConfigItem(configItem) - def encodeConsensusType(self): + def encodeConsensusType(self): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Orderer"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("ORDERER"), key=BootstrapHelper.KEY_CONSENSUS_TYPE, value=orderer_dot_configuration_pb2.ConsensusType(type=self.consensusType).SerializeToString()) return self.signConfigItem(configItem) - def encodeChainCreators(self, ciValue = orderer_dot_configuration_pb2.ChainCreationPolicyNames(names=DEFAULT_CHAIN_CREATORS).SerializeToString()): + def encodeChainCreators(self, ciValue=orderer_dot_configuration_pb2.ChainCreationPolicyNames( + names=DEFAULT_CHAIN_CREATORS).SerializeToString()): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Orderer"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("ORDERER"), key=BootstrapHelper.KEY_CHAIN_CREATION_POLICY_NAMES, value=ciValue) return self.signConfigItem(configItem) - def encodePolicy(self, key, policy=common_dot_configuration_pb2.Policy(type=common_dot_configuration_pb2.Policy.PolicyType.Value("SIGNATURE"), policy=AuthDSLHelper.Envelope(signaturePolicy=AuthDSLHelper.NOutOf(0,[]), identities=[]).SerializeToString())): + def encodePolicy(self, key, policy=common_dot_policies_pb2.Policy( + type=common_dot_policies_pb2.Policy.PolicyType.Value("SIGNATURE"), + policy=AuthDSLHelper.Envelope(signaturePolicy=AuthDSLHelper.NOutOf(0, []), identities=[]).SerializeToString())): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Policy"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("POLICY"), key=key, value=policy.SerializeToString()) return self.signConfigItem(configItem) - - def encodeEgressPolicy(self): + def encodeEgressPolicy(self): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Orderer"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("ORDERER"), key=BootstrapHelper.KEY_EGRESS_POLICY, - value=orderer_dot_configuration_pb2.EgressPolicyNames(names=[BootstrapHelper.KEY_ACCEPT_ALL_POLICY]).SerializeToString()) + value=orderer_dot_configuration_pb2.EgressPolicyNames( + names=[BootstrapHelper.KEY_ACCEPT_ALL_POLICY]).SerializeToString()) return self.signConfigItem(configItem) - def encodeIngressPolicy(self): + def encodeIngressPolicy(self): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Orderer"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("ORDERER"), key=BootstrapHelper.KEY_INGRESS_POLICY, - value=orderer_dot_configuration_pb2.IngressPolicyNames(names=[BootstrapHelper.KEY_ACCEPT_ALL_POLICY]).SerializeToString()) + value=orderer_dot_configuration_pb2.IngressPolicyNames( + names=[BootstrapHelper.KEY_ACCEPT_ALL_POLICY]).SerializeToString()) return self.signConfigItem(configItem) def encodeAcceptAllPolicy(self): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Policy"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("POLICY"), key=BootstrapHelper.KEY_ACCEPT_ALL_POLICY, - value=common_dot_configuration_pb2.Policy(type=1, policy=AuthDSLHelper.Envelope(signaturePolicy=AuthDSLHelper.NOutOf(0,[]), identities=[]).SerializeToString()).SerializeToString()) + value=common_dot_policies_pb2.Policy(type=1, policy=AuthDSLHelper.Envelope( + signaturePolicy=AuthDSLHelper.NOutOf(0, []), identities=[]).SerializeToString()).SerializeToString()) return self.signConfigItem(configItem) def lockDefaultModificationPolicy(self): configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Policy"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("POLICY"), key=BootstrapHelper.KEY_NEW_CONFIGURATION_ITEM_POLICY, - value=common_dot_configuration_pb2.Policy(type=1, policy=AuthDSLHelper.Envelope(signaturePolicy=AuthDSLHelper.NOutOf(1,[]), identities=[]).SerializeToString()).SerializeToString()) + value=common_dot_policies_pb2.Policy(type=1, policy=AuthDSLHelper.Envelope( + signaturePolicy=AuthDSLHelper.NOutOf(1, []), identities=[]).SerializeToString()).SerializeToString()) return self.signConfigItem(configItem) def computeBlockDataHash(self, blockData): return computeCryptoHash(blockData.SerializeToString()) - def signInitialChainConfig(self, signedConfigItems, chainCreationPolicyName): 'Create a signedConfigItem using previous config items' # Create byte array to store concatenated bytes @@ -525,34 +522,38 @@ def signInitialChainConfig(self, signedConfigItems, chainCreationPolicyName): # for sci in signedConfigItems: # concatenatedConfigItemsBytes = concatenatedConfigItemsBytes + bytearray(sci.ConfigurationItem) # hash = computeCryptoHash(concatenatedConfigItemsBytes) - data = '' - for sci in signedConfigItems: - data = data + sci.ConfigurationItem - # Compute hash over concatenated bytes - hash = computeCryptoHash(data) + # data = '' + # for sci in signedConfigItems: + # data = data + sci.ConfigurationItem + # # Compute hash over concatenated bytes + # hash = computeCryptoHash(data) configItem = self.getConfigItem( - commonConfigType=common_dot_configuration_pb2.ConfigurationItem.ConfigurationType.Value("Orderer"), + commonConfigType=common_dot_configtx_pb2.ConfigItem.ConfigType.Value("ORDERER"), key=BootstrapHelper.KEY_CREATIONPOLICY, - value=orderer_dot_configuration_pb2.CreationPolicy(policy=chainCreationPolicyName, digest=hash).SerializeToString()) + value=orderer_dot_configuration_pb2.CreationPolicy(policy=chainCreationPolicyName).SerializeToString()) return [self.signConfigItem(configItem)] + signedConfigItems -def signInitialChainConfig(signedConfigItems, chainId, chainCreationPolicyName): - bootstrapHelper = BootstrapHelper(chainId = chainId) +def createConfigUpdateEnvelope(channelConfigGroup, chainId, chainCreationPolicyName): # Returns a list prepended with a signedConfiguration - signedConfigItems = bootstrapHelper.signInitialChainConfig(signedConfigItems, chainCreationPolicyName) - return common_dot_configuration_pb2.ConfigurationEnvelope(Items=signedConfigItems) + channelConfigGroup.groups[OrdererGroup].values[BootstrapHelper.KEY_CREATIONPOLICY].value = toValue( + orderer_dot_configuration_pb2.CreationPolicy(policy=chainCreationPolicyName)) + config_update_envelope = createNewConfigUpdateEnvelope(channelConfig=channelConfigGroup, chainId=chainId) + return config_update_envelope + def getDirectory(context): if 'bootstrapDirectory' not in context: context.bootstrapDirectory = Directory() return context.bootstrapDirectory + def getOrdererBootstrapAdmin(context, shouldCreate=False): directory = getDirectory(context) ordererBootstrapAdmin = directory.getUser(userName="ordererBootstrapAdmin", shouldCreate=shouldCreate) return ordererBootstrapAdmin + def addOrdererBootstrapAdminOrgReferences(context, policyName, orgNames): 'Adds a key/value pair of policyName/[orgName,...]' directory = getDirectory(context) @@ -560,10 +561,12 @@ def addOrdererBootstrapAdminOrgReferences(context, policyName, orgNames): if not 'OrgReferences' in ordererBootstrapAdmin.tags: ordererBootstrapAdmin.tags['OrgReferences'] = {} policyNameToOrgNamesDict = ordererBootstrapAdmin.tags['OrgReferences'] - assert not policyName in policyNameToOrgNamesDict, "PolicyName '{0}' already registered with ordererBootstrapAdmin".format(policyName) + assert not policyName in policyNameToOrgNamesDict, "PolicyName '{0}' already registered with ordererBootstrapAdmin".format( + policyName) policyNameToOrgNamesDict[policyName] = orgNames return policyNameToOrgNamesDict + def getOrdererBootstrapAdminOrgReferences(context): directory = getDirectory(context) ordererBootstrapAdmin = directory.getUser(userName="ordererBootstrapAdmin", shouldCreate=False) @@ -571,64 +574,108 @@ def getOrdererBootstrapAdminOrgReferences(context): ordererBootstrapAdmin.tags['OrgReferences'] = {} return ordererBootstrapAdmin.tags['OrgReferences'] -def getSignedMSPConfigItems(context, chainId, orgNames): - directory = getDirectory(context) - bootstrapHelper = BootstrapHelper(chainId=chainId) - orgs = [directory.getOrganization(orgName) for orgName in orgNames] - mspSignedConfigItems = [bootstrapHelper.encodeMspInfo(org.name, org.getMSPConfig()) for org in orgs] - return mspSignedConfigItems -def getSignedAnchorConfigItems(context, chainId, nodeAdminTuples): +def getSignedMSPConfigItems(context, orgNames): directory = getDirectory(context) - bootstrapHelper = BootstrapHelper(chainId=chainId) - - anchorPeers = peer_dot_configuration_pb2.AnchorPeers() - for nodeAdminTuple in nodeAdminTuples: - anchorPeer = anchorPeers.anchorPeers.add() - anchorPeer.Host=nodeAdminTuple.nodeName - anchorPeer.Port=5611 - anchorPeer.Cert=crypto.dump_certificate(crypto.FILETYPE_PEM, directory.findCertForNodeAdminTuple(nodeAdminTuple)) + orgs = [directory.getOrganization(orgName) for orgName in orgNames] - anchorsSignedConfigItems = [bootstrapHelper.encodeAnchorInfo(anchorPeers)] - return anchorsSignedConfigItems + channel = common_dot_configtx_pb2.ConfigGroup() + for org in orgs: + channel.groups[ApplicationGroup].groups[org.name].values[BootstrapHelper.KEY_MSP_INFO].value = toValue( + org.getMSPConfig()) + return [channel] -def getMspConfigItemsForPolicyNames(context, chainId, policyNames): +def getAnchorPeersConfigGroup(context, nodeAdminTuples): directory = getDirectory(context) - ordererBootstrapAdmin = getOrdererBootstrapAdmin(context) + config_group = common_dot_configtx_pb2.ConfigGroup() + for orgName, group in groupby([(nat.organization, nat) for nat in nodeAdminTuples], lambda x: x[0]): + anchorPeers = peer_dot_configuration_pb2.AnchorPeers() + for (k,nodeAdminTuple) in group: + anchorPeer = anchorPeers.anchor_peers.add() + anchorPeer.host = nodeAdminTuple.nodeName + anchorPeer.port = 5611 + anchorPeer.cert = crypto.dump_certificate(crypto.FILETYPE_PEM, + directory.findCertForNodeAdminTuple(nodeAdminTuple)) + config_group.groups[ApplicationGroup].groups[orgName].values[BootstrapHelper.KEY_ANCHOR_PEERS].value=toValue(anchorPeers) + return [config_group] + + +def getMspConfigItemsForPolicyNames(context, policyNames): policyNameToOrgNamesDict = getOrdererBootstrapAdminOrgReferences(context) # Get unique set of org names and return set of signed MSP ConfigItems - orgNamesReferenced = list(set([orgName for policyName in policyNames for orgName in policyNameToOrgNamesDict[policyName]])) + orgNamesReferenced = list( + set([orgName for policyName in policyNames for orgName in policyNameToOrgNamesDict[policyName]])) orgNamesReferenced.sort() - return getSignedMSPConfigItems(context=context, chainId=chainId, orgNames=orgNamesReferenced) - - - -def createSignedConfigItems(context, chainId, consensusType, signedConfigItems = []): - # directory = getDirectory(context) - # assert len(directory.ordererAdminTuples) > 0, "No orderer admin tuples defined!!!" - bootstrapHelper = BootstrapHelper(chainId = chainId, consensusType=consensusType) - configItems = signedConfigItems - configItems.append(bootstrapHelper.encodeHashingAlgorithm()) - - # configItems.append(bootstrapHelper.encodeBlockDataHashingStructure()) - # configItems.append(bootstrapHelper.encodeOrdererAddresses()) - - configItems.append(bootstrapHelper.encodeBatchSize()) - configItems.append(bootstrapHelper.encodeBatchTimeout()) - configItems.append(bootstrapHelper.encodeConsensusType()) - configItems.append(bootstrapHelper.encodeAcceptAllPolicy()) - configItems.append(bootstrapHelper.encodeIngressPolicy()) - configItems.append(bootstrapHelper.encodeEgressPolicy()) - configItems.append(bootstrapHelper.lockDefaultModificationPolicy()) - return configItems + return getSignedMSPConfigItems(context=context, orgNames=orgNamesReferenced) + + +def createSignedConfigItems(configGroups=[]): + + channelConfig = createChannelConfigGroup() + for configGroup in configGroups: + mergeConfigGroups(channelConfig, configGroup) + return channelConfig + + +def createChannelConfigGroup(hashingAlgoName="SHA256", consensusType="solo", batchTimeout="10s", batchSizeMaxMessageCount=10, batchSizeAbsoluteMaxBytes=100000000, batchSizePreferredMaxBytes=512 * 1024): + + channel = common_dot_configtx_pb2.ConfigGroup() + # channel.groups[ApplicationGroup] = common_dot_configtx_pb2.ConfigGroup() + # channel.groups[OrdererGroup] = common_dot_configtx_pb2.ConfigGroup() + channel.groups[ApplicationGroup] + channel.groups[OrdererGroup] + # v = common_dot_configtx_pb2.ConfigItem.ConfigType.Value + # configItems.append(bootstrapHelper.encodeHashingAlgorithm()) + channel.values[BootstrapHelper.KEY_HASHING_ALGORITHM].value = toValue( + common_dot_configuration_pb2.HashingAlgorithm(name=hashingAlgoName)) + + channel.groups[OrdererGroup].values[BootstrapHelper.KEY_BATCH_SIZE].value = toValue(orderer_dot_configuration_pb2.BatchSize(maxMessageCount=batchSizeMaxMessageCount,absoluteMaxBytes=batchSizeAbsoluteMaxBytes,preferredMaxBytes=batchSizePreferredMaxBytes)) + channel.groups[OrdererGroup].values[BootstrapHelper.KEY_BATCH_TIMEOUT].value = toValue(orderer_dot_configuration_pb2.BatchTimeout(timeout=batchTimeout)) + channel.groups[OrdererGroup].values[BootstrapHelper.KEY_CONSENSUS_TYPE].value = toValue(orderer_dot_configuration_pb2.ConsensusType(type=consensusType)) + + acceptAllPolicy = common_dot_policies_pb2.Policy(type=1, policy=AuthDSLHelper.Envelope( + signaturePolicy=AuthDSLHelper.NOutOf(0, []), identities=[]).SerializeToString()) + channel.policies[BootstrapHelper.KEY_ACCEPT_ALL_POLICY].policy.CopyFrom(acceptAllPolicy) + channel.groups[OrdererGroup].values[ + BootstrapHelper.KEY_INGRESS_POLICY].value = toValue( + orderer_dot_configuration_pb2.IngressPolicyNames( + names=[BootstrapHelper.KEY_ACCEPT_ALL_POLICY])) + channel.groups[OrdererGroup].values[ + BootstrapHelper.KEY_EGRESS_POLICY].value = toValue( + orderer_dot_configuration_pb2.EgressPolicyNames( + names=[BootstrapHelper.KEY_ACCEPT_ALL_POLICY])) + return channel + +def createConfigUpdateTxEnvelope(chainId, configUpdateEnvelope): + 'The Join channel flow' + bootstrapHelper = BootstrapHelper(chainId=chainId) + payloadChainHeader = bootstrapHelper.makeChainHeader( + type=common_dot_common_pb2.HeaderType.Value("CONFIG_UPDATE")) + + # Now the SignatureHeader + serializedCreatorCertChain = None + nonce = None + payloadSignatureHeader = common_dot_common_pb2.SignatureHeader( + creator=serializedCreatorCertChain, + nonce=bootstrapHelper.getNonce(), + ) + payloadHeader = common_dot_common_pb2.Header( + channel_header=payloadChainHeader, + signature_header=payloadSignatureHeader, + ) + payload = common_dot_common_pb2.Payload(header=payloadHeader, data=configUpdateEnvelope.SerializeToString()) + envelope = common_dot_common_pb2.Envelope(payload=payload.SerializeToString(), signature=None) + return envelope -def createConfigTxEnvelope(chainId, signedConfigEnvelope): - bootstrapHelper = BootstrapHelper(chainId = chainId) - payloadChainHeader = bootstrapHelper.makeChainHeader(type=common_dot_common_pb2.HeaderType.Value("CONFIGURATION_TRANSACTION")) +def createConfigTxEnvelope(chainId, config_envelope): + # configEnvelope = common_dot_configtx_pb2.ConfigEnvelope(last_update=envelope.SerializeToString()) + bootstrapHelper = BootstrapHelper(chainId=chainId) + payloadChainHeader = bootstrapHelper.makeChainHeader( + type=common_dot_common_pb2.HeaderType.Value("CONFIG")) - #Now the SignatureHeader + # Now the SignatureHeader serializedCreatorCertChain = None nonce = None payloadSignatureHeader = common_dot_common_pb2.SignatureHeader( @@ -637,42 +684,80 @@ def createConfigTxEnvelope(chainId, signedConfigEnvelope): ) payloadHeader = common_dot_common_pb2.Header( - chainHeader=payloadChainHeader, - signatureHeader=payloadSignatureHeader, + channel_header=payloadChainHeader, + signature_header=payloadSignatureHeader, ) - payload = common_dot_common_pb2.Payload(header=payloadHeader, data=signedConfigEnvelope.SerializeToString()) + payload = common_dot_common_pb2.Payload(header=payloadHeader, data=config_envelope.SerializeToString()) envelope = common_dot_common_pb2.Envelope(payload=payload.SerializeToString(), signature=None) return envelope -def createGenesisBlock(context, chainId, consensusType, signedConfigItems = []): + return configEnvelope + +def createNewConfigUpdateEnvelope(channelConfig, chainId): + configUpdate = common_dot_configtx_pb2.ConfigUpdate(header=common_dot_common_pb2.ChannelHeader(channel_id=chainId, + type=common_dot_common_pb2.HeaderType.Value( + "CONFIG_UPDATE")), + write_set=channelConfig) + configUpdateEnvelope = common_dot_configtx_pb2.ConfigUpdateEnvelope(config_update=configUpdate.SerializeToString(), signatures =[]) + return configUpdateEnvelope + + +def mergeConfigGroups(configGroupTarget, configGroupSource): + for k, v in configGroupSource.groups.iteritems(): + if k in configGroupTarget.groups.keys(): + mergeConfigGroups(configGroupTarget.groups[k], configGroupSource.groups[k]) + else: + configGroupTarget.groups[k].MergeFrom(v) + for k, v in configGroupSource.policies.iteritems(): + if k in configGroupTarget.policies.keys(): + mergeConfigGroups(configGroupTarget.policies[k], configGroupSource.policies[k]) + else: + configGroupTarget.policies[k].MergeFrom(v) + for k, v in configGroupSource.values.iteritems(): + assert not k in configGroupTarget.values.keys(), "Value already exists in target config group: {0}".format(k) + configGroupTarget.values[k].CopyFrom(v) + + +def createGenesisBlock(context, chainId, consensusType, signedConfigItems=[]): 'Generates the genesis block for starting the oderers and for use in the chain config transaction by peers' - #assert not "bootstrapGenesisBlock" in context,"Genesis block already created:\n{0}".format(context.bootstrapGenesisBlock) + # assert not "bootstrapGenesisBlock" in context,"Genesis block already created:\n{0}".format(context.bootstrapGenesisBlock) directory = getDirectory(context) assert len(directory.ordererAdminTuples) > 0, "No orderer admin tuples defined!!!" - configItems = createSignedConfigItems(context, chainId, consensusType, signedConfigItems = signedConfigItems) + channelConfig = createChannelConfigGroup() + for configGroup in signedConfigItems: + mergeConfigGroups(channelConfig, configGroup) - bootstrapHelper = BootstrapHelper(chainId = chainId, consensusType=consensusType) - configEnvelope = common_dot_configuration_pb2.ConfigurationEnvelope(Items=configItems) + # (fileName, fileExist) = ContextHelper.GetHelper(context=context).getTmpPathForName(name="t",extension="protobuf") + # with open(fileName, 'w') as f: + # f.write(channelConfig.SerializeToString()) - envelope = createConfigTxEnvelope(chainId, configEnvelope) - - blockData = common_dot_common_pb2.BlockData(Data=[envelope.SerializeToString()]) + config = common_dot_configtx_pb2.Config( + header=common_dot_common_pb2.ChannelHeader(channel_id=chainId, + type=common_dot_common_pb2.HeaderType.Value("CONFIG")), + channel=channelConfig) + configEnvelope = common_dot_configtx_pb2.ConfigEnvelope(config=config) + envelope = createConfigTxEnvelope(chainId=chainId, config_envelope=configEnvelope) + blockData = common_dot_common_pb2.BlockData(data=[envelope.SerializeToString()]) # Spoke with kostas, for orderer in general signaturesMetadata = "" - lastConfigurationBlockMetadata = common_dot_common_pb2.Metadata(value=common_dot_common_pb2.LastConfiguration(index=0).SerializeToString()).SerializeToString() + lastConfigurationBlockMetadata = common_dot_common_pb2.Metadata( + value=common_dot_common_pb2.LastConfig(index=0).SerializeToString()).SerializeToString() ordererConfigMetadata = "" transactionFilterMetadata = "" + bootstrapHelper = BootstrapHelper(chainId="NOT_USED") block = common_dot_common_pb2.Block( - Header=common_dot_common_pb2.BlockHeader( - Number=0, - PreviousHash=None, - DataHash=bootstrapHelper.computeBlockDataHash(blockData), + header=common_dot_common_pb2.BlockHeader( + number=0, + previous_hash=None, + data_hash=bootstrapHelper.computeBlockDataHash(blockData), ), - Data=blockData, - Metadata=common_dot_common_pb2.BlockMetadata(Metadata=[signaturesMetadata,lastConfigurationBlockMetadata,transactionFilterMetadata, ordererConfigMetadata]), + data=blockData, + metadata=common_dot_common_pb2.BlockMetadata( + metadata=[signaturesMetadata, lastConfigurationBlockMetadata, transactionFilterMetadata, + ordererConfigMetadata]), ) # Add this back once crypto certs are required @@ -684,20 +769,67 @@ def createGenesisBlock(context, chainId, consensusType, signedConfigItems = []): return (block, envelope) + class PathType(Enum): 'Denotes whether Path relative to Local filesystem or Containers volume reference.' Local = 1 Container = 2 -class OrdererGensisBlockCompositionCallback(compose.CompositionCallback): +class CallbackHelper: + def __init__(self, discriminator, volumeRootPathInContainer = "/var/hyperledger/bddtests"): + self.volumeRootPathInContainer = volumeRootPathInContainer + self.discriminator = discriminator + + def getVolumePath(self, composition, pathType=PathType.Local): + assert pathType in PathType, "Expected pathType of {0}".format(PathType) + basePath = "." + if pathType == PathType.Container: + basePath = self.volumeRootPathInContainer + return "{0}/volumes/{1}/{2}".format(basePath, self.discriminator, composition.projectName) + + def getLocalMspConfigPath(self, composition, compose_service, pathType=PathType.Local): + return "{0}/{1}/localMspConfig".format(self.getVolumePath(composition, pathType), compose_service) + + def _writeMspFiles(self, directory , composition, compose_service, network): + localMspConfigPath = self.getLocalMspConfigPath(composition, compose_service=compose_service) + os.makedirs("{0}/{1}".format(localMspConfigPath, "signcerts")) + os.makedirs("{0}/{1}".format(localMspConfigPath, "admincerts")) + os.makedirs("{0}/{1}".format(localMspConfigPath, "cacerts")) + os.makedirs("{0}/{1}".format(localMspConfigPath, "keystore")) + # Loop through directory and place Organization Certs into cacerts folder + for targetOrg in [org for orgName, org in directory.organizations.items() if network in org.networks]: + with open("{0}/cacerts/{1}.pem".format(localMspConfigPath, targetOrg.name), "w") as f: + f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, targetOrg.getSelfSignedCert())) + + # Loop through directory and place Organization Certs into admincerts folder + # TODO: revisit this, ASO recommended for now + for targetOrg in [org for orgName, org in directory.organizations.items() if network in org.networks]: + with open("{0}/admincerts/{1}.pem".format(localMspConfigPath, targetOrg.name), "w") as f: + f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, targetOrg.getSelfSignedCert())) + + # Find the peer signer Tuple for this peer and add to signcerts folder + for pnt, cert in [(peerNodeTuple, cert) for peerNodeTuple, cert in directory.ordererAdminTuples.items() if + compose_service in peerNodeTuple.user and "signer" in peerNodeTuple.user.lower()]: + # Put the PEM file in the signcerts folder + with open("{0}/signcerts/{1}.pem".format(localMspConfigPath, pnt.user), "w") as f: + f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert)) + # Put the associated private key into the keystore folder + user = directory.getUser(pnt.user, shouldCreate=False) + with open("{0}/keystore/{1}.pem".format(localMspConfigPath, pnt.user), "w") as f: + f.write(user.ecdsaSigningKey.to_pem()) + # f.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, user.pKey)) + + +class OrdererGensisBlockCompositionCallback(compose.CompositionCallback, CallbackHelper): 'Responsible for setting the GensisBlock for the Orderer nodes upon composition' - def __init__(self, context, genesisBlock, genesisFileName = "genesis_file"): + def __init__(self, context, genesisBlock, genesisFileName="genesis_file"): + CallbackHelper.__init__(self, discriminator="orderer") self.context = context self.genesisFileName = genesisFileName self.genesisBlock = genesisBlock - self.volumeRootPathInContainer="/var/hyperledger/bddtests" + self.volumeRootPathInContainer = "/var/hyperledger/bddtests" compose.Composition.RegisterCallbackInContext(context, self) def getVolumePath(self, composition, pathType=PathType.Local): @@ -710,19 +842,32 @@ def getVolumePath(self, composition, pathType=PathType.Local): def getGenesisFilePath(self, composition, pathType=PathType.Local): return "{0}/{1}".format(self.getVolumePath(composition, pathType), self.genesisFileName) + def getOrdererList(self, composition): + return [serviceName for serviceName in composition.getServiceNames() if "orderer" in serviceName] + def composing(self, composition, context): print("Will copy gensisiBlock over at this point ") os.makedirs(self.getVolumePath(composition)) with open(self.getGenesisFilePath(composition), "wb") as f: f.write(self.genesisBlock.SerializeToString()) + directory = getDirectory(context) + + for ordererService in self.getOrdererList(composition): + self._writeMspFiles(directory=directory, + compose_service=ordererService, + composition=composition, + network=Network.Orderer) def decomposing(self, composition, context): 'Will remove the orderer volume path folder for the context' shutil.rmtree(self.getVolumePath(composition)) def getEnv(self, composition, context, env): - env["ORDERER_GENERAL_GENESISMETHOD"]="file" - env["ORDERER_GENERAL_GENESISFILE"]=self.getGenesisFilePath(composition, pathType=PathType.Container) + env["ORDERER_GENERAL_GENESISMETHOD"] = "file" + env["ORDERER_GENERAL_GENESISFILE"] = self.getGenesisFilePath(composition, pathType=PathType.Container) + for ordererService in self.getOrdererList(composition): + localMspConfigPath = self.getLocalMspConfigPath(composition, ordererService, pathType=PathType.Container) + env["{0}_ORDERER_GENERAL_LOCALMSPDIR".format(ordererService.upper())] = localMspConfigPath class PeerCompositionCallback(compose.CompositionCallback): @@ -730,7 +875,7 @@ class PeerCompositionCallback(compose.CompositionCallback): def __init__(self, context): self.context = context - self.volumeRootPathInContainer="/var/hyperledger/bddtests" + self.volumeRootPathInContainer = "/var/hyperledger/bddtests" compose.Composition.RegisterCallbackInContext(context, self) def getVolumePath(self, composition, pathType=PathType.Local): @@ -752,7 +897,6 @@ def _createLocalMspConfigDirs(self, mspConfigPath): os.makedirs("{0}/{1}".format(mspConfigPath, "cacerts")) os.makedirs("{0}/{1}".format(mspConfigPath, "keystore")) - def composing(self, composition, context): 'Will copy local MSP info over at this point for each peer node' @@ -762,18 +906,19 @@ def composing(self, composition, context): localMspConfigPath = self.getLocalMspConfigPath(composition, peerService) self._createLocalMspConfigDirs(localMspConfigPath) # Loop through directory and place Peer Organization Certs into cacerts folder - for peerOrg in [org for orgName,org in directory.organizations.items() if Network.Peer in org.networks]: + for peerOrg in [org for orgName, org in directory.organizations.items() if Network.Peer in org.networks]: with open("{0}/cacerts/{1}.pem".format(localMspConfigPath, peerOrg.name), "w") as f: f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, peerOrg.getSelfSignedCert())) # Loop through directory and place Peer Organization Certs into admincerts folder - #TODO: revisit this, ASO recommended for now - for peerOrg in [org for orgName,org in directory.organizations.items() if Network.Peer in org.networks]: + # TODO: revisit this, ASO recommended for now + for peerOrg in [org for orgName, org in directory.organizations.items() if Network.Peer in org.networks]: with open("{0}/admincerts/{1}.pem".format(localMspConfigPath, peerOrg.name), "w") as f: f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, peerOrg.getSelfSignedCert())) # Find the peer signer Tuple for this peer and add to signcerts folder - for pnt, cert in [(peerNodeTuple,cert) for peerNodeTuple,cert in directory.ordererAdminTuples.items() if peerService in peerNodeTuple.user and "signer" in peerNodeTuple.user.lower()]: + for pnt, cert in [(peerNodeTuple, cert) for peerNodeTuple, cert in directory.ordererAdminTuples.items() if + peerService in peerNodeTuple.user and "signer" in peerNodeTuple.user.lower()]: # Put the PEM file in the signcerts folder with open("{0}/signcerts/{1}.pem".format(localMspConfigPath, pnt.user), "w") as f: f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert)) @@ -783,7 +928,6 @@ def composing(self, composition, context): f.write(user.ecdsaSigningKey.to_pem()) # f.write(crypto.dump_privatekey(crypto.FILETYPE_PEM, user.pKey)) - def decomposing(self, composition, context): 'Will remove the orderer volume path folder for the context' shutil.rmtree(self.getVolumePath(composition)) @@ -791,19 +935,21 @@ def decomposing(self, composition, context): def getEnv(self, composition, context, env): for peerService in self.getPeerList(composition): localMspConfigPath = self.getLocalMspConfigPath(composition, peerService, pathType=PathType.Container) - env["{0}_CORE_PEER_MSPCFGPATH".format(peerService.upper())]=localMspConfigPath + env["{0}_CORE_PEER_MSPCFGPATH".format(peerService.upper())] = localMspConfigPath + def createChainCreationPolicyNames(context, chainCreationPolicyNames, chaindId): - directory = getDirectory(context) - bootstrapHelper = BootstrapHelper(chainId = chaindId) - chainCreationPolicyNamesSignedConfigItem = bootstrapHelper.encodeChainCreators(ciValue = orderer_dot_configuration_pb2.ChainCreationPolicyNames(names=chainCreationPolicyNames).SerializeToString()) - return chainCreationPolicyNamesSignedConfigItem + channel = common_dot_configtx_pb2.ConfigGroup() + channel.groups[OrdererGroup].values[BootstrapHelper.KEY_CHAIN_CREATION_POLICY_NAMES].value = toValue( + orderer_dot_configuration_pb2.ChainCreationPolicyNames( + names=chainCreationPolicyNames)) + return channel def createChainCreatorsPolicy(context, chainCreatePolicyName, chaindId, orgNames): 'Creates the chain Creator Policy with name' directory = getDirectory(context) - bootstrapHelper = BootstrapHelper(chainId = chaindId) + bootstrapHelper = BootstrapHelper(chainId=chaindId) # This represents the domain of organization which can create channels for the orderer # First create org MSPPrincicpal @@ -811,21 +957,32 @@ def createChainCreatorsPolicy(context, chainCreatePolicyName, chaindId, orgNames # Collect the orgs from the table mspPrincipalList = [] for org in [directory.getOrganization(orgName) for orgName in orgNames]: - mspPrincipalList.append(msp_principal_pb2.MSPPrincipal(PrincipalClassification=msp_principal_pb2.MSPPrincipal.Classification.Value("ByIdentity"), + mspPrincipalList.append(msp_principal_pb2.MSPPrincipal( + PrincipalClassification=msp_principal_pb2.MSPPrincipal.Classification.Value("ByIdentity"), Principal=crypto.dump_certificate(crypto.FILETYPE_ASN1, org.getSelfSignedCert()))) - policyTypeSig = common_dot_configuration_pb2.Policy.PolicyType.Value("SIGNATURE") - chainCreatorsOrgsPolicySignedConfigItem = bootstrapHelper.encodePolicy(key=chainCreatePolicyName , policy=common_dot_configuration_pb2.Policy(type=policyTypeSig, policy=AuthDSLHelper.Envelope(signaturePolicy=AuthDSLHelper.NOutOf(0,[]), identities=mspPrincipalList).SerializeToString())) + policy = common_dot_policies_pb2.Policy( + type=common_dot_policies_pb2.Policy.PolicyType.Value("SIGNATURE"), + policy=AuthDSLHelper.Envelope( + signaturePolicy=AuthDSLHelper.NOutOf( + 0, []), + identities=mspPrincipalList).SerializeToString()) + channel = common_dot_configtx_pb2.ConfigGroup() + channel.policies[chainCreatePolicyName].policy.CopyFrom(policy) + # print("signed Config Item:\n{0}\n".format(chainCreationPolicyNamesSignedConfigItem)) - #print("chain Creation orgs signed Config Item:\n{0}\n".format(chainCreatorsOrgsPolicySignedConfigItem)) - return chainCreatorsOrgsPolicySignedConfigItem + # print("chain Creation orgs signed Config Item:\n{0}\n".format(chainCreatorsOrgsPolicySignedConfigItem)) + return channel + def setOrdererBootstrapGenesisBlock(genesisBlock): 'Responsible for setting the GensisBlock for the Orderer nodes upon composition' -def broadcastCreateChannelConfigTx(context, composeService, chainId, configTxEnvelope, user): +def broadcastCreateChannelConfigTx(context, composeService, chainId, configTxEnvelope, user): dataFunc = lambda x: configTxEnvelope - user.broadcastMessages(context=context,numMsgsToBroadcast=1,composeService=composeService, chainID=chainId ,dataFunc=dataFunc, chainHeaderType=common_dot_common_pb2.CONFIGURATION_TRANSACTION) + user.broadcastMessages(context=context, numMsgsToBroadcast=1, composeService=composeService, chainID=chainId, + dataFunc=dataFunc) + def getArgsFromContextForUser(context, userName): directory = getDirectory(context) @@ -834,7 +991,7 @@ def getArgsFromContextForUser(context, userName): if 'table' in context: if context.table: # There are function arguments - user = directory.getUser(context, userName) + user = directory.getUser(userName) # Allow the user to specify expressions referencing tags in the args list pattern = re.compile('\{(.*)\}$') for arg in context.table[0].cells: @@ -843,9 +1000,11 @@ def getArgsFromContextForUser(context, userName): # tagName reference found in args list tagName = m.groups()[0] # make sure the tagName is found in the users tags - assert tagName in user.tags, "TagName '{0}' not found for user '{1}'".format(tagName, user.getUserName()) + assert tagName in user.tags, "TagName '{0}' not found for user '{1}'".format(tagName, + user.getUserName()) args.append(user.tags[tagName]) else: - #No tag referenced, pass the arg + # No tag referenced, pass the arg args.append(arg) return args + diff --git a/bddtests/steps/compose.py b/bddtests/steps/compose.py index 66279eff4bf..02f1d2999de 100644 --- a/bddtests/steps/compose.py +++ b/bddtests/steps/compose.py @@ -16,6 +16,7 @@ import os import uuid import bdd_test_util +from contexthelper import ContextHelper import peer_basic_impl import json @@ -63,7 +64,10 @@ def GetCompositionCallbacksFromContext(cls, context): def GetUUID(cls): return GetDockerSafeUUID() - def __init__(self, context, composeFilesYaml, projectName = GetDockerSafeUUID()): + def __init__(self, context, composeFilesYaml, projectName = None): + self.contextHelper = ContextHelper.GetHelper(context=context) + if not projectName: + projectName = self.contextHelper.getGuuid() self.projectName = projectName self.context = context self.containerDataList = [] @@ -88,23 +92,40 @@ def parseComposeFilesArg(self, composeFileArgs): def getFileArgs(self): return self.parseComposeFilesArg(self.composeFilesYaml) - def getEnv(self): - myEnv = os.environ.copy() + def getEnvAdditions(self): + myEnv = {} myEnv["COMPOSE_PROJECT_NAME"] = self.projectName myEnv["CORE_PEER_NETWORKID"] = self.projectName # Invoke callbacks [callback.getEnv(self, self.context, myEnv) for callback in Composition.GetCompositionCallbacksFromContext(self.context)] return myEnv + def getEnv(self): + myEnv = os.environ.copy() + for key,value in self.getEnvAdditions().iteritems(): + myEnv[key] = value + # myEnv["COMPOSE_PROJECT_NAME"] = self.projectName + # myEnv["CORE_PEER_NETWORKID"] = self.projectName + # # Invoke callbacks + # [callback.getEnv(self, self.context, myEnv) for callback in Composition.GetCompositionCallbacksFromContext(self.context)] + return myEnv + + def getConfig(self): + return self.issueCommand(["config"]) + def refreshContainerIDs(self): containers = self.issueCommand(["ps", "-q"]).split() return containers + def _callCLI(self, argList, expect_success, env): + return bdd_test_util.cli_call(argList, expect_success=expect_success, env=env) def issueCommand(self, args): cmdArgs = self.getFileArgs()+ args + # output, error, returncode = \ + # bdd_test_util.cli_call(["docker-compose"] + cmdArgs, expect_success=True, env=self.getEnv()) output, error, returncode = \ - bdd_test_util.cli_call(["docker-compose"] + cmdArgs, expect_success=True, env=self.getEnv()) + self._callCLI(["docker-compose"] + cmdArgs, expect_success=True, env=self.getEnv()) # Don't rebuild if ps command if args[0] !="ps" and args[0] !="config": self.rebuildContainerData() diff --git a/bddtests/steps/contexthelper.py b/bddtests/steps/contexthelper.py new file mode 100644 index 00000000000..006ef13889d --- /dev/null +++ b/bddtests/steps/contexthelper.py @@ -0,0 +1,86 @@ + +import uuid +import os +import shutil +from slugify import slugify + +class ContextHelper: + + @classmethod + def GetHelper(cls, context): + if not "contextHelper" in context: + context.contextHelper = ContextHelper(context) + return context.contextHelper + + def __init__(self, context): + self.context = context + self.guuid = str(uuid.uuid1()).replace('-','') + + def getBootrapHelper(self, chainId): + import bootstrap_util + return bootstrap_util.BootstrapHelper(chainId=chainId) + + def getGuuid(self): + return self.guuid + + def getTmpPath(self): + pathToReturn = "tmp" + if not os.path.isdir(pathToReturn): + os.makedirs(pathToReturn) + return pathToReturn + + def getCachePath(self): + pathToReturn = os.path.join(self.getTmpPath(), "cache") + if not os.path.isdir(pathToReturn): + os.makedirs(pathToReturn) + return pathToReturn + + + def getTmpProjectPath(self): + pathToReturn = os.path.join(self.getTmpPath(), self.guuid) + if not os.path.isdir(pathToReturn): + os.makedirs(pathToReturn) + return pathToReturn + + def getTmpPathForName(self, name, extension=None, copyFromCache=False): + 'Returns the tmp path for a file, and a flag indicating if the file exists. Will also check in the cache and copy to tmp if copyFromCache==True' + slugifiedName = ".".join([slugify(name), extension]) if extension else slugify(name) + tmpPath = os.path.join(self.getTmpProjectPath(), slugifiedName) + fileExists = False + if os.path.isfile(tmpPath): + # file already exists in tmp path, return path and exists flag + fileExists = True + elif copyFromCache: + # See if the file exists in cache, and copy over to project folder. + cacheFilePath = os.path.join(self.getCachePath(), slugifiedName) + if os.path.isfile(cacheFilePath): + shutil.copy(cacheFilePath, tmpPath) + fileExists = True + return (tmpPath, fileExists) + + def copyToCache(self, name): + srcPath, fileExists = self.getTmpPathForName(name, copyFromCache=False) + assert fileExists, "Tried to copy source file to cache, but file not found for: {0}".format(srcPath) + # Now copy to the cache if it does not already exist + cacheFilePath = os.path.join(self.getCachePath(), slugify(name)) + if not os.path.isfile(cacheFilePath): + shutil.copy(srcPath, cacheFilePath) + + + def isConfigEnabled(self, configName): + return self.context.config.userdata.get(configName, "false") == "true" + + def before_scenario(self, scenario): + print("before_scenario: {0}".format(self)) + + def after_scenario(self, scenario): + print("after_scenario: {0}".format(self)) + + + def before_step(self, step): + print("before_step: {0}".format(self)) + print("") + + def registerComposition(self, composition): + return composition + diff --git a/bddtests/steps/docgen.py b/bddtests/steps/docgen.py new file mode 100644 index 00000000000..2b29f8f4464 --- /dev/null +++ b/bddtests/steps/docgen.py @@ -0,0 +1,248 @@ + +from StringIO import StringIO +from itertools import chain +from google.protobuf.message import Message + +from b3j0f.aop import weave, unweave, is_intercepted, weave_on + +from jinja2 import Environment, PackageLoader, select_autoescape, FileSystemLoader, Template +env = Environment( + loader=FileSystemLoader(searchpath="templates"), + autoescape=select_autoescape(['html', 'xml']), + trim_blocks=True, + lstrip_blocks=True +) + +from bootstrap_util import getDirectory +from compose import Composition + +class DocumentGenerator: + + + def __init__(self, contextHelper, scenario): + self.contextHelper = contextHelper + self.directory = getDirectory(contextHelper.context) + self.output = StringIO() + self.currentStep = 0 + self.composition = None + + #Weave advices into contextHelper + weave(target=self.contextHelper.before_step, advices=self.stepAdvice) + weave(target=self.contextHelper.after_scenario, advices=self.afterScenarioAdvice) + weave(target=self.contextHelper.getBootrapHelper, advices=self.getBootstrapHelperAdvice) + + + weave(target=Composition.__init__, advices=self.registerCompositionAdvice) + + # Weave advices into Directory + weave(target=self.directory._registerOrg, advices=self.registerOrgAdvice) + weave(target=self.directory._registerUser, advices=self.registerUserAdvice) + weave(target=self.directory.registerOrdererAdminTuple, advices=self.registerNamedNodeAdminTupleAdvice) + + def stepAdvice(self, joinpoint): + self.currentStep += 1 + step = joinpoint.kwargs['step'] + # Now the jinja template + self.output.write(env.get_template("html/step.html").render(step_id="Step {0}".format(self.currentStep), step=step)) + return joinpoint.proceed() + + def compositionCallCLIAdvice(self, joinpoint): + 'This advice is called around the compositions usage of the cli' + result = joinpoint.proceed() + # Create table for environment + composition = joinpoint.kwargs['self'] + envAdditions = composition.getEnvAdditions() + keys = envAdditions.keys() + keys.sort() + envPreamble = " ".join(["{0}={1}".format(key,envAdditions[key]) for key in keys]) + args= " ".join(joinpoint.kwargs['argList']) + self.output.write(env.get_template("html/cli.html").render(command="{0} {1}".format(envPreamble, args))) + return result + + def _getNetworkGroup(self, serviceName): + groups = {"peer" : 1, "orderer" : 2} + groupId = 0 + for group, id in groups.iteritems(): + if serviceName.lower().startswith(group): + groupId = id + return groupId + + def _getNetworkForConfig(self, configAsYaml): + import yaml + config = yaml.load(configAsYaml) + assert "services" in config, "Expected config from docker-compose config to have services key at top level: \n{0}".format(config) + network = {"nodes": [], "links" : []} + for serviceName in config['services'].keys(): + network['nodes'].append({"id" : serviceName, "group" : self._getNetworkGroup(serviceName), "type" : "node"}) + # Now get links + if "depends_on" in config['services'][serviceName]: + for dependedOnServiceName in config['services'][serviceName]['depends_on']: + network['links'].append({"source": serviceName, "target": dependedOnServiceName, "value" : 1}) + return network + + def _getNetworkForDirectory(self): + network = {"nodes":[], "links": []} + for orgName, org in self.directory.getOrganizations().iteritems(): + network['nodes'].append({"id" : orgName, "group" : 3, "type" : "org"}) + for userName, user in self.directory.getUsers().iteritems(): + network['nodes'].append({"id" : userName, "group" : 4, "type" : "user"}) + # Now get links + for nct, cert in self.directory.getNamedCtxTuples().iteritems(): + nctId = "{0}-{1}-{2}".format(nct.user, nct.nodeName, nct.organization) + network['nodes'].append({"id" : nctId, "group" : 5, "type" : "cert"}) + network['links'].append({"source": nctId, "target": nct.organization, "value" : 1}) + network['links'].append({"source": nctId, "target": nct.user, "value" : 1}) + # Only add the context link if it is a compose service, else the target may not exist. + if nct.nodeName in self.composition.getServiceNames(): + network['links'].append({"source": nctId, "target": nct.nodeName, "value" : 1}) + return network + + def _writeNetworkJson(self): + if self.composition: + import json + configNetwork = self._getNetworkForConfig(configAsYaml=self.composition.getConfig()) + directoryNetwork = self._getNetworkForDirectory() + # Join the network info together + fullNetwork = dict(chain([(key, configNetwork[key] + directoryNetwork[key]) for key in configNetwork.keys()])) + (fileName, fileExists) = self.contextHelper.getTmpPathForName("network", extension="json") + with open(fileName, "w") as f: + f.write(json.dumps(fullNetwork)) + + + def registerCompositionAdvice(self, joinpoint): + composition = None + if joinpoint.kwargs['context'] == self.contextHelper.context: + # This is our context, weave into issue_command + composition = joinpoint.kwargs['self'] + weave(target=composition._callCLI, advices=self.compositionCallCLIAdvice) + result = joinpoint.proceed() + if composition: + #Now get the config for the composition and dump out. + self.composition = composition + configAsYaml = composition.getConfig() + self.output.write(env.get_template("html/header.html").render(text="Configuration", level=4)) + self.output.write(env.get_template("html/cli.html").render(command=configAsYaml)) + #Inject the graph + self.output.write(env.get_template("html/header.html").render(text="Network Graph", level=4)) + self.output.write(env.get_template("html/graph.html").render()) + return result + + def _addLinkToFile(self, fileName ,linkText): + import ntpath + baseName = ntpath.basename(fileName) + # self.markdownWriter.addLink(linkUrl="./{0}".format(baseName), linkText=linkText, linkTitle=baseName) + + def _getLinkInfoForFile(self, fileName): + import ntpath + return "./{0}".format(ntpath.basename(fileName)) + + def registerOrgAdvice(self, joinpoint): + orgName = joinpoint.kwargs['orgName'] + newlyRegisteredOrg = joinpoint.proceed() + orgCert = newlyRegisteredOrg.getCertAsPEM() + #Write out key material + (fileName, fileExists) = self.contextHelper.getTmpPathForName(name="dir-org-{0}-cert".format(orgName), extension="pem") + with open(fileName, 'w') as f: + f.write(orgCert) + self._addLinkToFile(fileName=fileName, linkText="Public cert for Organization") + #Now the jinja output + self.output.write(env.get_template("html/org.html").render(org=newlyRegisteredOrg, cert_href=self._getLinkInfoForFile(fileName))) + return newlyRegisteredOrg + + def registerUserAdvice(self, joinpoint): + userName = joinpoint.kwargs['userName'] + newlyRegisteredUser = joinpoint.proceed() + #Write out key material + privateKeyAsPem = newlyRegisteredUser.getPrivateKeyAsPEM() + (fileName, fileExists) = self.contextHelper.getTmpPathForName(name="dir-user-{0}-privatekey".format(userName), extension="pem") + with open(fileName, 'w') as f: + f.write(privateKeyAsPem) + #Weave into user tags setting + weave(target=newlyRegisteredUser.setTagValue, advices=self.userSetTagValueAdvice) + #Now the jinja output + self.output.write(env.get_template("html/user.html").render(user=newlyRegisteredUser, private_key_href=self._getLinkInfoForFile(fileName))) + return newlyRegisteredUser + + def afterScenarioAdvice(self, joinpoint): + scenario = joinpoint.kwargs['scenario'] + #Render with jinja + header = env.get_template("html/scenario.html").render(scenario=scenario, steps=scenario.steps) + main = env.get_template("html/main.html").render(header=header, body=self.output.getvalue()) + (fileName, fileExists) = self.contextHelper.getTmpPathForName("scenario", extension="html") + with open(fileName, 'w') as f: + f.write(main) + self._writeNetworkJson() + return joinpoint.proceed() + + def registerNamedNodeAdminTupleAdvice(self, joinpoint): + namedNodeAdminTuple = joinpoint.proceed() + directory = joinpoint.kwargs['self'] + #jinja + newCertAsPEM = directory.getCertAsPEM(namedNodeAdminTuple) + self.output.write(env.get_template("html/header.html").render(text="Created new named node admin tuple: {0}".format(namedNodeAdminTuple), level=4)) + self.output.write(env.get_template("html/cli.html").render(command=newCertAsPEM)) + #Write cert out + fileNameTocheck = "dir-user-{0}-cert-{1}-{2}".format(namedNodeAdminTuple.user, namedNodeAdminTuple.nodeName, namedNodeAdminTuple.organization) + (fileName, fileExists) = self.contextHelper.getTmpPathForName(fileNameTocheck, extension="pem") + with open(fileName, 'w') as f: + f.write(newCertAsPEM) + return namedNodeAdminTuple + + def bootstrapHelperSignConfigItemAdvice(self, joinpoint): + configItem = joinpoint.kwargs['configItem'] + #jinja + self.output.write(env.get_template("html/header.html").render(text="Dumping signed config item...", level=4)) + self.output.write(env.get_template("html/protobuf.html").render(msg=configItem, msgLength=len(str(configItem)))) + + signedConfigItem = joinpoint.proceed() + return signedConfigItem + + def getBootstrapHelperAdvice(self, joinpoint): + bootstrapHelper = joinpoint.proceed() + weave(target=bootstrapHelper.signConfigItem, advices=self.bootstrapHelperSignConfigItemAdvice) + return bootstrapHelper + + def _isProtobufMessage(self, target): + return isinstance(target, Message) + + def _isListOfProtobufMessages(self, target): + result = False + if isinstance(target, list): + messageList = [item for item in target if self._isProtobufMessage(item)] + result = len(messageList) == len(target) + return result + + def _writeProtobuf(self, fileName, msg): + import ntpath + baseName = ntpath.basename(fileName) + dataToWrite = msg.SerializeToString() + with open("{0}".format(fileName), 'wb') as f: + f.write(dataToWrite) + self.output.write(env.get_template("html/protobuf.html").render(id=baseName, msg=msg, path_to_protobuf=fileName, msgLength=len(dataToWrite),linkUrl="./{0}".format(baseName), linkText="Protobuf message in binary form", linkTitle=baseName)) + + + def userSetTagValueAdvice(self, joinpoint): + result = joinpoint.proceed() + user = joinpoint.kwargs['self'] + tagKey = joinpoint.kwargs['tagKey'] + tagValue = joinpoint.kwargs['tagValue'] + + #jinja invoke + self.output.write(env.get_template("html/tag.html").render(user=user, tag_key=tagKey)) + + # If protobuf message, write out in binary form + if self._isProtobufMessage(tagValue): + import ntpath + (fileName, fileExists) = self.contextHelper.getTmpPathForName("{0}-{1}".format(user.getUserName(), tagKey), extension="protobuf") + self._writeProtobuf(fileName=fileName, msg=tagValue) + # If protobuf message, write out in binary form + elif self._isListOfProtobufMessages(tagValue): + import ntpath + index = 0 + for msg in tagValue: + (fileName, fileExists) = self.contextHelper.getTmpPathForName("{0}-{1}-{2:0>4}".format(user.getUserName(), tagKey, index), extension="protobuf") + self._writeProtobuf(fileName=fileName, msg=msg) + index += 1 + else: + self.output.write(env.get_template("html/cli.html").render(command=str(tagValue))) + return result \ No newline at end of file diff --git a/bddtests/steps/endorser_impl.py b/bddtests/steps/endorser_impl.py index 331270623b4..529542a4359 100644 --- a/bddtests/steps/endorser_impl.py +++ b/bddtests/steps/endorser_impl.py @@ -27,7 +27,7 @@ def step_impl(context, userName, ccType, chaincodeName, chaincodePath, ccSpecAli args = bootstrap_util.getArgsFromContextForUser(context, userName) ccSpec = endorser_util.getChaincodeSpec(ccType=ccType, path=chaincodePath, name=chaincodeName, args=bdd_grpc_util.toStringArray(args)) print("ccSpec = {0}".format(ccSpec)) - user.tags[ccSpecAlias] = ccSpec + user.setTagValue(ccSpecAlias, ccSpec) @when(u'user "{userName}" creates a deployment spec "{ccDeploymentSpecAlias}" using chaincode spec "{ccSpecAlias}" and devops on peer "{devopsComposeService}"') @@ -40,7 +40,8 @@ def step_impl(context, userName, ccDeploymentSpecAlias, ccSpecAlias, devopsCompo channel = bdd_grpc_util.getGRPCChannel(ipAddress) devopsStub = devops_pb2.beta_create_Devops_stub(channel) deploymentSpec = devopsStub.Build(user.tags[ccSpecAlias],20) - user.tags[ccDeploymentSpecAlias] = deploymentSpec + #user.setTagValue(ccDeploymentSpecAlias, deploymentSpec) + user.setTagValue(ccDeploymentSpecAlias, deploymentSpec) @when(u'user "{userName}" using cert alias "{certAlias}" creates a deployment proposal "{proposalAlias}" for channel "{channelName}" using chaincode spec "{ccSpecAlias}"') @@ -58,13 +59,13 @@ def step_impl(context, userName, certAlias, proposalAlias, channelName, ccSpecAl signersCert = directory.findCertForNodeAdminTuple(nodeAdminTuple) mspID = nodeAdminTuple.organization - proposal = endorser_util.createInvokeProposalForBDD(ccSpec=lcChaincodeSpec, chainID=channelName,signersCert=signersCert, Mspid=mspID, type="ENDORSER_TRANSACTION") + proposal = endorser_util.createInvokeProposalForBDD(context, ccSpec=lcChaincodeSpec, chainID=channelName,signersCert=signersCert, Mspid=mspID, type="ENDORSER_TRANSACTION") signedProposal = endorser_util.signProposal(proposal=proposal, entity=user, signersCert=signersCert) # proposal = endorser_util.createDeploymentProposalForBDD(ccDeploymentSpec) assert not proposalAlias in user.tags, "Proposal alias '{0}' already exists for '{1}'".format(proposalAlias, userName) - user.tags[proposalAlias] = signedProposal + user.setTagValue(proposalAlias, signedProposal) @@ -82,6 +83,7 @@ def step_impl(context, userName, proposalAlias, timeout, proposalResponsesAlias) endorserStubs = endorser_util.getEndorserStubs(context, endorsers) proposalResponseFutures = [endorserStub.ProcessProposal.future(signedProposal, int(timeout)) for endorserStub in endorserStubs] resultsDict = dict(zip(endorsers, [respFuture.result() for respFuture in proposalResponseFutures])) + #user.setTagValue(proposalResponsesAlias, resultsDict) user.tags[proposalResponsesAlias] = resultsDict diff --git a/bddtests/steps/endorser_util.py b/bddtests/steps/endorser_util.py index 9a2061a2be6..3d37052422e 100644 --- a/bddtests/steps/endorser_util.py +++ b/bddtests/steps/endorser_util.py @@ -1,6 +1,7 @@ import os import json +from contexthelper import ContextHelper import bdd_test_util import bdd_grpc_util import bootstrap_util @@ -17,73 +18,66 @@ def getChaincodeSpec(ccType, path, name, args): # make chaincode spec for chaincode to be deployed ccSpec = chaincode_pb2.ChaincodeSpec(type=chaincode_pb2.ChaincodeSpec.Type.Value(ccType), - chaincodeID = chaincode_pb2.ChaincodeID(path=path, name=name), + chaincode_id = chaincode_pb2.ChaincodeID(path=path, name=name, version="test"), input = chaincode_pb2.ChaincodeInput(args = args)) return ccSpec def createPropsalId(): return 'TODO proposal Id' -def createInvokeProposalForBDD(ccSpec, chainID, signersCert, Mspid, type): - "Returns a deployment proposal of chaincode type" - lc_chaincode_invocation_spec = chaincode_pb2.ChaincodeInvocationSpec(chaincodeSpec = ccSpec) +def createInvokeProposalForBDD(context, ccSpec, chainID, signersCert, Mspid, type): + import binascii - # Create - ccHdrExt = chaincode_proposal_pb2.ChaincodeHeaderExtension(chaincodeID=ccSpec.chaincodeID) + "Returns a deployment proposal of chaincode type" + lc_chaincode_invocation_spec = chaincode_pb2.ChaincodeInvocationSpec(chaincode_spec = ccSpec) - ccProposalPayload = chaincode_proposal_pb2.ChaincodeProposalPayload(Input=lc_chaincode_invocation_spec.SerializeToString()) + # Create + ccHdrExt = proposal_pb2.ChaincodeHeaderExtension(chaincode_id=ccSpec.chaincode_id) - bootstrapHelper = bootstrap_util.BootstrapHelper(chainId=chainID) + ccProposalPayload = proposal_pb2.ChaincodeProposalPayload(input=lc_chaincode_invocation_spec.SerializeToString()) - chainHdr = bootstrapHelper.makeChainHeader(type=common_dot_common_pb2.HeaderType.Value(type), - txID=bootstrap_util.GetUUID(), extension=ccHdrExt.SerializeToString()) - serializedIdentity = identities_pb2.SerializedIdentity(Mspid=Mspid, IdBytes=crypto.dump_certificate(crypto.FILETYPE_PEM, signersCert)) + bootstrapHelper = ContextHelper.GetHelper(context=context).getBootrapHelper(chainId=chainID) + serializedIdentity = identities_pb2.SerializedIdentity(Mspid=Mspid, IdBytes=crypto.dump_certificate(crypto.FILETYPE_PEM, signersCert)) - sigHdr = bootstrapHelper.makeSignatureHeader(serializedIdentity.SerializeToString(), bootstrap_util.BootstrapHelper.getNonce()) + nonce = bootstrap_util.BootstrapHelper.getNonce() - header = common_dot_common_pb2.Header(chainHeader=chainHdr, signatureHeader=sigHdr) + sigHdr = bootstrapHelper.makeSignatureHeader(serializedIdentity.SerializeToString(), nonce) + + # Calculate the transaction ID + tx_id = binascii.hexlify(bootstrap_util.computeCryptoHash(nonce + serializedIdentity.SerializeToString())) - # make proposal - proposal = proposal_pb2.Proposal(header=header.SerializeToString(), payload=ccProposalPayload.SerializeToString()) + chainHdr = bootstrapHelper.makeChainHeader(type=common_dot_common_pb2.HeaderType.Value(type), + txID=tx_id, extension=ccHdrExt.SerializeToString()) + header = common_dot_common_pb2.Header(channel_header=chainHdr, signature_header=sigHdr) - return proposal + # make proposal + proposal = proposal_pb2.Proposal(header=header.SerializeToString(), payload=ccProposalPayload.SerializeToString()) + + + return proposal def signProposal(proposal, entity, signersCert): - import hashlib - from ecdsa import util - from ecdsa import VerifyingKey import binascii # Sign the proposal proposalBytes = proposal.SerializeToString() - #print("Proposal Bytes = \n{0}\n\n".format(binascii.hexlify(bytearray(proposalBytes)))) - - # calculate sha2_256 and dump for info only - digest = hashlib.sha256(proposalBytes).digest() - print("Proposal Bytes digest= \n{0}\n\n".format( binascii.hexlify(bytearray(digest)) )) signature = entity.sign(proposalBytes) - # signature = signingKey.sign(proposalBytes, hashfunc=hashlib.sha256, sigencode=util.sigencode_der) - #Verify the signature entity.verifySignature(signature=signature, signersCert=signersCert, data=proposalBytes) - # vk = VerifyingKey.from_der(crypto.dump_publickey(crypto.FILETYPE_ASN1, signersCert.get_pubkey())) - # assert vk.verify(signature, proposalBytes, hashfunc=hashlib.sha256, sigdecode=util.sigdecode_der), "Invalid signature!!" - - print("Proposal Bytes signature= \n{0}\n\n".format(binascii.hexlify(bytearray(signature)))) - print("") - - signedProposal = proposal_pb2.SignedProposal(proposalBytes=proposalBytes, signature=signature) + # print("Proposal Bytes signature= \n{0}\n\n".format(binascii.hexlify(bytearray(signature)))) + signedProposal = proposal_pb2.SignedProposal(proposal_bytes=proposalBytes, signature=signature) return signedProposal def createDeploymentChaincodeSpecForBDD(ccDeploymentSpec, chainID): - "Returns a deployment proposal of chaincode type" - lc_chaincode_spec = chaincode_pb2.ChaincodeSpec(type = chaincode_pb2.ChaincodeSpec.GOLANG, - chaincodeID = chaincode_pb2.ChaincodeID(name="lccc"), - input = chaincode_pb2.ChaincodeInput(args = ['deploy', chainID, ccDeploymentSpec.SerializeToString()])) - return lc_chaincode_spec + lc_chaincode_spec = getChaincodeSpec(ccType="GOLANG", path="", name="lccc", + args=['deploy', chainID, ccDeploymentSpec.SerializeToString()]) + # lc_chaincode_spec = chaincode_pb2.ChaincodeSpec(type = chaincode_pb2.ChaincodeSpec.GOLANG, + # chaincode_id = chaincode_pb2.ChaincodeID(name="lccc"), + # input = chaincode_pb2.ChaincodeInput(args = ['deploy', chainID, ccDeploymentSpec.SerializeToString()])) + return lc_chaincode_spec def getEndorserStubs(context, composeServices): stubs = [] @@ -103,18 +97,20 @@ def _createDeploymentSpecAsFile(ccSpec, outputPath): '''peer chaincode package -n myCC -c '{"Args":["init","a","100","b","200"]}' -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 --logging-level=DEBUG test.file''' myEnv = os.environ.copy() myEnv['CORE_PEER_MSPCONFIGPATH'] = "./../msp/sampleConfig" - nameArgs = ["-n", ccSpec.chaincodeID.name] + nameArgs = ["-n", ccSpec.chaincode_id.name] ctorArgs = ["-c", json.dumps({'Args' : [item for item in ccSpec.input.args]})] - pathArgs = ["-p", ccSpec.chaincodeID.path] + pathArgs = ["-p", ccSpec.chaincode_id.path] + versionArgs = ["-v", ccSpec.chaincode_id.version] output, error, returncode = \ - bdd_test_util.cli_call(["peer","chaincode","package"] + nameArgs + ctorArgs + pathArgs + [outputPath], expect_success=True, env=myEnv) + bdd_test_util.cli_call(["peer","chaincode","package"] + nameArgs + ctorArgs + pathArgs + versionArgs + [outputPath], expect_success=True, env=myEnv) return output def createDeploymentSpec(context, ccSpec): - contextHelper = bootstrap_util.ContextHelper.GetHelper(context=context) + contextHelper = ContextHelper.GetHelper(context=context) + contextHelper.getBootrapHelper(chainId="test") cacheDeploymentSpec = contextHelper.isConfigEnabled("cache-deployment-spec") - fileName = "deploymentspec_{0}".format(ccSpec.chaincodeID.name) + fileName = "deploymentspec-{0}-{1}-{2}".format(chaincode_pb2.ChaincodeSpec.Type.Name(ccSpec.type), ccSpec.chaincode_id.path, ccSpec.chaincode_id.name) outputPath, fileExists = contextHelper.getTmpPathForName(name=fileName, copyFromCache=cacheDeploymentSpec) if not fileExists: diff --git a/bddtests/steps/orderer_util.py b/bddtests/steps/orderer_util.py index b1e58694650..797fbe7179e 100644 --- a/bddtests/steps/orderer_util.py +++ b/bddtests/steps/orderer_util.py @@ -160,9 +160,9 @@ def getDelivererStreamHelper(self, context, composeService): assert composeService in self.abDeliversStreamHelperDict, "NOT connected to deliver stream on {0}".format(composeService) return self.abDeliversStreamHelperDict[composeService] - def broadcastMessages(self, context, numMsgsToBroadcast, composeService, chainID=TEST_CHAIN_ID, dataFunc=_defaultDataFunction, chainHeaderType=common_pb2.ENDORSER_TRANSACTION): + def broadcastMessages(self, context, numMsgsToBroadcast, composeService, chainID=TEST_CHAIN_ID, dataFunc=_defaultDataFunction): abStub = self.getABStubForComposeService(context, composeService) - replyGenerator = abStub.Broadcast(generateBroadcastMessages(chainID=chainID, numToGenerate = int(numMsgsToBroadcast), dataFunc=dataFunc, chainHeaderType=chainHeaderType), 2) + replyGenerator = abStub.Broadcast(generateBroadcastMessages(chainID=chainID, numToGenerate = int(numMsgsToBroadcast), dataFunc=dataFunc), 2) counter = 0 try: for reply in replyGenerator: @@ -230,8 +230,8 @@ def createSeekInfo(chainID = TEST_CHAIN_ID, start = 'Oldest', end = 'Newest', b return common_pb2.Envelope( payload = common_pb2.Payload( header = common_pb2.Header( - chainHeader = common_pb2.ChainHeader( chainID = chainID ), - signatureHeader = common_pb2.SignatureHeader(), + channel_header = common_pb2.ChannelHeader( channel_id = chainID ), + signature_header = common_pb2.SignatureHeader(), ), data = ab_pb2.SeekInfo( start = seekPosition(start), @@ -242,7 +242,7 @@ def createSeekInfo(chainID = TEST_CHAIN_ID, start = 'Oldest', end = 'Newest', b ) -def generateBroadcastMessages(chainID = TEST_CHAIN_ID, numToGenerate = 3, timeToHoldOpen = 1, dataFunc =_defaultDataFunction, chainHeaderType=common_pb2.ENDORSER_TRANSACTION ): +def generateBroadcastMessages(chainID = TEST_CHAIN_ID, numToGenerate = 3, timeToHoldOpen = 1, dataFunc =_defaultDataFunction): messages = [] for i in range(0, numToGenerate): messages.append(dataFunc(i)) diff --git a/bddtests/steps/peer_basic_impl.py b/bddtests/steps/peer_basic_impl.py index 374f753cad5..046df0dda21 100644 --- a/bddtests/steps/peer_basic_impl.py +++ b/bddtests/steps/peer_basic_impl.py @@ -70,7 +70,7 @@ def getDockerComposeFileArgsFromYamlFile(compose_yaml): @given(u'we compose "{composeYamlFile}"') def step_impl(context, composeYamlFile): # time.sleep(10) # Should be replaced with a definitive interlock guaranteeing that all peers/membersrvc are ready - composition = compose.Composition(context, composeYamlFile, projectName=bootstrap_util.ContextHelper.GetHelper(context=context).getGuuid()) + composition = compose.Composition(context, composeYamlFile) context.compose_containers = composition.containerDataList context.composition = composition diff --git a/bddtests/templates/html/cli.html b/bddtests/templates/html/cli.html new file mode 100644 index 00000000000..c027c2660c4 --- /dev/null +++ b/bddtests/templates/html/cli.html @@ -0,0 +1,5 @@ +
+ +{{ command }} + +
\ No newline at end of file diff --git a/bddtests/templates/html/graph.html b/bddtests/templates/html/graph.html new file mode 100644 index 00000000000..81a26ec2da5 --- /dev/null +++ b/bddtests/templates/html/graph.html @@ -0,0 +1,97 @@ + +
+ +
+ + \ No newline at end of file diff --git a/bddtests/templates/html/header.html b/bddtests/templates/html/header.html new file mode 100644 index 00000000000..30a235d4c61 --- /dev/null +++ b/bddtests/templates/html/header.html @@ -0,0 +1,3 @@ +
+ {{ text }} +
diff --git a/bddtests/templates/html/main.html b/bddtests/templates/html/main.html new file mode 100644 index 00000000000..68b91a2d788 --- /dev/null +++ b/bddtests/templates/html/main.html @@ -0,0 +1,22 @@ + + + + {% block head %} + + Scenario documentation + {% endblock %} + + +{% autoescape false %} +{{ header }} +{{ toc }} +{{ body }} +{{ appendix }} +{% endautoescape %} + + + \ No newline at end of file diff --git a/bddtests/templates/html/org.html b/bddtests/templates/html/org.html new file mode 100644 index 00000000000..b79f4f95201 --- /dev/null +++ b/bddtests/templates/html/org.html @@ -0,0 +1,4 @@ +
+

Created new organization {{ org.name }} with public cert

+ {{ org.getCertAsPEM() }} +
diff --git a/bddtests/templates/html/protobuf-py.html b/bddtests/templates/html/protobuf-py.html new file mode 100644 index 00000000000..e9f282c141a --- /dev/null +++ b/bddtests/templates/html/protobuf-py.html @@ -0,0 +1,17 @@ +
+ {% set msgClassModule = msg.__class__.__module__ %} + {% set msgClassName = msg.__class__.__name__ %} + {% set msgVarName = [msgClassName[0]|lower,msgClassName[1:]]|join('') %} +
+ +from {{ msgClassModule }} import {{ msgClassName }} +{{ msgVarName }} = {{ msgClassName }}() +data = None +with open('{{ path_to_protobuf }}') as f: + data = f.read() + +{{ msgVarName }}.ParseFromString(data) + + +
+
diff --git a/bddtests/templates/html/protobuf.html b/bddtests/templates/html/protobuf.html new file mode 100644 index 00000000000..001044f1a2a --- /dev/null +++ b/bddtests/templates/html/protobuf.html @@ -0,0 +1,22 @@ +
+ {% set maxLength = 10*1024 %} + {% if linkUrl %} + {{ linkText }} + {% endif %} + {% if msgLength < maxLength %} + {% set msgAsText = "%s"|format(msg) %} + {% set lines = msgAsText.split("\n") %} +
+ + {% for line in lines %} +{{ line }} + {% endfor %} + +
+ {% else %} + Not showing message, exceeded max lenth of {{ maxLength }} byes. + {% endif %} + {% if path_to_protobuf %} +{% include 'html/protobuf-py.html' %} + {% endif %} +
diff --git a/bddtests/templates/html/report.css b/bddtests/templates/html/report.css new file mode 100644 index 00000000000..57f313aef62 --- /dev/null +++ b/bddtests/templates/html/report.css @@ -0,0 +1,60 @@ +table { + border-collapse: collapse; +} + +table, th, td { + border: 1px solid black; +} + +tr:nth-child(even) {background-color: #f2f2f2} + +th, td { + padding: 8px; + text-align: left; +} + +ul { + padding: 20px; +} + +li { + padding: 2px; +} + +a:link { + text-decoration: none; + color: #1c7eba; +} + +a:visited { + color: #1c7eba; +} + +div { + padding: 2px; + width: 860px; + margin: auto; +} + +code { + white-space:pre +} + + .scrollBox { + #height: 100px; + border: 1px solid #ccc; + background: #f7f7f7; + overflow: auto; + padding: 10px + } + +/* +h1, h2, h3 { + color: #D7DADB +} + +body { + background-color: #3e4142; +} +*/ + diff --git a/bddtests/templates/html/scenario.html b/bddtests/templates/html/scenario.html new file mode 100644 index 00000000000..a37dbf05a48 --- /dev/null +++ b/bddtests/templates/html/scenario.html @@ -0,0 +1,13 @@ +
+

{{ scenario.name }}

+
+ +
diff --git a/bddtests/templates/html/step.html b/bddtests/templates/html/step.html new file mode 100644 index 00000000000..100d53981e5 --- /dev/null +++ b/bddtests/templates/html/step.html @@ -0,0 +1,21 @@ +
+

{{ step_id }}

+
+

{{ step.keyword }} {{ step.name }}

+ {% if step.table %} + + + {% for heading in step.table.headings %} + + {% endfor %} + + {% for row in step.table.rows %} + + {% for cell in row %} + + {% endfor %} + + {% endfor %} +
{{ heading }}
{{ cell }}
+ {% endif %} +
diff --git a/bddtests/templates/html/tag.html b/bddtests/templates/html/tag.html new file mode 100644 index 00000000000..8441407499c --- /dev/null +++ b/bddtests/templates/html/tag.html @@ -0,0 +1,3 @@ +
+

User {{ user.name }} setting tag key {{ tag_key }} to value

+
diff --git a/bddtests/templates/html/user.html b/bddtests/templates/html/user.html new file mode 100644 index 00000000000..f84dfeb6a35 --- /dev/null +++ b/bddtests/templates/html/user.html @@ -0,0 +1,4 @@ +
+

Created new user {{ user.name }} with private key

+ {{ user.getPrivateKeyAsPEM() }} +
diff --git a/common/cauthdsl/cauthdsl.go b/common/cauthdsl/cauthdsl.go index 17d30aaa694..a2c5df1e2b4 100644 --- a/common/cauthdsl/cauthdsl.go +++ b/common/cauthdsl/cauthdsl.go @@ -32,9 +32,9 @@ var cauthdslLogger = logging.MustGetLogger("cauthdsl") // compile recursively builds a go evaluatable function corresponding to the policy specified func compile(policy *cb.SignaturePolicy, identities []*cb.MSPPrincipal, deserializer msp.IdentityDeserializer) (func([]*cb.SignedData, []bool) bool, error) { switch t := policy.Type.(type) { - case *cb.SignaturePolicy_From: - policies := make([]func([]*cb.SignedData, []bool) bool, len(t.From.Policies)) - for i, policy := range t.From.Policies { + case *cb.SignaturePolicy_NOutOf_: + policies := make([]func([]*cb.SignedData, []bool) bool, len(t.NOutOf.Policies)) + for i, policy := range t.NOutOf.Policies { compiledPolicy, err := compile(policy, identities, deserializer) if err != nil { return nil, err @@ -54,13 +54,13 @@ func compile(policy *cb.SignaturePolicy, identities []*cb.MSPPrincipal, deserial } } - if verified >= t.From.N { + if verified >= t.NOutOf.N { cauthdslLogger.Debugf("Gate evaluation succeeds: (%s)", t) } else { cauthdslLogger.Debugf("Gate evaluation fails: (%s)", t) } - return verified >= t.From.N + return verified >= t.NOutOf.N }, nil case *cb.SignaturePolicy_SignedBy: if t.SignedBy < 0 || t.SignedBy >= int32(len(identities)) { diff --git a/common/cauthdsl/cauthdsl_builder.go b/common/cauthdsl/cauthdsl_builder.go index 83bf3f6ef25..6852e3323fc 100644 --- a/common/cauthdsl/cauthdsl_builder.go +++ b/common/cauthdsl/cauthdsl_builder.go @@ -123,8 +123,8 @@ func Or(lhs, rhs *cb.SignaturePolicy) *cb.SignaturePolicy { // NOutOf creates a policy which requires N out of the slice of policies to evaluate to true func NOutOf(n int32, policies []*cb.SignaturePolicy) *cb.SignaturePolicy { return &cb.SignaturePolicy{ - Type: &cb.SignaturePolicy_From{ - From: &cb.SignaturePolicy_NOutOf{ + Type: &cb.SignaturePolicy_NOutOf_{ + NOutOf: &cb.SignaturePolicy_NOutOf{ N: n, Policies: policies, }, diff --git a/protos/common/policies.pb.go b/protos/common/policies.pb.go index 15aeafc3c52..fd7b2eb9492 100644 --- a/protos/common/policies.pb.go +++ b/protos/common/policies.pb.go @@ -111,7 +111,7 @@ func (m *SignaturePolicyEnvelope) GetIdentities() []*MSPPrincipal { type SignaturePolicy struct { // Types that are valid to be assigned to Type: // *SignaturePolicy_SignedBy - // *SignaturePolicy_From + // *SignaturePolicy_NOutOf_ Type isSignaturePolicy_Type `protobuf_oneof:"Type"` } @@ -127,12 +127,12 @@ type isSignaturePolicy_Type interface { type SignaturePolicy_SignedBy struct { SignedBy int32 `protobuf:"varint,1,opt,name=signed_by,json=signedBy,oneof"` } -type SignaturePolicy_From struct { - From *SignaturePolicy_NOutOf `protobuf:"bytes,2,opt,name=from,oneof"` +type SignaturePolicy_NOutOf_ struct { + NOutOf *SignaturePolicy_NOutOf `protobuf:"bytes,2,opt,name=n_out_of,json=nOutOf,oneof"` } func (*SignaturePolicy_SignedBy) isSignaturePolicy_Type() {} -func (*SignaturePolicy_From) isSignaturePolicy_Type() {} +func (*SignaturePolicy_NOutOf_) isSignaturePolicy_Type() {} func (m *SignaturePolicy) GetType() isSignaturePolicy_Type { if m != nil { @@ -148,9 +148,9 @@ func (m *SignaturePolicy) GetSignedBy() int32 { return 0 } -func (m *SignaturePolicy) GetFrom() *SignaturePolicy_NOutOf { - if x, ok := m.GetType().(*SignaturePolicy_From); ok { - return x.From +func (m *SignaturePolicy) GetNOutOf() *SignaturePolicy_NOutOf { + if x, ok := m.GetType().(*SignaturePolicy_NOutOf_); ok { + return x.NOutOf } return nil } @@ -159,7 +159,7 @@ func (m *SignaturePolicy) GetFrom() *SignaturePolicy_NOutOf { func (*SignaturePolicy) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { return _SignaturePolicy_OneofMarshaler, _SignaturePolicy_OneofUnmarshaler, _SignaturePolicy_OneofSizer, []interface{}{ (*SignaturePolicy_SignedBy)(nil), - (*SignaturePolicy_From)(nil), + (*SignaturePolicy_NOutOf_)(nil), } } @@ -170,9 +170,9 @@ func _SignaturePolicy_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { case *SignaturePolicy_SignedBy: b.EncodeVarint(1<<3 | proto.WireVarint) b.EncodeVarint(uint64(x.SignedBy)) - case *SignaturePolicy_From: + case *SignaturePolicy_NOutOf_: b.EncodeVarint(2<<3 | proto.WireBytes) - if err := b.EncodeMessage(x.From); err != nil { + if err := b.EncodeMessage(x.NOutOf); err != nil { return err } case nil: @@ -192,13 +192,13 @@ func _SignaturePolicy_OneofUnmarshaler(msg proto.Message, tag, wire int, b *prot x, err := b.DecodeVarint() m.Type = &SignaturePolicy_SignedBy{int32(x)} return true, err - case 2: // Type.from + case 2: // Type.n_out_of if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } msg := new(SignaturePolicy_NOutOf) err := b.DecodeMessage(msg) - m.Type = &SignaturePolicy_From{msg} + m.Type = &SignaturePolicy_NOutOf_{msg} return true, err default: return false, nil @@ -212,8 +212,8 @@ func _SignaturePolicy_OneofSizer(msg proto.Message) (n int) { case *SignaturePolicy_SignedBy: n += proto.SizeVarint(1<<3 | proto.WireVarint) n += proto.SizeVarint(uint64(x.SignedBy)) - case *SignaturePolicy_From: - s := proto.Size(x.From) + case *SignaturePolicy_NOutOf_: + s := proto.Size(x.NOutOf) n += proto.SizeVarint(2<<3 | proto.WireBytes) n += proto.SizeVarint(uint64(s)) n += s @@ -272,34 +272,35 @@ func init() { func init() { proto.RegisterFile("common/policies.proto", fileDescriptor5) } var fileDescriptor5 = []byte{ - // 458 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x52, 0xdd, 0x8e, 0xd2, 0x40, - 0x14, 0x66, 0xa0, 0x16, 0x38, 0xb0, 0x5a, 0x27, 0xea, 0x36, 0x24, 0x2a, 0xe9, 0x85, 0x21, 0x31, - 0xb6, 0x09, 0xf8, 0x02, 0xa0, 0xc4, 0xad, 0x4b, 0x4b, 0x33, 0x74, 0x63, 0xd6, 0x1b, 0x42, 0x61, - 0x60, 0x27, 0xe9, 0x5f, 0xfa, 0xb3, 0x49, 0x7d, 0x0a, 0xaf, 0x7d, 0x15, 0x5f, 0xce, 0xcc, 0x4c, - 0xbb, 0xd1, 0x35, 0xdc, 0xcd, 0x39, 0xf3, 0x9d, 0xef, 0x67, 0xce, 0xc0, 0xcb, 0x7d, 0x12, 0x45, - 0x49, 0x6c, 0xa5, 0x49, 0xc8, 0xf6, 0x8c, 0xe6, 0x66, 0x9a, 0x25, 0x45, 0x82, 0x55, 0xd9, 0x1e, - 0x8d, 0xea, 0xeb, 0x28, 0x4f, 0xb7, 0x69, 0xc6, 0xe2, 0x3d, 0x4b, 0x77, 0xa1, 0xc4, 0x18, 0x3f, - 0x40, 0xf5, 0xf8, 0x54, 0x85, 0x31, 0x28, 0x45, 0x95, 0x52, 0x1d, 0x8d, 0xd1, 0xe4, 0x09, 0x11, - 0x67, 0xfc, 0x0a, 0x54, 0xc1, 0x59, 0xe9, 0xed, 0x31, 0x9a, 0x0c, 0x49, 0x5d, 0x19, 0x9f, 0x01, - 0xe4, 0x94, 0xcf, 0x51, 0x03, 0xe8, 0xde, 0xb8, 0xd7, 0xee, 0xfa, 0x9b, 0xab, 0xb5, 0xf0, 0x05, - 0xf4, 0x37, 0xf6, 0x17, 0x77, 0xee, 0xdf, 0x90, 0xa5, 0x86, 0x70, 0x17, 0x3a, 0xce, 0xc6, 0xd3, - 0xda, 0xf8, 0x39, 0x5c, 0xd8, 0x8e, 0xb7, 0xb2, 0x3f, 0xd9, 0xfe, 0xd6, 0x59, 0xfa, 0x73, 0xad, - 0x63, 0xfc, 0x42, 0x70, 0xb9, 0x61, 0xa7, 0x78, 0x57, 0x94, 0x19, 0x95, 0x7c, 0xcb, 0xf8, 0x9e, - 0x86, 0x49, 0x4a, 0xb1, 0x0e, 0xdd, 0x7b, 0x9a, 0xe5, 0x2c, 0x89, 0x6b, 0x43, 0x4d, 0x89, 0xad, - 0x7f, 0x3c, 0x0d, 0xa6, 0x97, 0xa6, 0x8c, 0x67, 0x3e, 0xa2, 0x6a, 0xcc, 0xe2, 0x8f, 0x00, 0xec, - 0x40, 0xe3, 0x82, 0x15, 0x8c, 0xe6, 0x7a, 0x67, 0xdc, 0x99, 0x0c, 0xa6, 0x2f, 0x9a, 0x21, 0x67, - 0xe3, 0x79, 0xcd, 0x93, 0x90, 0xbf, 0x70, 0xc6, 0x6f, 0x04, 0xcf, 0x1e, 0x31, 0xe2, 0xd7, 0xd0, - 0xcf, 0xd9, 0x29, 0xa6, 0x87, 0x6d, 0x50, 0x49, 0x5b, 0x57, 0x2d, 0xd2, 0x93, 0xad, 0x05, 0x17, - 0x52, 0x8e, 0x59, 0x12, 0xd5, 0xbe, 0xde, 0x9c, 0xf1, 0x65, 0xba, 0xeb, 0xb2, 0x58, 0x1f, 0xaf, - 0x5a, 0x44, 0xa0, 0x47, 0xd7, 0xa0, 0xca, 0x0e, 0x1e, 0x02, 0x72, 0xeb, 0xb4, 0xc8, 0xc5, 0x33, - 0xe8, 0x35, 0xfb, 0xd4, 0xdb, 0xc2, 0xf4, 0xd9, 0xa4, 0x0f, 0xc0, 0x85, 0x0a, 0x0a, 0x5f, 0x89, - 0xf1, 0x13, 0x01, 0xb6, 0xa3, 0x94, 0x77, 0x0b, 0x87, 0x16, 0xbb, 0x87, 0x00, 0x90, 0x97, 0xc1, - 0xb6, 0x7e, 0x3f, 0x2e, 0xd5, 0x27, 0xfd, 0xbc, 0x0c, 0xea, 0xeb, 0x19, 0x28, 0x59, 0x19, 0x52, - 0x11, 0xe0, 0xe9, 0xf4, 0x6d, 0x23, 0xf7, 0x3f, 0x91, 0x49, 0xca, 0x90, 0x12, 0x01, 0x36, 0xde, - 0x81, 0xc2, 0x2b, 0xbe, 0xe9, 0xb9, 0x7b, 0xab, 0xb5, 0xc4, 0x61, 0xb5, 0xd2, 0x10, 0x1e, 0x42, - 0xcf, 0x99, 0x7f, 0x5d, 0x13, 0xdb, 0xbf, 0xd5, 0xda, 0x8b, 0x0f, 0xdf, 0xdf, 0x9f, 0x58, 0x71, - 0x57, 0x06, 0x9c, 0xd6, 0xba, 0xab, 0x52, 0x9a, 0x85, 0xf4, 0x70, 0xa2, 0x99, 0x75, 0xdc, 0x05, - 0x19, 0xdb, 0x5b, 0xe2, 0x43, 0xe6, 0x96, 0x14, 0x0d, 0x54, 0x51, 0xce, 0xfe, 0x04, 0x00, 0x00, - 0xff, 0xff, 0x57, 0x5a, 0x88, 0x8a, 0xdc, 0x02, 0x00, 0x00, + // 466 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x52, 0x51, 0x8f, 0xd2, 0x40, + 0x10, 0x66, 0x01, 0x0b, 0x0c, 0x9c, 0xd6, 0x8d, 0x7a, 0x84, 0x44, 0x25, 0x7d, 0x30, 0x24, 0xc6, + 0x36, 0x01, 0x9f, 0x7c, 0x03, 0x25, 0x5e, 0x3d, 0x5a, 0x9a, 0xa5, 0x17, 0x73, 0xbe, 0x34, 0x14, + 0x16, 0x6e, 0x93, 0xd2, 0x6e, 0xda, 0xed, 0x25, 0xf5, 0x57, 0xf8, 0xec, 0xbf, 0xf1, 0x9f, 0x99, + 0xee, 0xb6, 0x17, 0xbd, 0xcb, 0xbd, 0xcd, 0xcc, 0x7e, 0xf3, 0xcd, 0xf7, 0xcd, 0x2c, 0xbc, 0xdc, + 0x25, 0xa7, 0x53, 0x12, 0x5b, 0x3c, 0x89, 0xd8, 0x8e, 0xd1, 0xcc, 0xe4, 0x69, 0x22, 0x12, 0xac, + 0xa9, 0xf2, 0x68, 0x54, 0x3d, 0x9f, 0x32, 0x1e, 0xf0, 0x94, 0xc5, 0x3b, 0xc6, 0xb7, 0x91, 0xc2, + 0x18, 0x3f, 0x41, 0xf3, 0xca, 0xae, 0x02, 0x63, 0x68, 0x8b, 0x82, 0xd3, 0x21, 0x1a, 0xa3, 0xc9, + 0x13, 0x22, 0x63, 0xfc, 0x0a, 0x34, 0xc9, 0x59, 0x0c, 0x9b, 0x63, 0x34, 0x19, 0x90, 0x2a, 0x33, + 0xbe, 0x00, 0xa8, 0x2e, 0xbf, 0x44, 0xf5, 0xa1, 0x73, 0xe5, 0x5e, 0xba, 0xeb, 0xef, 0xae, 0xde, + 0xc0, 0x67, 0xd0, 0xdb, 0xd8, 0x5f, 0xdd, 0xb9, 0x7f, 0x45, 0x96, 0x3a, 0xc2, 0x1d, 0x68, 0x39, + 0x1b, 0x4f, 0x6f, 0xe2, 0xe7, 0x70, 0x66, 0x3b, 0xde, 0xca, 0xfe, 0x6c, 0xfb, 0x81, 0xb3, 0xf4, + 0xe7, 0x7a, 0xcb, 0xf8, 0x8d, 0xe0, 0x7c, 0xc3, 0x8e, 0xf1, 0x56, 0xe4, 0x29, 0x55, 0x7c, 0xcb, + 0xf8, 0x96, 0x46, 0x09, 0xa7, 0x78, 0x08, 0x9d, 0x5b, 0x9a, 0x66, 0x2c, 0x89, 0x2b, 0x41, 0x75, + 0x8a, 0xad, 0xff, 0x34, 0xf5, 0xa7, 0xe7, 0xa6, 0xb2, 0x67, 0xde, 0xa3, 0xaa, 0xc5, 0xe2, 0x8f, + 0x00, 0x6c, 0x4f, 0x63, 0xc1, 0x04, 0xa3, 0xd9, 0xb0, 0x35, 0x6e, 0x4d, 0xfa, 0xd3, 0x17, 0x75, + 0x93, 0xb3, 0xf1, 0xbc, 0x7a, 0x25, 0xe4, 0x1f, 0x9c, 0xf1, 0x07, 0xc1, 0xb3, 0x7b, 0x8c, 0xf8, + 0x35, 0xf4, 0x32, 0x76, 0x8c, 0xe9, 0x3e, 0x08, 0x0b, 0x25, 0xeb, 0xa2, 0x41, 0xba, 0xaa, 0xb4, + 0x28, 0xf0, 0x27, 0xe8, 0xc6, 0x41, 0x92, 0x8b, 0x20, 0x39, 0x54, 0xda, 0xde, 0x3c, 0xa2, 0xcd, + 0x74, 0xd7, 0xb9, 0x58, 0x1f, 0x2e, 0x1a, 0x44, 0x8b, 0x65, 0x34, 0xba, 0x04, 0x4d, 0xd5, 0xf0, + 0x00, 0x90, 0x5b, 0x79, 0x46, 0x2e, 0x9e, 0x41, 0xb7, 0xbe, 0xea, 0xb0, 0x29, 0xa5, 0x3f, 0xea, + 0xf7, 0x0e, 0xb8, 0xd0, 0xa0, 0x5d, 0x1e, 0xc6, 0xf8, 0x85, 0x00, 0xdb, 0x27, 0x5e, 0x56, 0x85, + 0x43, 0xc5, 0xf6, 0xce, 0x06, 0x64, 0x79, 0x18, 0x54, 0x5b, 0x2c, 0x47, 0xf5, 0x48, 0x2f, 0xcb, + 0xc3, 0xea, 0x79, 0x06, 0xed, 0x34, 0x8f, 0xa8, 0xb4, 0xf0, 0x74, 0xfa, 0xb6, 0x1e, 0xf7, 0x90, + 0xc8, 0x24, 0x79, 0x44, 0x89, 0x04, 0x1b, 0xef, 0xa0, 0x5d, 0x66, 0xe5, 0xbd, 0xe7, 0xee, 0xb5, + 0xde, 0x90, 0xc1, 0x6a, 0xa5, 0x23, 0x3c, 0x80, 0xae, 0x33, 0xff, 0xb6, 0x26, 0xb6, 0x7f, 0xad, + 0x37, 0x17, 0x1f, 0x7e, 0xbc, 0x3f, 0x32, 0x71, 0x93, 0x87, 0x25, 0xad, 0x75, 0x53, 0x70, 0x9a, + 0x46, 0x74, 0x7f, 0xa4, 0xa9, 0x75, 0xd8, 0x86, 0x29, 0xdb, 0x59, 0xf2, 0x5b, 0x66, 0x96, 0x1a, + 0x1a, 0x6a, 0x32, 0x9d, 0xfd, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x29, 0x52, 0xc3, 0xda, 0xe2, 0x02, + 0x00, 0x00, } diff --git a/protos/common/policies.proto b/protos/common/policies.proto index 3f874142ed6..fb6c3081a1c 100644 --- a/protos/common/policies.proto +++ b/protos/common/policies.proto @@ -55,7 +55,7 @@ message SignaturePolicy { } oneof Type { int32 signed_by = 1; - NOutOf from = 2; + NOutOf n_out_of = 2; } }