@@ -940,3 +940,38 @@ def test_on_torrent_finished_alert(self) -> None:
940
940
941
941
self .assertEqual (call (infohash = hexlify (download .tdef .infohash ).decode (), name = "torrent_create" , hidden = False ),
942
942
callback .call_args )
943
+
944
+ async def test_recheck_after_finish (self ) -> None :
945
+ """
946
+ Test if a recheck is triggered after finishing.
947
+ """
948
+ config = MockTriblerConfigManager ()
949
+ config .set ("libtorrent/check_after_complete" , True )
950
+ download = Download (TorrentDef .load_from_memory (TORRENT_WITH_DIRS_CONTENT ), Mock (config = config ),
951
+ checkpoint_disabled = True , config = self .create_mock_download_config ())
952
+ download .handle = Mock ()
953
+
954
+ download .future_added .set_result (None )
955
+ await sleep (0 )
956
+ download .future_finished .set_result (None )
957
+ await sleep (0 )
958
+
959
+ self .assertEqual (call (), download .handle .force_recheck .call_args )
960
+
961
+ async def test_recheck_after_finish_no_startup (self ) -> None :
962
+ """
963
+ Test if a recheck is not triggered after loading a torrent on startup.
964
+ """
965
+ config = MockTriblerConfigManager ()
966
+ config .set ("libtorrent/check_after_complete" , True )
967
+ download = Download (TorrentDef .load_from_memory (TORRENT_WITH_DIRS_CONTENT ), Mock (config = config ),
968
+ checkpoint_disabled = True , config = self .create_mock_download_config ())
969
+ download .handle = Mock ()
970
+ download .lt_status = Mock (progress = 1.0 ) # Start completed
971
+
972
+ download .future_added .set_result (None )
973
+ await sleep (0 )
974
+ download .future_finished .set_result (None )
975
+ await sleep (0 )
976
+
977
+ self .assertEqual (None , download .handle .force_recheck .call_args )
0 commit comments