Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update modelator to 0.2.0 #1249

Merged
merged 6 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ optional = true
env_logger = "0.9.0"
tracing-subscriber = "0.2.19"
test-env-log = { version = "0.2.7", features = ["trace"] }
modelator = { git = "https://github.com/informalsystems/modelator", rev = "99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd" }
modelator = "0.2.0"
tendermint-rpc = { version = "=0.21.0", features = ["http-client", "websocket-client"] }
tendermint-testgen = { version = "=0.21.0" } # Needed for generating (synthetic) light blocks.
sha2 = { version = "0.9.3" }
Expand Down
12 changes: 7 additions & 5 deletions modules/tests/mbt.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod runner;

use modelator::{run, TestError};
use runner::{step::Step, IbcTestRunner};
use modelator::{ModelChecker, TestError, run_tla_steps};
use runner::IbcTestRunner;

#[test]
fn mbt() {
Expand All @@ -12,12 +12,14 @@ fn mbt() {
}
}

fn run_tests() -> Result<(), TestError<IbcTestRunner, Step>> {
fn run_tests() -> Result<(), TestError> {
// run the test
let tla_tests_file = "tests/support/model_based/IBCTests.tla";
let tla_config_file = "tests/support/model_based/IBCTests.cfg";
let runner = IbcTestRunner::new();
run(tla_tests_file, tla_config_file, runner)?;
let mut opts = modelator::Options::default();
opts.model_checker_options.model_checker = ModelChecker::Tlc;
let mut runner = IbcTestRunner::new();
run_tla_steps(tla_tests_file, tla_config_file, &opts, &mut runner)?;

Ok(())
}
18 changes: 11 additions & 7 deletions modules/tests/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl IbcTestRunner {
max_history_size,
Height::new(Self::revision(), initial_height),
);
assert!(self.contexts.insert(chain_id, ctx).is_none());
self.contexts.insert(chain_id, ctx);
jtremback marked this conversation as resolved.
Show resolved Hide resolved
}

/// Returns a reference to the `MockContext` of a given `chain_id`.
Expand Down Expand Up @@ -436,8 +436,8 @@ impl IbcTestRunner {
}
}

impl modelator::runner::TestRunner<Step> for IbcTestRunner {
fn initial_step(&mut self, step: Step) -> bool {
impl modelator::step_runner::StepRunner<Step> for IbcTestRunner {
fn initial_step(&mut self, step: Step) -> Result<(), String> {
assert_eq!(step.action, Action::None, "unexpected action type");
assert_eq!(
step.action_outcome,
Expand All @@ -448,11 +448,11 @@ impl modelator::runner::TestRunner<Step> for IbcTestRunner {
for (chain_id, chain) in step.chains {
self.init_chain_context(chain_id, chain.height);
}
true
Ok(())
}

fn next_step(&mut self, step: Step) -> bool {
let result = self.apply(step.action);
fn next_step(&mut self, step: Step) -> Result<(), String> {
let result = self.apply(step.clone().action);
jtremback marked this conversation as resolved.
Show resolved Hide resolved
let outcome_matches = match step.action_outcome {
ActionOutcome::None => panic!("unexpected action outcome"),
ActionOutcome::Ics02CreateOk => result.is_ok(),
Expand Down Expand Up @@ -499,6 +499,10 @@ impl modelator::runner::TestRunner<Step> for IbcTestRunner {
ActionOutcome::Ics03ConnectionOpenConfirmOk => result.is_ok(),
};
// also check the state of chains
outcome_matches && self.validate_chains() && self.check_chain_states(step.chains)
if outcome_matches && self.validate_chains() && self.check_chain_states(step.chains) {
Ok(())
} else {
Err("next_step did not conclude successfully".into())
}
}
}