本文整理汇总了Python中TestUtils.didNodeReceive方法的典型用法代码示例。如果您正苦于以下问题:Python TestUtils.didNodeReceive方法的具体用法?Python TestUtils.didNodeReceive怎么用?Python TestUtils.didNodeReceive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestUtils
的用法示例。
在下文中一共展示了TestUtils.didNodeReceive方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sendP2PMsg
# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import didNodeReceive [as 别名]
def sendP2PMsg(self, src, dst, allNodeObservers):
'''Send a P2P message from src to dst and verify it got there.
Also check that no other nodes got it.
'''
goodCounter = 0
for _ in range(numMessages):
messageNum = random.randint(1,9999999)
# Send the message
status = yield TestUtils.sendP2P(src, dst, messageNum )
self.assertTrue(status,"sendP2PMsg failed! [%s] [%s] to [%s]" % (status, src, dst))
#yield TestUtils.wait(1) # Wait for the messages to send
# Check receipt (both that one did and others did not)
status = TestUtils.didNodeReceive(allNodeObservers,dst, messageNum)
self.assertTrue(status,"Expected node did not receive the message!")
status = TestUtils.didNotReceive(allNodeObservers, 'ALL', messageNum, len(allNodeObservers) - 1)
self.assertTrue(status,"Extra nodes received message!")
goodCounter += 1
self.assertTrue(goodCounter == numMessages, "sendP2P message did not finish all messages [%d][%d]" % (goodCounter, numMessages))
defer.returnValue(True)