magic-wormhole / magic-wormhole-transit-relay

Transit Relay server for Magic-Wormhole
MIT License
169 stars 42 forks source link

Use StringTransportWithDisconnection for transit server tests. #14

Closed sigwinch28 closed 4 years ago

sigwinch28 commented 4 years ago

Replace the use of TCP in the test suite with Twisted's StringTransport, specifically StringTransportWithDisconnection which allows us to trigger a disconnect event on the server side during testing.

The dataReceived method on the server is now called directly, and any effects will be realised immediately. Responses are available to the test client using the value() method of the transport objects, and the buffer can be cleared using clear().

This allows all asynchronous behaviour to be removed from the transit server test suite. Furthermore, as we never have to wait for the server, tests no longer hang if they fail: the errors are encountered immediately.

codecov-io commented 4 years ago

Codecov Report

Merging #14 into master will increase coverage by <.01%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #14      +/-   ##
==========================================
+ Coverage   99.43%   99.44%   +<.01%     
==========================================
  Files           5        5              
  Lines         356      359       +3     
  Branches       57       57              
==========================================
+ Hits          354      357       +3     
  Misses          1        1              
  Partials        1        1
Impacted Files Coverage Δ
src/wormhole_transit_relay/transit_server.py 100% <100%> (ø) :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 c644532...658b4d4. Read the comment docs.

warner commented 4 years ago

thank you! I will try to resolve the conflicts and land this over the weekend.

sigwinch28 commented 4 years ago

Thank you! and you're very welcome :)

warner commented 4 years ago

Awesome job, thorough comments, excellent change. 5 stars, would review again :).

Landing momentarily (in rebased form as 46ec26f2bba7900dffd4d213608ebeeaf647427d).