From ab4e4e1db936c360ad39fadfc4f424096c504cb2 Mon Sep 17 00:00:00 2001 From: JRoberts <8711996+jr-simplex@users.noreply.github.com> Date: Mon, 23 Jan 2023 22:27:44 +0400 Subject: [PATCH] core: test cancelling inline file transfer (#1827) * core: test cancelling inline file transfer * tests --- tests/ChatTests.hs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/ChatTests.hs b/tests/ChatTests.hs index af563f361d..5c4c3efee6 100644 --- a/tests/ChatTests.hs +++ b/tests/ChatTests.hs @@ -88,6 +88,7 @@ chatTests = do describe "sending and receiving files" $ do describe "send and receive file" $ fileTestMatrix2 runTestFileTransfer it "send and receive file inline (without accepting)" testInlineFileTransfer + it "accept inline file transfer, sender cancels during transfer" testAcceptInlineFileSndCancelDuringTransfer it "send and receive small file inline (default config)" testSmallInlineFileTransfer it "small file sent without acceptance is ignored in terminal by default" testSmallInlineFileIgnored it "receive file inline with inline=on option" testReceiveInline @@ -1906,6 +1907,37 @@ testInlineFileTransfer = where cfg = testCfg {inlineFiles = defaultInlineFilesConfig {offerChunks = 100, sendChunks = 100, receiveChunks = 100}} +testAcceptInlineFileSndCancelDuringTransfer :: IO () +testAcceptInlineFileSndCancelDuringTransfer = + testChatCfg2 cfg aliceProfile bobProfile $ \alice bob -> do + connectUsers alice bob + bob ##> "/_files_folder ./tests/tmp/" + bob <## "ok" + alice #> "/f @bob ./tests/fixtures/test_1MB.pdf" + alice <## "use /fc 1 to cancel sending" + bob <# "alice> sends file test_1MB.pdf (1017.7 KiB / 1042157 bytes)" + bob <## "use /fr 1 [/ | ] to receive it" + bob ##> "/fr 1 inline=on" + bob <## "saving file 1 from alice to test_1MB.pdf" + alice <## "started sending file 1 (test_1MB.pdf) to bob" + bob <## "started receiving file 1 (test_1MB.pdf) from alice" + alice ##> "/fc 1" -- test that inline file cancel doesn't delete contact connection + concurrentlyN_ + [ do + alice <##. "cancelled sending file 1 (test_1MB.pdf)" + alice <## "completed sending file 1 (test_1MB.pdf) to bob", + bob <## "completed receiving file 1 (test_1MB.pdf) from alice" + ] + _ <- getTermLine alice + alice #> "@bob hi" + bob #> "@alice hey" + _ <- getTermLine bob + bob <## "alice cancelled sending file 1 (test_1MB.pdf)" + bob <# "alice> hi" + alice <# "bob> hey" + where + cfg = testCfg {inlineFiles = defaultInlineFilesConfig {offerChunks = 100, receiveChunks = 50}} + testSmallInlineFileTransfer :: IO () testSmallInlineFileTransfer = testChat2 aliceProfile bobProfile $ \alice bob -> do