def test_jail_singlePrisonerErrback(self): self.refresh() q = Quarantine(self.pc.ping, self.rt) n = Node(2**35, ("127.0.0.1", 255)) q.jail(n) self.assertFalse(n in self.rt.nodes) self.assertTrue(n in q.prison) self.pc.current_deferred.errback(TimeoutError("")) self.assertTrue(n in q.prison) self.assertFalse(n in self.rt.nodes)
def test_jail_singlePrisonerCallBack(self): self.refresh() q = Quarantine(self.pc.ping, self.rt) n = Node(2**30, ("127.0.0.1", 555)) q.jail(n) # The node should be inserted into the routing # table after it 'responds' to a query self.assertFalse(n in self.rt.nodes) self.assertTrue(n in q.prison) self.pc.current_deferred.callback(None) self.assertTrue(n in self.rt.nodes) self.assertFalse(n in q.prison)
def test_jail_singlePrisonerErrbackThenCallback(self): self.refresh() q = Quarantine(self.pc.ping, self.rt) n = Node(2**51, ("127.0.0.1", 9555)) q.jail(n) self.assertFalse(n in self.rt.nodes) self.assertTrue(n in q.prison) self.pc.current_deferred.errback(TimeoutError("")) # After the errback, the quarantine should try to # ping the node one last time self.assertFalse(n in self.rt.nodes) self.assertTrue(n in q.prison) self.pc.current_deferred.callback("") self.assertTrue(n in self.rt.nodes) self.assertFalse(n in q.prison)
def test_jail_singlePrisoner(self): self.refresh() q = Quarantine(self.pc.ping, self.rt) n = Node(2**150, ("127.0.0.1", 58)) q.jail(n) self.assertEquals(1, self.pc.ping_count)