Skip to content

Commit

Permalink
FAB-3281: Import protobuf implementation
Browse files Browse the repository at this point in the history
This verifies that importing of the python generated
code from protobuf files works correctly.

Change-Id: I1ebf1d11fcd10a201ba8209b95a3f52e83803646
Signed-off-by: Latitia M Haskins <latitia.haskins@gmail.com>
  • Loading branch information
lhaskins committed Apr 21, 2017
1 parent 03fe133 commit 479c436
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/ft/steps/orderer_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright IBM Corp. 2016 All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import os
import sys
import datetime

try:
pbFilePath = os.environ['GOPATH'] + "/src/github.com/hyperledger/fabric/bddtests"
sys.path.insert(0, pbFilePath)
from common import common_pb2
except:
print "ERROR! Unable to import the protobuf libraries from the hyperledger/fabric/bddtests directory: {0}".format(sys.exc_info()[0])
sys.exit(1)


# The default chain ID when the system is statically bootstrapped for testing
TEST_CHAIN_ID = "testchainid"


def _testAccessPBMethods():
channel_header = common_pb2.ChannelHeader(channel_id=TEST_CHAIN_ID,
type=common_pb2.ENDORSER_TRANSACTION)
header = common_pb2.Header(channel_header=channel_header.SerializeToString(),
signature_header=common_pb2.SignatureHeader().SerializeToString())
payload = common_pb2.Payload(header=header,
data="Functional test: {0}".format(datetime.datetime.utcnow()))
envelope = common_pb2.Envelope(payload=payload.SerializeToString())
return envelope


envelope = _testAccessPBMethods()
assert isinstance(envelope, common_pb2.Envelope)
print("Successfully imported protobufs from bddtests directory")

0 comments on commit 479c436

Please sign in to comment.