2 unstable releases

0.2.0 Apr 11, 2020
0.1.0 Apr 10, 2020

#769 in Testing

Download history 14/week @ 2024-02-19 4/week @ 2024-02-26 15/week @ 2024-03-11 39/week @ 2024-04-01

54 downloads per month

MIT license

11KB
200 lines

diviner

Diviner is a FoundationDB style simulation testing framework for Rust. It includes 2 parts:

  • A Future executor that is designed to be single threaded and deterministic. The goal here is to enable deterministic simulations in Rust.
  • Wrappers over existing Rust async IO libraries. When building normally, the wrappers will use the actual implementation, but when building with simulation feature enabled, the wrappers will use mocked implementations that integrate with above Future executor to enable deterministic testing. The wrappers mentioned here, might inclue (but are not limited to):
    • Time related functions, such as sleep or now;
    • Network related modules, such as TCPListener, TCPStream;
    • File IO related modules;

If you find the above term confusing, this video might help explain what diviner provides.

The goal here, is to enable deterministic testing on any Rust code satisfying the following rules:

  1. The code is written in async/await style;
  2. The code uses wrappers provided by diviner to perform all the necessary IOs;

Examples

To illustrate what the library does, several examples are provided in the repository:

  • simple: a minimal piece of code written in async/await style;
  • time-manipulation: time manipulation example, here we are testing sleeping for a whole day, but the simulation code would manipulate time and finish immediately;
  • execution-order: a poorly implemented agent, diviner can use different seeds to test different execution orders of futures. So later you can determinisically debug the code with the seed that will trigger the errors;

Dependencies

~1.2–1.7MB
~28K SLoC