core: test async file transfer (sender & receiver restarts); close files in stopChatController; handle openFile error in getFileHandle (#1716)

This commit is contained in:
JRoberts
2023-01-10 20:52:59 +04:00
committed by GitHub
parent 813fecddfe
commit 810f248c74
2 changed files with 42 additions and 5 deletions

View File

@@ -159,10 +159,12 @@ chatTests = do
-- it "v1 to v2" testFullAsyncV1toV2
-- it "v2 to v1" testFullAsyncV2toV1
describe "async sending and receiving files" $ do
it "send and receive file, sender restarts" testAsyncFileTransferSenderRestarts
it "send and receive file, receiver restarts" testAsyncFileTransferReceiverRestarts
xdescribe "send and receive file, fully asynchronous" $ do
it "v2" testAsyncFileTransfer
it "v1" testAsyncFileTransferV1
xit "send and receive file to group, fully asynchronous" testAsyncGroupFileTransfer
it "send and receive file to group, fully asynchronous" testAsyncGroupFileTransfer
describe "webrtc calls api" $ do
it "negotiate call" testNegotiateCall
describe "maintenance mode" $ do
@@ -4010,6 +4012,34 @@ testFullAsyncV2toV1 = withTmpFiles $ do
withNewBob = withNewTestChat "bob" bobProfile
withBob = withTestChat "bob"
testAsyncFileTransferSenderRestarts :: IO ()
testAsyncFileTransferSenderRestarts = withTmpFiles $ do
withNewTestChat "bob" bobProfile $ \bob -> do
withNewTestChat "alice" aliceProfile $ \alice -> do
connectUsers alice bob
startFileTransfer' alice bob "test_1MB.pdf" "1017.7 KiB / 1042157 bytes"
threadDelay 100000
withTestChatContactConnected "alice" $ \alice -> do
alice <## "completed sending file 1 (test_1MB.pdf) to bob"
bob <## "completed receiving file 1 (test_1MB.pdf) from alice"
src <- B.readFile "./tests/fixtures/test_1MB.pdf"
dest <- B.readFile "./tests/tmp/test_1MB.pdf"
dest `shouldBe` src
testAsyncFileTransferReceiverRestarts :: IO ()
testAsyncFileTransferReceiverRestarts = withTmpFiles $ do
withNewTestChat "alice" aliceProfile $ \alice -> do
withNewTestChat "bob" bobProfile $ \bob -> do
connectUsers alice bob
startFileTransfer' alice bob "test_1MB.pdf" "1017.7 KiB / 1042157 bytes"
threadDelay 100000
withTestChatContactConnected "bob" $ \bob -> do
alice <## "completed sending file 1 (test_1MB.pdf) to bob"
bob <## "completed receiving file 1 (test_1MB.pdf) from alice"
src <- B.readFile "./tests/fixtures/test_1MB.pdf"
dest <- B.readFile "./tests/tmp/test_1MB.pdf"
dest `shouldBe` src
testAsyncFileTransfer :: IO ()
testAsyncFileTransfer = withTmpFiles $ do
withNewTestChat "alice" aliceProfile $ \alice ->