本文整理汇总了Python中pyndn.Face.getMaxNdnPacketSize方法的典型用法代码示例。如果您正苦于以下问题:Python Face.getMaxNdnPacketSize方法的具体用法?Python Face.getMaxNdnPacketSize怎么用?Python Face.getMaxNdnPacketSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyndn.Face
的用法示例。
在下文中一共展示了Face.getMaxNdnPacketSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_max_ndn_packet_size
# 需要导入模块: from pyndn import Face [as 别名]
# 或者: from pyndn.Face import getMaxNdnPacketSize [as 别名]
def test_max_ndn_packet_size(self):
# Construct an interest whose encoding is one byte larger than getMaxNdnPacketSize.
targetSize = Face.getMaxNdnPacketSize() + 1
# Start with an interest which is almost the right size.
interest = Interest()
interest.getName().append(bytearray(targetSize))
initialSize = interest.wireEncode().size()
# Now replace the component with the desired size which trims off the extra encoding.
interest.setName(
(Name().append(bytearray(targetSize - (initialSize - targetSize)))))
interestSize = interest.wireEncode().size()
self.assertEqual(targetSize, interestSize,
"Wrong interest size for MaxNdnPacketSize")
with self.assertRaises(RuntimeError):
# If no error is raised, then expressInterest didn't throw an
# exception when the interest size exceeds getMaxNdnPacketSize()
self.face.expressInterest(interest, Mock(), Mock())