Provide and use a SimpleMockTimeProvider
Provide a much simpler mock time provider which doesn't offer block_advance
et al, and use it in MockRuntime.
And: add some new warning code to MockRuntime
, and discourage use of MockSleepProvider
.
Rationale
The block_advance
functionality is hard to understand and use correctly, and anyway doesn't work with spawned tasks. The MockRuntime
with its MockExecutor
offers a better (simpler and more faithful) way to ensure that events occur in the right order in tests using mock time.
Additionally, the need to support block_advance
makes time.rs
complicated and hard to follow. The actual implementation has some problems eg #1036.
Switching MockRuntime
to use a simpler fake time provider avoids these problems for new tests (which postdate the availability of MockExecutor
).
Future
Ideally I would like to deprecate block_advance
et al but they are used fairly extensively in parts of the actual production code (!) via the Runtime
trait. I am not inclined to try to rewrite those tests now. But I think new tests should usually use MockRuntime
.