-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <latitia.haskins@gmail.com>
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |