diff --git a/polkadot/executor/src/lib.rs b/polkadot/executor/src/lib.rs index a7cef0c3cb..f7ded05025 100644 --- a/polkadot/executor/src/lib.rs +++ b/polkadot/executor/src/lib.rs @@ -73,9 +73,9 @@ mod tests { #[test] fn panic_execution_with_foreign_code_gives_error() { let one = Keyring::One.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![68u8, 0, 0, 0, 0, 0, 0, 0] - ], }; + ]; let r = Executor::new().call(&mut t, BLOATY_CODE, "execute_transaction", &vec![].and(&Header::from_block_number(1u64)).and(&tx())); assert!(r.is_err()); @@ -84,9 +84,9 @@ mod tests { #[test] fn panic_execution_with_native_equivalent_code_gives_error() { let one = Keyring::One.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![68u8, 0, 0, 0, 0, 0, 0, 0] - ], }; + ]; let r = Executor::new().call(&mut t, COMPACT_CODE, "execute_transaction", &vec![].and(&Header::from_block_number(1u64)).and(&tx())); assert!(r.is_err()); @@ -97,9 +97,9 @@ mod tests { let one = Keyring::One.to_raw_public(); let two = Keyring::Two.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0] - ], }; + ]; let r = Executor::new().call(&mut t, COMPACT_CODE, "execute_transaction", &vec![].and(&Header::from_block_number(1u64)).and(&tx())); assert!(r.is_ok()); @@ -115,9 +115,9 @@ mod tests { let one = Keyring::One.to_raw_public(); let two = Keyring::Two.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0] - ], }; + ]; let r = Executor::new().call(&mut t, BLOATY_CODE, "execute_transaction", &vec![].and(&Header::from_block_number(1u64)).and(&tx())); assert!(r.is_ok()); @@ -133,7 +133,7 @@ mod tests { let two = Keyring::Two.to_raw_public(); let three = [3u8; 32]; - TestExternalities { storage: map![ + map![ twox_128(&0u64.to_keyed_vec(b"sys:old:")).to_vec() => [69u8; 32].encode(), twox_128(b"gov:apr").to_vec() => vec![].and(&667u32), twox_128(b"ses:len").to_vec() => vec![].and(&2u64), @@ -149,7 +149,7 @@ mod tests { twox_128(b"sta:vac").to_vec() => vec![].and(&3u64), twox_128(b"sta:era").to_vec() => vec![].and(&0u64), twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0] - ], } + ] } fn construct_block(number: BlockNumber, parent_hash: Hash, state_root: Hash, txs: Vec) -> (Vec, Hash) { @@ -250,9 +250,9 @@ mod tests { #[test] fn panic_execution_gives_error() { let one = Keyring::One.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![68u8, 0, 0, 0, 0, 0, 0, 0] - ], }; + ]; let foreign_code = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm"); let r = WasmExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &vec![].and(&Header::from_block_number(1u64)).and(&tx())); @@ -264,9 +264,9 @@ mod tests { let one = Keyring::One.to_raw_public(); let two = Keyring::Two.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0] - ], }; + ]; let foreign_code = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm"); let r = WasmExecutor.call(&mut t, &foreign_code[..], "execute_transaction", &vec![].and(&Header::from_block_number(1u64)).and(&tx())); diff --git a/polkadot/runtime/src/runtime/governance.rs b/polkadot/runtime/src/runtime/governance.rs index b8733b9776..9138a3eddf 100644 --- a/polkadot/runtime/src/runtime/governance.rs +++ b/polkadot/runtime/src/runtime/governance.rs @@ -157,7 +157,7 @@ mod tests { let two = Keyring::Two.to_raw_public(); let three = [3u8; 32]; - TestExternalities { storage: map![ + map![ twox_128(APPROVALS_REQUIRED).to_vec() => vec![].and(&667u32), twox_128(b"ses:len").to_vec() => vec![].and(&1u64), twox_128(b"ses:val:len").to_vec() => vec![].and(&3u32), @@ -171,7 +171,7 @@ mod tests { twox_128(b"sta:spe").to_vec() => vec![].and(&1u64), twox_128(b"sta:vac").to_vec() => vec![].and(&3u64), twox_128(b"sta:era").to_vec() => vec![].and(&1u64) - ], } + ] } #[test] diff --git a/polkadot/runtime/src/runtime/parachains.rs b/polkadot/runtime/src/runtime/parachains.rs index dd7485ddc8..1cd4151cf9 100644 --- a/polkadot/runtime/src/runtime/parachains.rs +++ b/polkadot/runtime/src/runtime/parachains.rs @@ -83,10 +83,10 @@ mod tests { use runtime::{consensus, session}; fn simple_setup() -> TestExternalities { - TestExternalities { storage: map![ + map![ twox_128(b"ses:val:len").to_vec() => vec![].and(&8u32), twox_128(b"par:cou").to_vec() => vec![].and(&2u32) - ], } + ] } #[test] diff --git a/polkadot/runtime/src/runtime/session.rs b/polkadot/runtime/src/runtime/session.rs index a3a43d88cc..e9bf5f3765 100644 --- a/polkadot/runtime/src/runtime/session.rs +++ b/polkadot/runtime/src/runtime/session.rs @@ -145,7 +145,7 @@ mod tests { use runtime::{consensus, session}; fn simple_setup() -> TestExternalities { - TestExternalities { storage: map![ + map![ twox_128(SESSION_LENGTH).to_vec() => vec![].and(&2u64), // the validators (10, 20, ...) twox_128(b"ses:val:len").to_vec() => vec![].and(&2u32), @@ -155,7 +155,7 @@ mod tests { b":auth:len".to_vec() => vec![].and(&2u32), 0u32.to_keyed_vec(b":auth:") => vec![11; 32], 1u32.to_keyed_vec(b":auth:") => vec![21; 32] - ], } + ] } #[test] diff --git a/polkadot/runtime/src/runtime/staking.rs b/polkadot/runtime/src/runtime/staking.rs index a66d43eeb9..0bb4372c6d 100644 --- a/polkadot/runtime/src/runtime/staking.rs +++ b/polkadot/runtime/src/runtime/staking.rs @@ -227,7 +227,7 @@ mod tests { let three = [3u8; 32]; let four = [4u8; 32]; - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(b"ses:len").to_vec() => vec![].and(&1u64), twox_128(b"ses:val:len").to_vec() => vec![].and(&2u32), twox_128(&0u32.to_keyed_vec(b"ses:val:")).to_vec() => vec![10; 32], @@ -239,7 +239,7 @@ mod tests { twox_128(&two.to_keyed_vec(BALANCE_OF)).to_vec() => vec![].and(&20u64), twox_128(&three.to_keyed_vec(BALANCE_OF)).to_vec() => vec![].and(&30u64), twox_128(&four.to_keyed_vec(BALANCE_OF)).to_vec() => vec![].and(&40u64) - ], }; + ]; with_externalities(&mut t, || { assert_eq!(era_length(), 2u64); @@ -296,10 +296,10 @@ mod tests { #[test] fn staking_eras_work() { - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(b"ses:len").to_vec() => vec![].and(&1u64), twox_128(SESSIONS_PER_ERA).to_vec() => vec![].and(&2u64) - ], }; + ]; with_externalities(&mut t, || { assert_eq!(era_length(), 2u64); assert_eq!(sessions_per_era(), 2u64); @@ -363,9 +363,9 @@ mod tests { let one = Keyring::One.to_raw_public(); let two = Keyring::Two.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(BALANCE_OF)).to_vec() => vec![].and(&42u64) - ], }; + ]; with_externalities(&mut t, || { assert_eq!(balance(&one), 42); @@ -378,9 +378,9 @@ mod tests { let one = Keyring::One.to_raw_public(); let two = Keyring::Two.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(BALANCE_OF)).to_vec() => vec![].and(&111u64) - ], }; + ]; with_externalities(&mut t, || { transfer(&one, &two, 69); @@ -395,9 +395,9 @@ mod tests { let one = Keyring::One.to_raw_public(); let two = Keyring::Two.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(BALANCE_OF)).to_vec() => vec![].and(&111u64) - ], }; + ]; with_externalities(&mut t, || { stake(&one); diff --git a/polkadot/runtime/src/runtime/system.rs b/polkadot/runtime/src/runtime/system.rs index 2f8f5c25c7..7d5e8835ed 100644 --- a/polkadot/runtime/src/runtime/system.rs +++ b/polkadot/runtime/src/runtime/system.rs @@ -247,9 +247,9 @@ mod tests { let one = Keyring::One.to_raw_public(); let two = Keyring::Two.to_raw_public(); - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0] - ], }; + ]; let tx = UncheckedTransaction { transaction: Transaction { @@ -272,7 +272,7 @@ mod tests { let two = Keyring::Two.to_raw_public(); let three = [3u8; 32]; - TestExternalities { storage: map![ + map![ twox_128(&0u64.to_keyed_vec(b"sys:old:")).to_vec() => [69u8; 32].encode(), twox_128(b"gov:apr").to_vec() => vec![].and(&667u32), twox_128(b"ses:len").to_vec() => vec![].and(&2u64), @@ -288,7 +288,7 @@ mod tests { twox_128(b"sta:vac").to_vec() => vec![].and(&3u64), twox_128(b"sta:era").to_vec() => vec![].and(&0u64), twox_128(&one.to_keyed_vec(b"sta:bal:")).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0] - ], } + ] } #[test] diff --git a/polkadot/runtime/src/runtime/timestamp.rs b/polkadot/runtime/src/runtime/timestamp.rs index c64a511ad0..0b96f39bd4 100644 --- a/polkadot/runtime/src/runtime/timestamp.rs +++ b/polkadot/runtime/src/runtime/timestamp.rs @@ -47,9 +47,9 @@ mod tests { #[test] fn timestamp_works() { - let mut t = TestExternalities { storage: map![ + let mut t: TestExternalities = map![ twox_128(CURRENT_TIMESTAMP).to_vec() => vec![].and(&42u64) - ], }; + ]; with_externalities(&mut t, || { assert_eq!(get(), 42); diff --git a/polkadot/runtime/wasm/genesis.wasm b/polkadot/runtime/wasm/genesis.wasm index 91c7b47574..bc0cb89235 100644 Binary files a/polkadot/runtime/wasm/genesis.wasm and b/polkadot/runtime/wasm/genesis.wasm differ diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm index 84e52dbc50..a1f28badf2 100644 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm differ diff --git a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm index a92614dcc2..160550b5c7 100644 Binary files a/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm and b/polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm differ