tokio-rs / turmoil

Add hardship to your tests
MIT License
790 stars 50 forks source link

Fix subtraction overflow bug with min latency #146

Closed Benjscho closed 1 year ago

Benjscho commented 1 year ago

Previously if you specify a min_message_latency greater than the default max_message_latency, the test would fail with a tokio error: overflow when subtracting durations. This updates the min_message_latency setter to update the max_message_latency if it is less than the new minimum value.

I also updated the max message latency setter to panic if provided with a value less than the minimum message latency. Given this is much more obviously incorrect to a user of the crate (given the default min latency of 0), I felt a panic was appropriate, and would provide an easier error to debug than the tokio message.