def test_ordering(self):
random.shuffle(self.swarm)
sender = self.swarm[0]
receiver = self.swarm[-1]
# send messages
message_alpha = binascii.hexlify(os.urandom(64))
message_beta = binascii.hexlify(os.urandom(64))
message_gamma = binascii.hexlify(os.urandom(64))
self.assertTrue(sender.message_send(receiver.dht_id(), message_alpha))
self.assertTrue(sender.message_send(receiver.dht_id(), message_beta))
self.assertTrue(sender.message_send(receiver.dht_id(), message_gamma))
# check received in order
received = receiver.message_list()
self.assertTrue(sender.dht_id() in received)
messages = received[sender.dht_id()]
self.assertEqual(messages[0], message_alpha)
self.assertEqual(messages[1], message_beta)
self.assertEqual(messages[2], message_gamma)
评论列表
文章目录