Skip to content

Commit

Permalink
Clean up the mixed tabs and spaces
Browse files Browse the repository at this point in the history
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 <latitia.haskins@gmail.com>
  • Loading branch information
lhaskins committed Feb 8, 2017
1 parent f7c19f8 commit 8c89259
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 48 deletions.
42 changes: 21 additions & 21 deletions bddtests/steps/orderer_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,46 +30,46 @@

@given(u'user "{enrollId}" is an authorized user of the ordering service')
def step_impl(context, enrollId):
secretMsg = {
"enrollId": enrollId,
"enrollSecret" : enrollId
}
orderer_util.registerUser(context, secretMsg, "N/A")
secretMsg = {
"enrollId": enrollId,
"enrollSecret" : enrollId
}
orderer_util.registerUser(context, secretMsg, "N/A")


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


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


@when(u'user "{enrollId}" waits "{waitTime}" seconds')
def step_impl(context, enrollId, waitTime):
time.sleep(float(waitTime))
time.sleep(float(waitTime))


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


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

userRegistration = orderer_util.getUserRegistration(context, enrollId)
streamHelper = userRegistration.getDelivererStreamHelper(context, composeService)
userRegistration = orderer_util.getUserRegistration(context, enrollId)
streamHelper = userRegistration.getDelivererStreamHelper(context, composeService)
streamHelper.seekToRange(start = start, end = end)
50 changes: 23 additions & 27 deletions bddtests/steps/orderer_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,46 +149,43 @@ def __init__(self, userName):
def getUserName(self):
return self.userName


def connectToDeliverFunction(self, context, composeService, timeout=1):
'Connect to the deliver function and drain messages to associated orderer queue'
assert not composeService in self.abDeliversStreamHelperDict, "Already connected to deliver stream on {0}".format(composeService)
streamHelper = DeliverStreamHelper(self.getABStubForComposeService(context, composeService))
self.abDeliversStreamHelperDict[composeService] = streamHelper
return streamHelper


def getDelivererStreamHelper(self, context, composeService):
assert composeService in self.abDeliversStreamHelperDict, "NOT connected to deliver stream on {0}".format(composeService)
return self.abDeliversStreamHelperDict[composeService]



def broadcastMessages(self, context, numMsgsToBroadcast, composeService, chainID=TEST_CHAIN_ID, dataFunc=_defaultDataFunction, chainHeaderType=common_pb2.ENDORSER_TRANSACTION):
abStub = self.getABStubForComposeService(context, composeService)
replyGenerator = abStub.Broadcast(generateBroadcastMessages(chainID=chainID, numToGenerate = int(numMsgsToBroadcast), dataFunc=dataFunc, chainHeaderType=chainHeaderType), 2)
counter = 0
try:
for reply in replyGenerator:
counter += 1
print("{0} received reply: {1}, counter = {2}".format(self.getUserName(), reply, counter))
if counter == int(numMsgsToBroadcast):
break
except Exception as e:
print("Got error: {0}".format(e) )
print("Got error")
print("Done")
assert counter == int(numMsgsToBroadcast), "counter = {0}, expected {1}".format(counter, numMsgsToBroadcast)
abStub = self.getABStubForComposeService(context, composeService)
replyGenerator = abStub.Broadcast(generateBroadcastMessages(chainID=chainID, numToGenerate = int(numMsgsToBroadcast), dataFunc=dataFunc, chainHeaderType=chainHeaderType), 2)
counter = 0
try:
for reply in replyGenerator:
counter += 1
print("{0} received reply: {1}, counter = {2}".format(self.getUserName(), reply, counter))
if counter == int(numMsgsToBroadcast):
break
except Exception as e:
print("Got error: {0}".format(e) )
print("Got error")
print("Done")
assert counter == int(numMsgsToBroadcast), "counter = {0}, expected {1}".format(counter, numMsgsToBroadcast)

def getABStubForComposeService(self, context, composeService):
'Return a Stub for the supplied composeService, will cache'
if composeService in self.atomicBroadcastStubsDict:
return self.atomicBroadcastStubsDict[composeService]
# Get the IP address of the server that the user registered on
channel = getGRPCChannel(*bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050))
newABStub = ab_pb2.beta_create_AtomicBroadcast_stub(channel)
self.atomicBroadcastStubsDict[composeService] = newABStub
return newABStub
'Return a Stub for the supplied composeService, will cache'
if composeService in self.atomicBroadcastStubsDict:
return self.atomicBroadcastStubsDict[composeService]
# Get the IP address of the server that the user registered on
channel = getGRPCChannel(*bdd_test_util.getPortHostMapping(context.compose_containers, composeService, 7050))
newABStub = ab_pb2.beta_create_AtomicBroadcast_stub(channel)
self.atomicBroadcastStubsDict[composeService] = newABStub
return newABStub


# Registerses a user on a specific composeService
def registerUser(context, secretMsg, composeService):
Expand Down Expand Up @@ -245,7 +242,6 @@ def createSeekInfo(chainID = TEST_CHAIN_ID, start = 'Oldest', end = 'Newest', b
)



def generateBroadcastMessages(chainID = TEST_CHAIN_ID, numToGenerate = 3, timeToHoldOpen = 1, dataFunc =_defaultDataFunction, chainHeaderType=common_pb2.ENDORSER_TRANSACTION ):
messages = []
for i in range(0, numToGenerate):
Expand Down

0 comments on commit 8c89259

Please sign in to comment.