当前位置: 首页>>代码示例>>Python>>正文


Python TestUtils.sendP2P方法代码示例

本文整理汇总了Python中TestUtils.sendP2P方法的典型用法代码示例。如果您正苦于以下问题:Python TestUtils.sendP2P方法的具体用法?Python TestUtils.sendP2P怎么用?Python TestUtils.sendP2P使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestUtils的用法示例。


在下文中一共展示了TestUtils.sendP2P方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sendP2PMsg

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import sendP2P [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)       
开发者ID:danfleck,项目名称:Class-Chord,代码行数:29,代码来源:EnclaveP2PTest.py

示例2: sendFailingP2PMsg

# 需要导入模块: import TestUtils [as 别名]
# 或者: from TestUtils import sendP2P [as 别名]
 def sendFailingP2PMsg(self, src, dst):
     '''Send a P2P message from src to dst that should fail to get there
        because they are in different enclaves.
        Also check that no other nodes got it.
     '''
     for _ in range(numMessages):
         messageNum = random.randint(1,9999999)
         
         # Send the message
         status = yield TestUtils.sendP2P(src, dst, messageNum )
         self.assertFalse(status,"sendP2PMsg  succeeded but should have failed! [%s] to [%s]" % (src, dst))
     
     defer.returnValue(True)  
开发者ID:danfleck,项目名称:Class-Chord,代码行数:15,代码来源:EnclaveP2PTest.py


注:本文中的TestUtils.sendP2P方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。