From 05a5292ee1396d9df0bad6646452eece85d95865 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Tue, 22 Oct 2019 11:25:42 +0200 Subject: [PATCH 1/2] Make tests work after the changes introduced in #3793 --- Cargo.lock | 3 ++- srml/bridge/Cargo.toml | 1 + srml/bridge/src/lib.rs | 10 ++++------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc66df3025217..e8b18d94a793d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4078,13 +4078,14 @@ name = "srml-bridge" version = "0.1.0" dependencies = [ "hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-scale-codec 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-scale-codec 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "srml-session 2.0.0", "srml-support 2.0.0", "srml-system 2.0.0", + "substrate-externalities 2.0.0", "substrate-primitives 2.0.0", "substrate-state-machine 2.0.0", "substrate-trie 2.0.0", diff --git a/srml/bridge/Cargo.toml b/srml/bridge/Cargo.toml index 92c93954bf186..a43cfdf25a5a6 100644 --- a/srml/bridge/Cargo.toml +++ b/srml/bridge/Cargo.toml @@ -17,6 +17,7 @@ system = { package = "srml-system", path = "../system", default-features = false trie = { package = "substrate-trie", path = "../../core/trie", default-features = false } [dev-dependencies] +externalities = { package = "substrate-externalities", path = "../../core/externalities" } primitives = { package = "substrate-primitives", path = "../../core/primitives" } runtime-io = { package = "sr-io", path = "../../core/sr-io", default-features = false } state-machine = { package = "substrate-state-machine", path = "../../core/state-machine" } diff --git a/srml/bridge/src/lib.rs b/srml/bridge/src/lib.rs index 625e22915d21c..f437c0445dd5b 100644 --- a/srml/bridge/src/lib.rs +++ b/srml/bridge/src/lib.rs @@ -149,12 +149,11 @@ impl Module { mod tests { use super::*; - use primitives::{H256, Blake2Hasher}; + use primitives::H256; use sr_primitives::{ Perbill, traits::{Header as HeaderT, IdentityLookup}, testing::Header, generic::Digest, }; use support::{assert_ok, impl_outer_origin, parameter_types}; - use runtime_io::with_externalities; // NOTE: What's this for? impl_outer_origin! { @@ -188,7 +187,6 @@ mod tests { type AccountId = DummyValidatorId; type Lookup = IdentityLookup; type Header = Header; - type WeightMultiplierUpdate = (); type Event = (); type BlockHashCount = (); type MaximumBlockWeight = (); @@ -201,7 +199,7 @@ mod tests { type ValidatorId = DummyValidatorId; } - fn new_test_ext() -> runtime_io::TestExternalities { + fn new_test_ext() -> runtime_io::TestExternalities { let mut t = system::GenesisConfig::default().build_storage::().unwrap(); GenesisConfig { num_bridges: 0, @@ -211,7 +209,7 @@ mod tests { #[test] fn it_works_for_default_value() { - with_externalities(&mut new_test_ext(), || { + new_test_ext().execute_with(|| { assert_eq!(MockBridge::num_bridges(), 0); }); } @@ -228,7 +226,7 @@ mod tests { }; let test_hash = test_header.hash(); - with_externalities(&mut new_test_ext(), || { + new_test_ext().execute_with(|| { assert_eq!(MockBridge::num_bridges(), 0); assert_eq!(MockBridge::tracked_bridges(0), None); From 8a9eb3b4b8a97e2e0ae366069f8bb76aa974a7ea Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Tue, 22 Oct 2019 16:07:50 +0200 Subject: [PATCH 2/2] Remove unneccessary import --- srml/bridge/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/srml/bridge/Cargo.toml b/srml/bridge/Cargo.toml index a43cfdf25a5a6..92c93954bf186 100644 --- a/srml/bridge/Cargo.toml +++ b/srml/bridge/Cargo.toml @@ -17,7 +17,6 @@ system = { package = "srml-system", path = "../system", default-features = false trie = { package = "substrate-trie", path = "../../core/trie", default-features = false } [dev-dependencies] -externalities = { package = "substrate-externalities", path = "../../core/externalities" } primitives = { package = "substrate-primitives", path = "../../core/primitives" } runtime-io = { package = "sr-io", path = "../../core/sr-io", default-features = false } state-machine = { package = "substrate-state-machine", path = "../../core/state-machine" }