discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
327 stars 110 forks source link

test(VoiceUDPSocket): unit tests #82

Closed amishshah closed 3 years ago

amishshah commented 3 years ago

Please describe the changes this PR makes and why it should be merged:

Adds unit tests to VoiceUDPSocket, and also fixes an issue raised in testing. Previously, if an unexpected message was received on the socket during IP discovery, then an unhandled error would be thrown. This has been fixed, the caller of the parsing function now handles errors by discarding bad packets. The parsing function also validates the IP address.

Status and versioning classification:

codecov[bot] commented 3 years ago

Codecov Report

Merging #82 (3369f25) into main (f140bd4) will increase coverage by 3.50%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #82      +/-   ##
==========================================
+ Coverage   44.01%   47.52%   +3.50%     
==========================================
  Files          15       15              
  Lines         602      606       +4     
  Branches      133      134       +1     
==========================================
+ Hits          265      288      +23     
+ Misses        335      316      -19     
  Partials        2        2              
Impacted Files Coverage Δ
src/networking/VoiceUDPSocket.ts 95.83% <100.00%> (+95.83%) :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 f140bd4...3369f25. Read the comment docs.

amishshah commented 3 years ago

Addressed code review @kyranet. As for the malformed packet test, I realised this situation could never actually occur, so I removed the check.