def test_stringify(self): for i in range(0, self.num_iters): elems = [IntElem(random.randint(0, 100000000)) for i in range(0, 1000)] elems.sort() sl = AuthSkipList.new(elems, IntElem(-1), IntElem(100000001)) lower = random.choice(elems[1:200]) upper = random.choice(elems[500:-1]) vo = SkipListVO.range_query(sl, lower, upper) self.assertTrue(isinstance(vo, SkipListVO)) serialized = vo.serialize() new_vo = SkipListVO.deserialize(serialized, IntElem) print 'vo:' for l in vo.to_list_of_lists(): print l print print new_vo.root print 'new_vo:' for l in new_vo.to_list_of_lists(): print l self.assertEqual(vo, new_vo)
def range_query(self, lower, upper): """ Query a range of elements beteween lower and upper (inclusive) Arguments: self - the skiplist object lower - the (inclusive) lower bound of the range upper - the (inclusive) upper bound of the range Returns: vo - a verification object (as in vo.py) for the given range """ _send(self.wfile, 'RANGE_QUERY') _sendi(self.wfile, [lower.serialize(), upper.serialize()]) vo = _recv(self.rfile, 'client') return SkipListVO.deserialize(vo, self.elemClass)