github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/bddtests/templates/html/appendix-py.html (about)

     1  <!--
     2  #
     3  # Copyright IBM Corp. All Rights Reserved.
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  -->
     8  <div>
     9      {% set msgClassModule = directory.__class__.__module__ %}
    10      {% set msgClassName = directory.__class__.__name__ %}
    11      {% set msgVarName = [msgClassName[0]|lower,msgClassName[1:]]|join('') %}
    12      <div class="scrollBox">
    13          <code>
    14  from common import common_pb2 as common_dot_common_pb2
    15  from common import configtx_pb2 as common_dot_configtx_pb2
    16  from common import configuration_pb2 as common_dot_configuration_pb2
    17  from common import policies_pb2 as common_dot_policies_pb2
    18  from msp import msp_config_pb2, msp_principal_pb2, identities_pb2
    19  from peer import configuration_pb2 as peer_dot_configuration_pb2
    20  from orderer import configuration_pb2 as orderer_dot_configuration_pb2
    21  
    22  from {{ msgClassModule }} import {{ msgClassName }}
    23  {{ msgVarName }} = {{ msgClassName }}()
    24  directory.initFromPath('{{ path_to_pickle }}')
    25  
    26  from steps import bootstrap_util, contexthelper, compose
    27  context = contexthelper.Context()
    28  composition = compose.Composition(context=context, projectName='{{ compose_project_name }}', composeFilesYaml='{{  docker_compose_yml_file }}', register_and_up=False)
    29  composition.rebuildContainerData()
    30  context.compose_containers=composition.containerDataList
    31  
    32  user = directory.getUser("configAdminOrdererOrg0")
    33  channel_id = user.tags['ordererSystemChannelId']
    34  deliverer_stream_helper = user.connectToDeliverFunction(context, 'orderer0', user.tags['config-admin-cert'])
    35  latest_orderer_config_block = bootstrap_util.get_latest_configuration_block(deliverer_stream_helper, channel_id)
    36  latest_orderer_config_group = bootstrap_util.get_channel_group_from_config_block(latest_orderer_config_block)
    37  
    38  deliverer_stream_helper.seekToRange(chainID=channel_id, start="Newest", end="Newest")
    39  blocks = deliverer_stream_helper.getBlocks()
    40  assert len(blocks) == 1, "Expected single block, received: {0} blocks".format(len(blocks))
    41  newest_block = blocks[0]
    42  last_config = common_dot_common_pb2.LastConfig()
    43  metadata = common_dot_common_pb2.Metadata()
    44  metadata.ParseFromString(newest_block.metadata.metadata[common_dot_common_pb2.BlockMetadataIndex.Value('LAST_CONFIG')])
    45  last_config.ParseFromString(metadata.value)
    46  print("Latest config index = {0}, with latest block index = {1}".format(last_config.index, newest_block.header.number))
    47  
    48  #NOTE When done, close open streams
    49  directory.cleanup()
    50  
    51          </code>
    52      </div>
    53  </div>