Syncitem sync state done on last next
This commit is contained in:
parent
2b5383e9e0
commit
755a030175
@ -83,6 +83,7 @@ class SyncFsItem:
|
|||||||
block_number += 1
|
block_number += 1
|
||||||
tx_index = 0
|
tx_index = 0
|
||||||
if self.target >= 0 and block_number > self.target:
|
if self.target >= 0 and block_number > self.target:
|
||||||
|
self.sync_state.move(self.state_key, self.sync_state.DONE)
|
||||||
raise SyncDone(self.target)
|
raise SyncDone(self.target)
|
||||||
else:
|
else:
|
||||||
tx_index += 1
|
tx_index += 1
|
||||||
@ -186,7 +187,7 @@ class SyncFsStore:
|
|||||||
factory = SimpleFileStoreFactory(base_filter_path, binary=True)
|
factory = SimpleFileStoreFactory(base_filter_path, binary=True)
|
||||||
filter_state_backend = PersistedState(factory.add, 0, check_alias=False)
|
filter_state_backend = PersistedState(factory.add, 0, check_alias=False)
|
||||||
self.filter_state = SyncState(filter_state_backend)
|
self.filter_state = SyncState(filter_state_backend)
|
||||||
self.filters = []
|
self.filters = [] # used by SyncSession
|
||||||
|
|
||||||
|
|
||||||
def register(self, fltr):
|
def register(self, fltr):
|
||||||
|
@ -216,6 +216,29 @@ class TestFs(unittest.TestCase):
|
|||||||
store = SyncFsStore(self.path, session_id='foo')
|
store = SyncFsStore(self.path, session_id='foo')
|
||||||
store.start()
|
store.start()
|
||||||
o = store.get(0)
|
o = store.get(0)
|
||||||
|
self.assertEqual(o.cursor, 2)
|
||||||
|
self.assertEqual(o.target, 13)
|
||||||
|
o.next(advance_block=True)
|
||||||
|
o.next(advance_block=True)
|
||||||
|
|
||||||
|
session.stop(o)
|
||||||
|
store = SyncFsStore(self.path, session_id='foo')
|
||||||
|
store.start()
|
||||||
|
self.assertEqual(o.cursor, 4)
|
||||||
|
self.assertEqual(o.target, 13)
|
||||||
|
|
||||||
|
|
||||||
|
def test_sync_history_complete(self):
|
||||||
|
store = SyncFsStore(self.path, session_id='foo')
|
||||||
|
session = SyncSession(store)
|
||||||
|
|
||||||
|
session.start(target=3)
|
||||||
|
o = session.get(0)
|
||||||
|
o.next(advance_block=True)
|
||||||
|
o.next(advance_block=True)
|
||||||
|
o.next(advance_block=True)
|
||||||
|
with self.assertRaises(SyncDone):
|
||||||
|
o.next(advance_block=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user