@@ -149,46 +149,43 @@ def __init__(self, userName):
149149 def getUserName (self ):
150150 return self .userName
151151
152-
153152 def connectToDeliverFunction (self , context , composeService , timeout = 1 ):
154153 'Connect to the deliver function and drain messages to associated orderer queue'
155154 assert not composeService in self .abDeliversStreamHelperDict , "Already connected to deliver stream on {0}" .format (composeService )
156155 streamHelper = DeliverStreamHelper (self .getABStubForComposeService (context , composeService ))
157156 self .abDeliversStreamHelperDict [composeService ] = streamHelper
158157 return streamHelper
159158
160-
161159 def getDelivererStreamHelper (self , context , composeService ):
162160 assert composeService in self .abDeliversStreamHelperDict , "NOT connected to deliver stream on {0}" .format (composeService )
163161 return self .abDeliversStreamHelperDict [composeService ]
164162
165-
166-
167163 def broadcastMessages (self , context , numMsgsToBroadcast , composeService , chainID = TEST_CHAIN_ID , dataFunc = _defaultDataFunction , chainHeaderType = common_pb2 .ENDORSER_TRANSACTION ):
168- abStub = self .getABStubForComposeService (context , composeService )
169- replyGenerator = abStub .Broadcast (generateBroadcastMessages (chainID = chainID , numToGenerate = int (numMsgsToBroadcast ), dataFunc = dataFunc , chainHeaderType = chainHeaderType ), 2 )
170- counter = 0
171- try :
172- for reply in replyGenerator :
173- counter += 1
174- print ("{0} received reply: {1}, counter = {2}" .format (self .getUserName (), reply , counter ))
175- if counter == int (numMsgsToBroadcast ):
176- break
177- except Exception as e :
178- print ("Got error: {0}" .format (e ) )
179- print ("Got error" )
180- print ("Done" )
181- assert counter == int (numMsgsToBroadcast ), "counter = {0}, expected {1}" .format (counter , numMsgsToBroadcast )
164+ abStub = self .getABStubForComposeService (context , composeService )
165+ replyGenerator = abStub .Broadcast (generateBroadcastMessages (chainID = chainID , numToGenerate = int (numMsgsToBroadcast ), dataFunc = dataFunc , chainHeaderType = chainHeaderType ), 2 )
166+ counter = 0
167+ try :
168+ for reply in replyGenerator :
169+ counter += 1
170+ print ("{0} received reply: {1}, counter = {2}" .format (self .getUserName (), reply , counter ))
171+ if counter == int (numMsgsToBroadcast ):
172+ break
173+ except Exception as e :
174+ print ("Got error: {0}" .format (e ) )
175+ print ("Got error" )
176+ print ("Done" )
177+ assert counter == int (numMsgsToBroadcast ), "counter = {0}, expected {1}" .format (counter , numMsgsToBroadcast )
182178
183179 def getABStubForComposeService (self , context , composeService ):
184- 'Return a Stub for the supplied composeService, will cache'
185- if composeService in self .atomicBroadcastStubsDict :
186- return self .atomicBroadcastStubsDict [composeService ]
187- # Get the IP address of the server that the user registered on
188- channel = getGRPCChannel (* bdd_test_util .getPortHostMapping (context .compose_containers , composeService , 7050 ))
189- newABStub = ab_pb2 .beta_create_AtomicBroadcast_stub (channel )
190- self .atomicBroadcastStubsDict [composeService ] = newABStub
191- return newABStub
180+ 'Return a Stub for the supplied composeService, will cache'
181+ if composeService in self .atomicBroadcastStubsDict :
182+ return self .atomicBroadcastStubsDict [composeService ]
183+ # Get the IP address of the server that the user registered on
184+ channel = getGRPCChannel (* bdd_test_util .getPortHostMapping (context .compose_containers , composeService , 7050 ))
185+ newABStub = ab_pb2 .beta_create_AtomicBroadcast_stub (channel )
186+ self .atomicBroadcastStubsDict [composeService ] = newABStub
187+ return newABStub
188+
192189
193190# Registerses a user on a specific composeService
194191def registerUser (context , secretMsg , composeService ):
@@ -245,7 +242,6 @@ def createSeekInfo(chainID = TEST_CHAIN_ID, start = 'Oldest', end = 'Newest', b
245242 )
246243
247244
248-
249245def generateBroadcastMessages (chainID = TEST_CHAIN_ID , numToGenerate = 3 , timeToHoldOpen = 1 , dataFunc = _defaultDataFunction , chainHeaderType = common_pb2 .ENDORSER_TRANSACTION ):
250246 messages = []
251247 for i in range (0 , numToGenerate ):
0 commit comments