test(mbt): Add Model Based Test for Emerald#201
test(mbt): Add Model Based Test for Emerald#201erickpintor wants to merge 1 commit intoerick/mbt-decide-on-roundfrom
Conversation
029e72f to
d09bd51
Compare
| #[quint_run( | ||
| spec = "../../specs/emerald_mbt.qnt", | ||
| step = "step_no_failures", | ||
| max_samples = 32, | ||
| max_steps = 128 | ||
| )] | ||
| fn simulation_no_failures() -> impl Driver { | ||
| EmeraldDriver::default() | ||
| } | ||
|
|
||
| #[quint_run( | ||
| spec = "../../specs/emerald_mbt.qnt", | ||
| step = "step_with_failures", | ||
| max_samples = 32, | ||
| max_steps = 128 | ||
| )] | ||
| fn simulation_with_failures() -> impl Driver { | ||
| EmeraldDriver::default() | ||
| } |
There was a problem hiding this comment.
First uncached run took about 30m in the CI. Let me know if you want to generate fewer traces or reduce the number of steps to minimize test time.
bugarela
left a comment
There was a problem hiding this comment.
All good from my side!
9b46ba5 to
6343e8e
Compare
58ca2f7 to
1de9af2
Compare
6343e8e to
b9b7e32
Compare
1de9af2 to
54fca10
Compare
b9b7e32 to
133095a
Compare
3d62414 to
805fcc9
Compare
tests/mbt/src/reth.rs
Outdated
| let res = Command::new("make") | ||
| .env("RETH_NODES", nodes) | ||
| .arg(cmd) | ||
| .current_dir("../..") |
There was a problem hiding this comment.
can we use absolute path here?
you may use CARGO_MANIFEST_DIR.
There was a problem hiding this comment.
It seems like CARGO_MANIFEST_DIR points to tests/mbt. I had to make the path relative to that directory anyway. Lemme know if you want me to try something else.
tests/mbt/src/runtime.rs
Outdated
| impl Runtime { | ||
| pub fn new(temp_dir: TempDir) -> Result<Self> { | ||
| Ok(Self { | ||
| tokio: tokio::runtime::Runtime::new()?, |
tests/mbt/src/driver/environment.rs
Outdated
| /// creating one Emerald and Reth instance per [crate::NODES]. | ||
| pub fn init(&mut self) -> Result<()> { | ||
| // Reset the driver | ||
| *self = Default::default(); |
There was a problem hiding this comment.
can you explain this line ?
I would rather prefer pub fn reinit(self) -> Result<Self> { ... }
There was a problem hiding this comment.
The intent is to reset the state of the driver to its default (empty) state. I could extract it into a function but, it'd just be a function that returns Self::default().
| impl EmeraldDriver { | ||
| /// Locates the system under test and use the driver's runtime to wait for | ||
| /// the execution of the given future. | ||
| pub fn perform<'a, F, Fut>(&'a mut self, node: Node, action: F) -> Result<()> |
There was a problem hiding this comment.
curious why this is implemented separately.
There was a problem hiding this comment.
I didn't want pollute the driver.rs file with helper functions. The driver is the main entry point into the MBT code and I usually try to keep it clean and focused on the translation between quint actions and its associated code. Happy to move things around if needed, though.
| let peer_id = PeerId::from_multihash(Default::default()) | ||
| .map_err(|err| anyhow!("Failed to create peer id: {err:?}"))?; |
There was a problem hiding this comment.
so, it's always from the same peer_id?
There was a problem hiding this comment.
Yes. Because we deliver all parts at once, I didn't find that to be a problem. I can try and make for some randomized ids if you think it can improve coverage.
| F: FnOnce(&'a mut Sut, &'a mut History) -> Fut, | ||
| Fut: Future<Output = Result<()>>, |
There was a problem hiding this comment.
don't know if it'll fit nicely but there exists AsyncFnOnce.
There was a problem hiding this comment.
I'm fought the borrow checker for 5m and didn't win. AsyncFnOnce seems like an nice interface. I'll try again later and see if I get a better luck.
2f24a10 to
c083964
Compare
|
@rnbguy thank you for the detailed review 🙏 I've addressed most comments and left a few replies. |
This patch connects the newly added Quint specs to Emerald's code via the Quint Connect library.
c083964 to
ffc1a1e
Compare
This patch connects the newly added Quint specs to Emerald's code via the Quint Connect library.
PS: the best files to start reviewing are probable
tests.rsanddriver.rs.