bitcoin-dev-project / bitcoin-dev-project/sim-ln
Robustness: Improve Test Coverage of Repo
- Dominant language
- Rust
- Stars
- 80
- Forks
- 40
- Avg merge
- 18h 49m
- Merged PRs (30d)
- 2
Description
SimLN started as a hackathon project, so it doesn't have much by way of unit tests. This is very, very bad.
We should aim to dramatically improve the coverage of the codebase to ensure that everything is working as expected, and there are no future regressions.
A great first starting point would be to add test coverage for `Simulator` with [mock out](https://docs.rs/mockall/latest/mockall/) `LightningNode` implementations. See [sim node mocking](https://github.com/bitcoin-dev-project/sim-ln/blob/main/sim-lib/src/sim_node.rs#L1415) as an example of how to go about this.
Low hanging fruit:
* `validate_activity`
* `validate_node_network`
Middle tier:
Test individual functions for their expected behavior, eg:
* Spin up `consume_events`
* Test various exit conditions - `send_payment` failure, `listener` shutdown etc
* Test successful `send_payment` for both `SimulationOutput::SendPaymentSuccess`/`SimulationOutput::SendPaymentFailure` etc
A few considerations here:
* Will need to spin up blocking functions like `consume_events` in a separate task so the test can run
* Consider buffering channels to make life a bit easier
The rest of the elephant:
* Test the high level `Simulation::run` function with mocked nodes
* Refactors that make life easier here are welcome!
Contributor guide
Assessment
This issue has not been assessed yet.