Skip to content

Commit 8c89259

Browse files
committed
Clean up the mixed tabs and spaces
The whitespace in these files needed to be cleaned up a bit. All tabs were replaced with 4 spaces. Change-Id: Ie5e6aab33024e65b924fe17206ed9308d7b5a6e7 Signed-off-by: Latitia M Haskins <[email protected]>
1 parent f7c19f8 commit 8c89259

File tree

2 files changed

+44
-48
lines changed

2 files changed

+44
-48
lines changed

bddtests/steps/orderer_impl.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,46 @@
3030

3131
@given(u'user "{enrollId}" is an authorized user of the ordering service')
3232
def step_impl(context, enrollId):
33-
secretMsg = {
34-
"enrollId": enrollId,
35-
"enrollSecret" : enrollId
36-
}
37-
orderer_util.registerUser(context, secretMsg, "N/A")
33+
secretMsg = {
34+
"enrollId": enrollId,
35+
"enrollSecret" : enrollId
36+
}
37+
orderer_util.registerUser(context, secretMsg, "N/A")
3838

3939

4040
@when(u'user "{enrollId}" broadcasts "{numMsgsToBroadcast}" unique messages on "{composeService}"')
4141
def step_impl(context, enrollId, numMsgsToBroadcast, composeService):
42-
userRegistration = orderer_util.getUserRegistration(context, enrollId)
43-
userRegistration.broadcastMessages(context, numMsgsToBroadcast, composeService)
42+
userRegistration = orderer_util.getUserRegistration(context, enrollId)
43+
userRegistration.broadcastMessages(context, numMsgsToBroadcast, composeService)
4444

4545

4646
@when(u'user "{enrollId}" connects to deliver function on "{composeService}"')
4747
def step_impl(context, enrollId, composeService):
48-
# First get the properties
49-
assert 'table' in context, "table (Start | End) not found in context"
50-
userRegistration = orderer_util.getUserRegistration(context, enrollId)
51-
streamHelper = userRegistration.connectToDeliverFunction(context, composeService)
48+
# First get the properties
49+
assert 'table' in context, "table (Start | End) not found in context"
50+
userRegistration = orderer_util.getUserRegistration(context, enrollId)
51+
streamHelper = userRegistration.connectToDeliverFunction(context, composeService)
5252

5353

5454
@when(u'user "{enrollId}" waits "{waitTime}" seconds')
5555
def step_impl(context, enrollId, waitTime):
56-
time.sleep(float(waitTime))
56+
time.sleep(float(waitTime))
5757

5858

5959
@then(u'user "{enrollId}" should get a delivery from "{composeService}" of "{expectedBlocks}" blocks with "{numMsgsToBroadcast}" messages within "{batchTimeout}" seconds')
6060
def step_impl(context, enrollId, expectedBlocks, numMsgsToBroadcast, batchTimeout, composeService):
61-
userRegistration = orderer_util.getUserRegistration(context, enrollId)
62-
streamHelper = userRegistration.getDelivererStreamHelper(context, composeService)
63-
blocks = streamHelper.getBlocks()
64-
# Verify block count
65-
assert len(blocks) == int(expectedBlocks), "Expected {0} blocks, received {1}".format(expectedBlocks, len(blocks))
61+
userRegistration = orderer_util.getUserRegistration(context, enrollId)
62+
streamHelper = userRegistration.getDelivererStreamHelper(context, composeService)
63+
blocks = streamHelper.getBlocks()
64+
# Verify block count
65+
assert len(blocks) == int(expectedBlocks), "Expected {0} blocks, received {1}".format(expectedBlocks, len(blocks))
6666

6767

6868
@when(u'user "{enrollId}" sends deliver a seek request on "{composeService}" with properties')
6969
def step_impl(context, enrollId, composeService):
70-
row = context.table.rows[0]
71-
start, end, = orderer_util.convertSeek(row['Start']), orderer_util.convertSeek(row['End'])
70+
row = context.table.rows[0]
71+
start, end, = orderer_util.convertSeek(row['Start']), orderer_util.convertSeek(row['End'])
7272

73-
userRegistration = orderer_util.getUserRegistration(context, enrollId)
74-
streamHelper = userRegistration.getDelivererStreamHelper(context, composeService)
73+
userRegistration = orderer_util.getUserRegistration(context, enrollId)
74+
streamHelper = userRegistration.getDelivererStreamHelper(context, composeService)
7575
streamHelper.seekToRange(start = start, end = end)

bddtests/steps/orderer_util.py

+23-27
Original file line numberDiff line numberDiff line change
@@ -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
194191
def registerUser(context, secretMsg, composeService):
@@ -245,7 +242,6 @@ def createSeekInfo(chainID = TEST_CHAIN_ID, start = 'Oldest', end = 'Newest', b
245242
)
246243

247244

248-
249245
def 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

Comments
 (0)