Skip to content

Commit 479c436

Browse files
committed
FAB-3281: Import protobuf implementation
This verifies that importing of the python generated code from protobuf files works correctly. Change-Id: I1ebf1d11fcd10a201ba8209b95a3f52e83803646 Signed-off-by: Latitia M Haskins <[email protected]>
1 parent 03fe133 commit 479c436

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/ft/steps/orderer_util.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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")

0 commit comments

Comments
 (0)