github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/test/ft/steps/orderer_util.py (about)

     1  # Copyright IBM Corp. 2016 All Rights Reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #      http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  #
    15  
    16  import os
    17  import sys
    18  import datetime
    19  
    20  try:
    21      pbFilePath = os.environ['GOPATH'] + "/src/github.com/hyperledger/fabric/bddtests"
    22      sys.path.insert(0, pbFilePath)
    23      from common import common_pb2
    24  except:
    25      print "ERROR! Unable to import the protobuf libraries from the hyperledger/fabric/bddtests directory: {0}".format(sys.exc_info()[0])
    26      sys.exit(1)
    27  
    28  
    29  # The default chain ID when the system is statically bootstrapped for testing
    30  TEST_CHAIN_ID = "testchainid"
    31  
    32  
    33  def _testAccessPBMethods():
    34      channel_header = common_pb2.ChannelHeader(channel_id=TEST_CHAIN_ID,
    35                                                type=common_pb2.ENDORSER_TRANSACTION)
    36      header = common_pb2.Header(channel_header=channel_header.SerializeToString(),
    37                                 signature_header=common_pb2.SignatureHeader().SerializeToString())
    38      payload = common_pb2.Payload(header=header,
    39                                   data="Functional test: {0}".format(datetime.datetime.utcnow()))
    40      envelope = common_pb2.Envelope(payload=payload.SerializeToString())
    41      return envelope
    42  
    43  
    44  envelope = _testAccessPBMethods()
    45  assert isinstance(envelope, common_pb2.Envelope)
    46  print("Successfully imported protobufs from bddtests directory")