summaryrefslogtreecommitdiff
path: root/testing/tests/sync/test_encdecpool.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tests/sync/test_encdecpool.py')
-rw-r--r--testing/tests/sync/test_encdecpool.py19
1 files changed, 5 insertions, 14 deletions
diff --git a/testing/tests/sync/test_encdecpool.py b/testing/tests/sync/test_encdecpool.py
index 82e99a47..4a32885e 100644
--- a/testing/tests/sync/test_encdecpool.py
+++ b/testing/tests/sync/test_encdecpool.py
@@ -29,7 +29,6 @@ from leap.soledad.client.encdecpool import SyncDecrypterPool
from leap.soledad.common.document import SoledadDocument
from test_soledad.util import BaseSoledadTest
from twisted.internet import defer
-from twisted.test.proto_helpers import MemoryReactorClock
DOC_ID = "mydoc"
DOC_REV = "rev"
@@ -65,17 +64,11 @@ class TestSyncEncrypterPool(BaseSoledadTest):
"""
doc = SoledadDocument(
doc_id=DOC_ID, rev=DOC_REV, json=json.dumps(DOC_CONTENT))
- self._pool.encrypt_doc(doc)
- # exhaustivelly attempt to get the encrypted document
- encrypted = None
- attempts = 0
- while encrypted is None and attempts < 10:
- encrypted = yield self._pool.get_encrypted_doc(DOC_ID, DOC_REV)
- attempts += 1
+ yield self._pool.encrypt_doc(doc)
+ encrypted = yield self._pool.get_encrypted_doc(DOC_ID, DOC_REV)
self.assertIsNotNone(encrypted)
- self.assertTrue(attempts < 10)
class TestSyncDecrypterPool(BaseSoledadTest):
@@ -219,9 +212,6 @@ class TestSyncDecrypterPool(BaseSoledadTest):
This test ensures that processing of documents only occur if there is
a sequence in place.
"""
- reactor_clock = MemoryReactorClock()
- self._pool._loop.clock = reactor_clock
-
crypto = self._soledad._crypto
docs = []
@@ -234,18 +224,19 @@ class TestSyncDecrypterPool(BaseSoledadTest):
docs.append((doc, encrypted_content))
# insert the encrypted document in the pool
- self._pool.start(10) # pool is expecting to process 10 docs
+ yield self._pool.start(10) # pool is expecting to process 10 docs
+ self._pool._loop.stop() # we are processing manually
# first three arrives, forming a sequence
for i, (doc, encrypted_content) in enumerate(docs[:3]):
gen = idx = i + 1
yield self._pool.insert_encrypted_received_doc(
doc.doc_id, doc.rev, encrypted_content, gen, "trans_id", idx)
+
# last one arrives alone, so it can't be processed
doc, encrypted_content = docs[-1]
yield self._pool.insert_encrypted_received_doc(
doc.doc_id, doc.rev, encrypted_content, 10, "trans_id", 10)
- reactor_clock.advance(self._pool.DECRYPT_LOOP_PERIOD)
yield self._pool._decrypt_and_recurse()
self.assertEqual(3, self._pool._processed_docs)