moved skiplists tests
authorForrest Voight <forrest@forre.st>
Mon, 5 Dec 2011 09:59:52 +0000 (04:59 -0500)
committerForrest Voight <forrest@forre.st>
Mon, 5 Dec 2011 09:59:52 +0000 (04:59 -0500)
p2pool/skiplists.py
p2pool/test/test_skiplists.py [new file with mode: 0644]

index 2cfa560..6baac98 100644 (file)
@@ -85,15 +85,3 @@ class CountsSkipList(skiplist.SkipList):
     
     def finalize(self, (share_count, share_hashes)):
         return share_hashes
-
-if __name__ == '__main__':
-    import random
-    from p2pool.util import forest
-    t = forest.Tracker()
-    d = WeightsSkipList(t)
-    for i in xrange(2000):
-        t.add(data.FakeShare(hash=i, previous_hash=i - 1 if i > 0 else None, new_script=i, target=random.randrange(2**249, 2**250)))
-    for i in xrange(2000):
-        #a = random.randrange(2000)
-        a = 1999
-        print d(a, a, 1000000)[1]
diff --git a/p2pool/test/test_skiplists.py b/p2pool/test/test_skiplists.py
new file mode 100644 (file)
index 0000000..835899c
--- /dev/null
@@ -0,0 +1,16 @@
+import random
+import unittest
+
+from p2pool import skiplists
+from p2pool.util import forest
+from p2pool.test.util import test_forest
+
+class Test(unittest.TestCase):
+    def test_all(self):
+        t = forest.Tracker()
+        d = skiplists.WeightsSkipList(t)
+        for i in xrange(200):
+            t.add(test_forest.FakeShare(hash=i, previous_hash=i - 1 if i > 0 else None, new_script=i, donation=1234, target=2**249))
+        for i in xrange(200):
+            a = random.randrange(200)
+            d(a, random.randrange(a + 1), 1000000*65535)[1]