parent
2bf6d08a16
commit
e9180ed0dc
@ -1321,7 +1321,12 @@ createRcvFileChunk st RcvFileTransfer {fileId, fileInvitation = FileInvitation {
|
||||
getLastChunkNo db = do
|
||||
ns <- DB.query db "SELECT chunk_number FROM rcv_file_chunks WHERE file_id = ? ORDER BY chunk_number DESC LIMIT 1" (Only fileId)
|
||||
pure $ case map fromOnly ns of
|
||||
[] -> if chunkNo == 1 then RcvChunkOk else RcvChunkError
|
||||
[]
|
||||
| chunkNo == 1 ->
|
||||
if chunkSize >= fileSize
|
||||
then RcvChunkFinal
|
||||
else RcvChunkOk
|
||||
| otherwise -> RcvChunkError
|
||||
n : _
|
||||
| chunkNo == n -> RcvChunkDuplicate
|
||||
| chunkNo == n + 1 ->
|
||||
|
@ -42,6 +42,7 @@ chatTests = do
|
||||
it "update user profiles and notify contacts" testUpdateProfile
|
||||
describe "sending and receiving files" $ do
|
||||
it "send and receive file" testFileTransfer
|
||||
it "send and receive a small file" testSmallFileTransfer
|
||||
it "sender cancelled file transfer" testFileSndCancel
|
||||
it "recipient cancelled file transfer" testFileRcvCancel
|
||||
it "send and receive file to group" testGroupFileTransfer
|
||||
@ -420,6 +421,29 @@ testFileTransfer =
|
||||
dest <- B.readFile "./tests/tmp/test.jpg"
|
||||
dest `shouldBe` src
|
||||
|
||||
testSmallFileTransfer :: IO ()
|
||||
testSmallFileTransfer =
|
||||
testChat2 aliceProfile bobProfile $
|
||||
\alice bob -> do
|
||||
connectUsers alice bob
|
||||
alice #> "/f @bob ./tests/fixtures/test.txt"
|
||||
alice <## "use /fc 1 to cancel sending"
|
||||
bob <# "alice> sends file test.txt (11 bytes / 11 bytes)"
|
||||
bob <## "use /fr 1 [<dir>/ | <path>] to receive it"
|
||||
bob ##> "/fr 1 ./tests/tmp"
|
||||
bob <## "saving file 1 from alice to ./tests/tmp/test.txt"
|
||||
concurrentlyN_
|
||||
[ do
|
||||
bob <## "started receiving file 1 (test.txt) from alice"
|
||||
bob <## "completed receiving file 1 (test.txt) from alice",
|
||||
do
|
||||
alice <## "started sending file 1 (test.txt) to bob"
|
||||
alice <## "completed sending file 1 (test.txt) to bob"
|
||||
]
|
||||
src <- B.readFile "./tests/fixtures/test.txt"
|
||||
dest <- B.readFile "./tests/tmp/test.txt"
|
||||
dest `shouldBe` src
|
||||
|
||||
testFileSndCancel :: IO ()
|
||||
testFileSndCancel =
|
||||
testChat2 aliceProfile bobProfile $
|
||||
|
1
tests/fixtures/test.txt
vendored
Normal file
1
tests/fixtures/test.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
hello there
|
Loading…
Reference in New Issue
Block a user