def test_tracker3(self): for ii in xrange(10): items = [] for i in xrange(random.randrange(100)): x = random.choice(items + [ FakeShare(hash=None), FakeShare(hash=random.randrange(1000000, 2000000)) ]).hash items.append(FakeShare(hash=i, previous_hash=x)) t = forest.Tracker() test_tracker(t) for item in math.shuffled(items): t.add(item) test_tracker(t) if random.randrange(3) == 0: while True: try: t.remove(random.choice(list(t.items))) except NotImplementedError: pass else: break test_tracker(t) for item in math.shuffled(items): if item.hash not in t.items: t.add(item) test_tracker(t) if random.randrange(3) == 0: while True: try: t.remove(random.choice(list(t.items))) except NotImplementedError: pass else: break test_tracker(t) while t.items: while True: try: t.remove(random.choice(list(t.items))) except NotImplementedError: pass else: break test_tracker(t)
def generate_tracker_simple(n): t = forest.Tracker( math.shuffled( FakeShare(hash=i, previous_hash=i - 1 if i > 0 else None) for i in xrange(n))) test_tracker(t) return t
def test_tracker3(self): for ii in xrange(10): shares = [] for i in xrange(random.randrange(100)): x = random.choice(shares + [FakeShare(hash=None), FakeShare(hash=random.randrange(1000000, 2000000))]).hash shares.append(FakeShare(hash=i, previous_hash=x)) t = forest.Tracker() test_tracker(t) for share in math.shuffled(shares): t.add(share) test_tracker(t) if random.randrange(3) == 0: while True: try: t.remove(random.choice(list(t.shares))) except NotImplementedError: pass else: break test_tracker(t) for share in math.shuffled(shares): if share.hash not in t.shares: t.add(share) test_tracker(t) if random.randrange(3) == 0: while True: try: t.remove(random.choice(list(t.shares))) except NotImplementedError: pass else: break test_tracker(t) while t.shares: while True: try: t.remove(random.choice(list(t.shares))) except NotImplementedError: pass else: break test_tracker(t)
def generate_tracker_random(n): shares = [] for i in xrange(n): x = random.choice(shares + [FakeShare(hash=None), FakeShare(hash=random.randrange(1000000, 2000000))]).hash shares.append(FakeShare(hash=i, previous_hash=x)) t = forest.Tracker(math.shuffled(shares)) test_tracker(t) return t
def generate_tracker_random(n): items = [] for i in xrange(n): x = random.choice(items + [ FakeShare(hash=None), FakeShare(hash=random.randrange(1000000, 2000000)) ]).hash items.append(FakeShare(hash=i, previous_hash=x)) t = forest.Tracker(math.shuffled(items)) test_tracker(t) return t
def get(blah): for p2pool_base_url in util_math.shuffled(p2pool_base_urls): url = p2pool_base_url.rstrip('/') + '/' + blah print 'trying', url try: d = yield client.getPage(url) except Exception: traceback.print_exc() else: defer.returnValue(json.loads(d)) raise ValueError('no good p2pool servers')
def generate_tracker_simple(n): t = forest.Tracker(math.shuffled(FakeShare(hash=i, previous_hash=i - 1 if i > 0 else None) for i in xrange(n))) test_tracker(t) return t