lndk-org / lndk

MIT License
84 stars 20 forks source link

Task: Improve Rate Limiter Handling of Time #56

Open carlaKC opened 1 year ago

carlaKC commented 1 year ago

Description

47 introduced a basic rate limiting implementation with some unit tests, but they're not ideal. One of the main limitations here is around the mocking we have in place for the clock:

Steps to Complete

  1. Update tests to use a static start time (unix epoch?) rather than the current time.
  2. Improve tests to mock out progression of time rather than this workaround, this could either be: 2.1. Update handling of mock to report different timestamps / figure out how to clone + checkpoint afterwards 2.2. Add a duration_since method to the Clock trait, which can be more easily mocked (though still suffers similar issues) - perhaps stealing ideas from LDK
kannapoix commented 1 month ago

@carlaKC (or perhaps @orbitalturtle, who is currently more active). What are your thoughts on using Tokio's built-in testing features(such as advance method)? This approach differs from what you suggested earlier, but it allows us to manage time without relying on mocking.