Exemplo n.º 1
0
 def test_sees_peer(self):
     self.sent = []
     self.neighbors = {}
     self.engine = HelloProtocol(self, self)
     self.engine.handle_hello(MessageHELLO(None, 'R2', []), 2.0, 0, 1)
     self.engine.tick(5.0)
     self.assertEqual(len(self.sent), 1)
     dest, msg = self.sent.pop(0)
     self.assertEqual(msg.seen_peers, ['R2'])
Exemplo n.º 2
0
 def test_establish_peer(self):
     self.sent = []
     self.neighbors = {}
     self.engine = HelloProtocol(self, self)
     self.engine.handle_hello(MessageHELLO(None, 'R2', ['R1']), 0.5, 0, 1)
     self.engine.tick(1.0)
     self.engine.tick(2.0)
     self.engine.tick(3.0)
     self.assertEqual(len(self.neighbors), 1)
     self.assertEqual(self.neighbors.keys(), ['R2'])
Exemplo n.º 3
0
 def test_hello_sent(self):
     self.sent = []
     self.local_link_state = None
     self.engine = HelloProtocol(self, self)
     self.engine.tick(1.0)
     self.assertEqual(len(self.sent), 1)
     dest, msg = self.sent.pop(0)
     self.assertEqual(dest, "amqp:/_local/qdhello")
     self.assertEqual(msg.get_opcode(), "HELLO")
     self.assertEqual(msg.id, self.id)
     self.assertEqual(msg.seen_peers, [])
     self.assertEqual(self.local_link_state, None)
Exemplo n.º 4
0
 def test_establish_multiple_peers(self):
     self.sent = []
     self.neighbors = {}
     self.engine = HelloProtocol(self, self)
     self.engine.handle_hello(MessageHELLO(None, 'R2', ['R1']), 0.5, 0)
     self.engine.tick(1.0)
     self.engine.handle_hello(MessageHELLO(None, 'R3', ['R1', 'R2']), 1.5, 0)
     self.engine.tick(2.0)
     self.engine.handle_hello(MessageHELLO(None, 'R4', ['R1']), 2.5, 0)
     self.engine.handle_hello(MessageHELLO(None, 'R5', ['R2']), 2.5, 0)
     self.engine.handle_hello(MessageHELLO(None, 'R6', ['R1']), 2.5, 0)
     self.engine.tick(3.0)
     keys = self.neighbors.keys()
     keys.sort()
     self.assertEqual(keys, ['R2', 'R3', 'R4', 'R6'])