magic-wormhole / magic-wormhole.rs

Rust implementation of Magic Wormhole, with new features and enhancements
European Union Public License 1.2
648 stars 72 forks source link

Break when reading at EOF #153

Closed aeshirey closed 2 years ago

aeshirey commented 2 years ago

Fix for #152 - when reading zero bytes at EOF, don't transmit, update sent size, or update hash.

piegamesde commented 2 years ago

Thanks. Can you please also add an assertion about the payload length to Transit::send_record? And if you want to go the extra mile, add a test case to catch any regressions (could probably be based off our test_file_rust2rust test).

codecov[bot] commented 2 years ago

Codecov Report

Merging #153 (15deddd) into master (b6a471a) will increase coverage by 0.72%. The diff coverage is 88.67%.

@@            Coverage Diff             @@
##           master     #153      +/-   ##
==========================================
+ Coverage   51.87%   52.59%   +0.72%     
==========================================
  Files          15       15              
  Lines        2641     2694      +53     
==========================================
+ Hits         1370     1417      +47     
- Misses       1271     1277       +6     
Impacted Files Coverage Δ
src/transfer/v1.rs 31.53% <50.00%> (+0.15%) :arrow_up:
src/core/test.rs 93.15% <90.00%> (-0.94%) :arrow_down:
src/transit.rs 79.19% <100.00%> (+0.03%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b6a471a...15deddd. Read the comment docs.

aeshirey commented 2 years ago

Binary file example-file-4096.bin created according to the original issue (dd if=/dev/zero of=example-file-4096.bin bs=4096 count=123).

All tests ran successfully (cargo test --all) and specifically, the new test (cargo test test_4096_file_rust2rust --all).

piegamesde commented 2 years ago

Looking good! However, I'd like to not check in a 0.5 MiB file into the repository if I can avoid it. I think something smaller, like 8096 bytes should still do the trick.

(Also, rustfmt is having a fit for some reason right now, just ignore it)