From 56ab4e56d0081edb221585828a509d9829d65528 Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Fri, 12 Feb 2021 11:37:47 +0100 Subject: [PATCH 1/4] Add structure to MBT --- .../tests/{model_based.rs => executor/mod.rs} | 8 ++++---- modules/tests/{ => executor}/modelator.rs | 0 modules/tests/{ => executor}/step.rs | 0 modules/tests/mbt.rs | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+), 4 deletions(-) rename modules/tests/{model_based.rs => executor/mod.rs} (99%) rename modules/tests/{ => executor}/modelator.rs (100%) rename modules/tests/{ => executor}/step.rs (100%) create mode 100644 modules/tests/mbt.rs diff --git a/modules/tests/model_based.rs b/modules/tests/executor/mod.rs similarity index 99% rename from modules/tests/model_based.rs rename to modules/tests/executor/mod.rs index 5f11385afd..3a9ef9d18d 100644 --- a/modules/tests/model_based.rs +++ b/modules/tests/executor/mod.rs @@ -1,5 +1,5 @@ -mod modelator; -mod step; +pub mod modelator; +pub mod step; use ibc::ics02_client::client_def::{AnyClientState, AnyConsensusState, AnyHeader}; use ibc::ics02_client::client_type::ClientType; @@ -24,13 +24,13 @@ use step::{ActionOutcome, ActionType, Chain, Step}; use tendermint::account::Id as AccountId; #[derive(Debug)] -struct IBCTestExecutor { +pub struct IBCTestExecutor { // mapping from chain identifier to its context contexts: HashMap, } impl IBCTestExecutor { - fn new() -> Self { + pub fn new() -> Self { Self { contexts: Default::default(), } diff --git a/modules/tests/modelator.rs b/modules/tests/executor/modelator.rs similarity index 100% rename from modules/tests/modelator.rs rename to modules/tests/executor/modelator.rs diff --git a/modules/tests/step.rs b/modules/tests/executor/step.rs similarity index 100% rename from modules/tests/step.rs rename to modules/tests/executor/step.rs diff --git a/modules/tests/mbt.rs b/modules/tests/mbt.rs new file mode 100644 index 0000000000..ad85e09a75 --- /dev/null +++ b/modules/tests/mbt.rs @@ -0,0 +1,18 @@ +mod executor; + +const TESTS_DIR: &str = "tests/support/model_based/tests"; + +#[test] +fn model_based() { + let tests = vec!["ICS02UpdateOKTest", "ICS02HeaderVerificationFailureTest"]; + + for test in tests { + let test = format!("{}/{}.json", TESTS_DIR, test); + let executor = executor::IBCTestExecutor::new(); + // we should be able to just return the `Result` once the following issue + // is fixed: https://github.com/rust-lang/rust/issues/43301 + if let Err(e) = executor::modelator::test(&test, executor) { + panic!("{:?}", e); + } + } +} From d10aa8e23c328293e80164d4549793bb1a7ef61e Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Fri, 12 Feb 2021 11:45:26 +0100 Subject: [PATCH 2/4] Only run model_based test if mocks feature is enabled --- modules/Cargo.toml | 5 +++++ modules/tests/README.md | 2 +- modules/tests/mbt.rs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/Cargo.toml b/modules/Cargo.toml index e30594b7d4..1019f4a135 100644 --- a/modules/Cargo.toml +++ b/modules/Cargo.toml @@ -53,3 +53,8 @@ optional = true tokio = { version = "1.0", features = ["macros"] } tendermint-rpc = { version = "=0.18.0", features = ["http-client", "websocket-client"] } tendermint-testgen = { version = "=0.18.0" } # Needed for generating (synthetic) light blocks. + +[[test]] +name = "mbt" +path = "tests/mbt.rs" +required-features = ["mocks"] diff --git a/modules/tests/README.md b/modules/tests/README.md index 54e6491585..670f5b521e 100644 --- a/modules/tests/README.md +++ b/modules/tests/README.md @@ -59,5 +59,5 @@ These are currently generated manually, but can be easily mapped to Rust (see [s The model-based tests can be run with the following command: ```bash -cargo test -p ibc --features mocks -- model_based +cargo test --features mocks -- mbt ``` diff --git a/modules/tests/mbt.rs b/modules/tests/mbt.rs index ad85e09a75..4ac8059990 100644 --- a/modules/tests/mbt.rs +++ b/modules/tests/mbt.rs @@ -3,7 +3,7 @@ mod executor; const TESTS_DIR: &str = "tests/support/model_based/tests"; #[test] -fn model_based() { +fn mbt() { let tests = vec!["ICS02UpdateOKTest", "ICS02HeaderVerificationFailureTest"]; for test in tests { From bb1062af5284070d597db5998b21cdeeedff9228 Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Fri, 12 Feb 2021 11:48:15 +0100 Subject: [PATCH 3/4] Remove model_based test from the executor --- modules/tests/executor/mod.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/modules/tests/executor/mod.rs b/modules/tests/executor/mod.rs index 3a9ef9d18d..7dafed984c 100644 --- a/modules/tests/executor/mod.rs +++ b/modules/tests/executor/mod.rs @@ -250,20 +250,3 @@ impl modelator::TestExecutor for IBCTestExecutor { outcome_matches && self.check_chain_heights(step.chains) } } - -const TESTS_DIR: &str = "tests/support/model_based/tests"; - -#[test] -fn model_based() { - let tests = vec!["ICS02UpdateOKTest", "ICS02HeaderVerificationFailureTest"]; - - for test in tests { - let test = format!("{}/{}.json", TESTS_DIR, test); - let executor = IBCTestExecutor::new(); - // we should be able to just return the `Result` once the following issue - // is fixed: https://github.com/rust-lang/rust/issues/43301 - if let Err(e) = modelator::test(&test, executor) { - panic!("{:?}", e); - } - } -} From 361e046ac94cfc0ce8e45a9bd453bfa08fdcb56b Mon Sep 17 00:00:00 2001 From: Vitor Enes Date: Fri, 12 Feb 2021 15:56:13 +0100 Subject: [PATCH 4/4] update CHANGELOG --- CHANGELOG.md | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d4c1f4a25..6653a00071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,13 +29,14 @@ ### BUG FIXES - [ibc] - - [nothing yet] + - Fix panic in conn open try when no connection id is provided ([#626]) + - Disable MBT tests if the "mocks" feature is not enabled ([#643]) - [ibc-relayer] - [nothing yet] - [ibc-relayer-cli] - - [nothing yet] + - Fix wrong acks sent with `tx raw packet-ack` in a 3-chain setup ([#614]) ### BREAKING CHANGES @@ -49,23 +50,12 @@ - [ibc-relayer-cli] - [nothing yet] -### BUG FIXES - -- [ibc] - - Fix panic in conn open try when no connection id is provided ([#626]) - -- [ibc-relayer] - - [nothing yet] - -- [ibc-relayer-cli] - - Fix wrong acks sent with `tx raw packet-ack` in a 3-chain setup ([#614]) - - [#316]: https://github.com/informalsystems/ibc-rs/issues/316 [#560]: https://github.com/informalsystems/ibc-rs/issues/560 [#614]: https://github.com/informalsystems/ibc-rs/issues/614 [#624]: https://github.com/informalsystems/ibc-rs/issues/624 [#626]: https://github.com/informalsystems/ibc-rs/issues/626 +[#643]: https://github.com/informalsystems/ibc-rs/issues/643 ## v0.1.0 *February 4, 2021*