diff --git a/substrate/demo/cli/src/lib.rs b/substrate/demo/cli/src/lib.rs index 73c72ab305087e7628de4fb522aeb6aea9ed1348..8c0a3711abcb176139c94c9078b63d48dd298cfe 100644 --- a/substrate/demo/cli/src/lib.rs +++ b/substrate/demo/cli/src/lib.rs @@ -77,7 +77,20 @@ pub fn run<I, T>(args: I) -> error::Result<()> where session_length: 720, // that's 1 hour per session. sessions_per_era: 24, // 24 hours per era. bonding_duration: 90, // 90 days per bond. - approval_ratio: 667, // 66.7% approvals required for legislation. + launch_period: 120 * 24 * 14, // 2 weeks per public referendum + voting_period: 120 * 24 * 28, // 4 weeks to discuss & vote on an active referendum + minimum_deposit: 1000, // 1000 as the minimum deposit for a referendum + candidacy_bond: 1000, // 1000 to become a council candidate + voter_bond: 100, // 100 down to vote for a candidate + present_slash_per_voter: 1, // slash by 1 per voter for an invalid presentation. + carry_count: 24, // carry over the 24 runners-up to the next council election + presentation_duration: 120 * 24, // one day for presenting winners. + council_election_voting_period: 7 * 120 * 24, // one week period between possible council elections. + council_term_duration: 180 * 120 * 24, // 180 day term duration for the council. + desired_seats: 0, // start with no council: we'll raise this once the stake has been dispersed a bit. + inactive_grace_period: 1, // one addition vote should go by before an inactive voter can be reaped. + cooloff_period: 90 * 120 * 24, // 90 day cooling off period if council member vetoes a proposal. + council_proposal_voting_period: 7 * 120 * 24, // 7 day voting period for council members. }; let prepare_genesis = || { storage = genesis_config.genesis_map(); diff --git a/substrate/demo/executor/src/lib.rs b/substrate/demo/executor/src/lib.rs index cd080871a1a83f0fda4d613e3283b8a7bf3a9040..3f55a5c247cdd2eafb6372e12833fd7e89513c32 100644 --- a/substrate/demo/executor/src/lib.rs +++ b/substrate/demo/executor/src/lib.rs @@ -39,9 +39,9 @@ mod tests { use super::Executor; use substrate_executor::WasmExecutor; use codec::{KeyedVec, Slicable, Joiner}; - use keyring::Keyring; + use keyring::Keyring::{self, One, Two}; use runtime_support::Hashable; - use demo_runtime::runtime::staking::balance; + use demo_runtime::runtime::staking::{self, balance, BALANCE_OF}; use state_machine::{CodeExecutor, TestExternalities}; use primitives::twox_128; use demo_primitives::{Hash, Header, BlockNumber, Block, Digest, Transaction, @@ -60,9 +60,9 @@ mod tests { fn tx() -> UncheckedTransaction { let transaction = Transaction { - signed: Keyring::One.to_raw_public(), + signed: One.into(), nonce: 0, - function: Function::StakingTransfer(Keyring::Two.to_raw_public(), 69), + function: Function::StakingTransfer(Two.into(), 69), }; let signature = Keyring::from_raw_public(transaction.signed).unwrap() .sign(&transaction.encode()); @@ -72,9 +72,8 @@ mod tests { #[test] fn panic_execution_with_foreign_code_gives_error() { - let one = Keyring::One.to_raw_public(); 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] + twox_128(&One.to_raw_public().to_keyed_vec(BALANCE_OF)).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())); @@ -83,9 +82,8 @@ mod tests { #[test] fn panic_execution_with_native_equivalent_code_gives_error() { - let one = Keyring::One.to_raw_public(); 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] + twox_128(&One.to_raw_public().to_keyed_vec(BALANCE_OF)).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())); @@ -94,62 +92,36 @@ mod tests { #[test] fn successful_execution_with_native_equivalent_code_gives_ok() { - let one = Keyring::One.to_raw_public(); - let two = Keyring::Two.to_raw_public(); - 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] + twox_128(&One.to_raw_public().to_keyed_vec(BALANCE_OF)).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()); runtime_io::with_externalities(&mut t, || { - assert_eq!(balance(&one), 42); - assert_eq!(balance(&two), 69); + assert_eq!(balance(&One), 42); + assert_eq!(balance(&Two), 69); }); } #[test] fn successful_execution_with_foreign_code_gives_ok() { - let one = Keyring::One.to_raw_public(); - let two = Keyring::Two.to_raw_public(); - 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] + twox_128(&One.to_raw_public().to_keyed_vec(BALANCE_OF)).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()); runtime_io::with_externalities(&mut t, || { - assert_eq!(balance(&one), 42); - assert_eq!(balance(&two), 69); + assert_eq!(balance(&One), 42); + assert_eq!(balance(&Two), 69); }); } fn new_test_ext() -> TestExternalities { - let one = Keyring::One.to_raw_public(); - let two = Keyring::Two.to_raw_public(); - let three = [3u8; 32]; - - 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), - twox_128(b"ses:val:len").to_vec() => vec![].and(&3u32), - twox_128(&0u32.to_keyed_vec(b"ses:val:")).to_vec() => one.to_vec(), - twox_128(&1u32.to_keyed_vec(b"ses:val:")).to_vec() => two.to_vec(), - twox_128(&2u32.to_keyed_vec(b"ses:val:")).to_vec() => three.to_vec(), - twox_128(b"sta:wil:len").to_vec() => vec![].and(&3u32), - twox_128(&0u32.to_keyed_vec(b"sta:wil:")).to_vec() => one.to_vec(), - twox_128(&1u32.to_keyed_vec(b"sta:wil:")).to_vec() => two.to_vec(), - twox_128(&2u32.to_keyed_vec(b"sta:wil:")).to_vec() => three.to_vec(), - twox_128(b"sta:spe").to_vec() => vec![].and(&2u64), - 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] - ] + staking::testing::externalities(2, 2, 0) } fn construct_block(number: BlockNumber, parent_hash: Hash, state_root: Hash, txs: Vec<Transaction>) -> (Vec<u8>, Hash) { @@ -180,11 +152,11 @@ mod tests { construct_block( 1, [69u8; 32].into(), - hex!("2481853da20b9f4322f34650fea5f240dcbfb266d02db94bfa0153c31f4a29db").into(), + hex!("6f0202ee141932f5cf9efad76d9200ec0ae98e2782335c5c7940be6a66bb9418").into(), vec![Transaction { - signed: Keyring::One.to_raw_public(), + signed: One.into(), nonce: 0, - function: Function::StakingTransfer(Keyring::Two.to_raw_public(), 69), + function: Function::StakingTransfer(Two.into(), 69), }] ) } @@ -193,17 +165,17 @@ mod tests { construct_block( 2, block1().1, - hex!("1feb4d3a2e587079e6ce1685fa79994efd995e33cb289d39cded67aac1bb46a9").into(), + hex!("04a2ca0ff5cdbe6a0ceb75009b4e707c8d052f28c95e9a7751ea814b13b95c92").into(), vec![ Transaction { - signed: Keyring::Two.to_raw_public(), + signed: Two.into(), nonce: 0, - function: Function::StakingTransfer(Keyring::One.to_raw_public(), 5), + function: Function::StakingTransfer(One.into(), 5), }, Transaction { - signed: Keyring::One.to_raw_public(), + signed: One.into(), nonce: 1, - function: Function::StakingTransfer(Keyring::Two.to_raw_public(), 15), + function: Function::StakingTransfer(Two.into(), 15), } ] ) @@ -216,15 +188,15 @@ mod tests { Executor::new().call(&mut t, COMPACT_CODE, "execute_block", &block1().0).unwrap(); runtime_io::with_externalities(&mut t, || { - assert_eq!(balance(&Keyring::One.to_raw_public()), 42); - assert_eq!(balance(&Keyring::Two.to_raw_public()), 69); + assert_eq!(balance(&One), 42); + assert_eq!(balance(&Two), 69); }); Executor::new().call(&mut t, COMPACT_CODE, "execute_block", &block2().0).unwrap(); runtime_io::with_externalities(&mut t, || { - assert_eq!(balance(&Keyring::One.to_raw_public()), 32); - assert_eq!(balance(&Keyring::Two.to_raw_public()), 79); + assert_eq!(balance(&One), 32); + assert_eq!(balance(&Two), 79); }); } @@ -235,23 +207,22 @@ mod tests { WasmExecutor.call(&mut t, COMPACT_CODE, "execute_block", &block1().0).unwrap(); runtime_io::with_externalities(&mut t, || { - assert_eq!(balance(&Keyring::One.to_raw_public()), 42); - assert_eq!(balance(&Keyring::Two.to_raw_public()), 69); + assert_eq!(balance(&One), 42); + assert_eq!(balance(&Two), 69); }); WasmExecutor.call(&mut t, COMPACT_CODE, "execute_block", &block2().0).unwrap(); runtime_io::with_externalities(&mut t, || { - assert_eq!(balance(&Keyring::One.to_raw_public()), 32); - assert_eq!(balance(&Keyring::Two.to_raw_public()), 79); + assert_eq!(balance(&One), 32); + assert_eq!(balance(&Two), 79); }); } #[test] fn panic_execution_gives_error() { - let one = Keyring::One.to_raw_public(); 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] + twox_128(&One.to_raw_public().to_keyed_vec(BALANCE_OF)).to_vec() => vec![68u8, 0, 0, 0, 0, 0, 0, 0] ]; let foreign_code = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/demo_runtime.wasm"); @@ -261,11 +232,8 @@ mod tests { #[test] fn successful_execution_gives_ok() { - let one = Keyring::One.to_raw_public(); - let two = Keyring::Two.to_raw_public(); - 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] + twox_128(&One.to_raw_public().to_keyed_vec(BALANCE_OF)).to_vec() => vec![111u8, 0, 0, 0, 0, 0, 0, 0] ]; let foreign_code = include_bytes!("../../runtime/wasm/target/wasm32-unknown-unknown/release/demo_runtime.compact.wasm"); @@ -273,8 +241,8 @@ mod tests { assert!(r.is_ok()); runtime_io::with_externalities(&mut t, || { - assert_eq!(balance(&one), 42); - assert_eq!(balance(&two), 69); + assert_eq!(balance(&One), 42); + assert_eq!(balance(&Two), 69); }); } } diff --git a/substrate/demo/runtime/Cargo.toml b/substrate/demo/runtime/Cargo.toml index f98345cae6d1001d1f32fbe183b1d0292ac94d98..bcd3f5dcf00baf4e6b55082bf5914e651b31feb2 100644 --- a/substrate/demo/runtime/Cargo.toml +++ b/substrate/demo/runtime/Cargo.toml @@ -12,12 +12,10 @@ substrate-runtime-std = { path = "../../substrate/runtime-std" } substrate-runtime-io = { path = "../../substrate/runtime-io" } substrate-runtime-support = { path = "../../substrate/runtime-support" } substrate-primitives = { path = "../../substrate/primitives" } +substrate-keyring = { path = "../../substrate/keyring" } demo-primitives = { path = "../primitives" } integer-sqrt = "0.1.0" -[dev-dependencies] -substrate-keyring = { path = "../../substrate/keyring" } - [features] default = ["std"] std = [ diff --git a/substrate/demo/runtime/src/genesismap.rs b/substrate/demo/runtime/src/genesismap.rs index 5e7634cc646a9b737d3646ad81b69eab90a2a789..c3b7da1b7d8c2f4e2ffe84f6b63d6a727af1270a 100644 --- a/substrate/demo/runtime/src/genesismap.rs +++ b/substrate/demo/runtime/src/genesismap.rs @@ -23,6 +23,7 @@ use runtime_support::Hashable; use primitives::Block; use demo_primitives::{BlockNumber, AccountId}; use runtime::staking::Balance; +use runtime::{staking, session, consensus, system, democracy, council, council_vote}; /// Configuration of a general Substrate Demo genesis block. pub struct GenesisConfig { @@ -33,7 +34,20 @@ pub struct GenesisConfig { pub session_length: BlockNumber, pub sessions_per_era: BlockNumber, pub bonding_duration: BlockNumber, - pub approval_ratio: u32, + pub launch_period: BlockNumber, + pub voting_period: BlockNumber, + pub minimum_deposit: Balance, + pub candidacy_bond: Balance, + pub voter_bond: Balance, + pub present_slash_per_voter: Balance, + pub carry_count: u32, + pub presentation_duration: BlockNumber, + pub council_election_voting_period: BlockNumber, + pub council_term_duration: BlockNumber, + pub desired_seats: u32, + pub inactive_grace_period: BlockNumber, + pub cooloff_period: BlockNumber, + pub council_proposal_voting_period: BlockNumber, } impl GenesisConfig { @@ -42,43 +56,69 @@ impl GenesisConfig { validators: authorities_validators.clone(), authorities: authorities_validators.clone(), balances: authorities_validators.iter().map(|v| (v.clone(), balance)).collect(), - block_time: 5, // 5 second block time. - session_length: 720, // that's 1 hour per session. + block_time: 30, // 30 second block time. + session_length: 120, // that's 1 hour per session. sessions_per_era: 24, // 24 hours per era. bonding_duration: 90, // 90 days per bond. - approval_ratio: 667, // 66.7% approvals required for legislation. + launch_period: 120 * 24 * 14, // 2 weeks per public referendum + voting_period: 120 * 24 * 28, // 4 weeks to discuss & vote on an active referendum + minimum_deposit: 1000, // 1000 as the minimum deposit for a referendum + candidacy_bond: 1000, // 1000 to become a council candidate + voter_bond: 100, // 100 down to vote for a candidate + present_slash_per_voter: 1, // slash by 1 per voter for an invalid presentation. + carry_count: 24, // carry over the 24 runners-up to the next council election + presentation_duration: 120 * 24, // one day for presenting winners. + council_election_voting_period: 7 * 120 * 24, // one week period between possible council elections. + council_term_duration: 180 * 120 * 24, // 180 day term duration for the council. + desired_seats: 0, // start with no council: we'll raise this once the stake has been dispersed a bit. + inactive_grace_period: 1, // one addition vote should go by before an inactive voter can be reaped. + cooloff_period: 90 * 120 * 24, // 90 day cooling off period if council member vetoes a proposal. + council_proposal_voting_period: 7 * 120 * 24, // 7 day voting period for council members. } } pub fn genesis_map(&self) -> HashMap<Vec<u8>, Vec<u8>> { let wasm_runtime = include_bytes!("../wasm/genesis.wasm").to_vec(); vec![ - (&b"gov:apr"[..], vec![].and(&self.approval_ratio)), - (&b"ses:len"[..], vec![].and(&self.session_length)), - (&b"ses:val:len"[..], vec![].and(&(self.validators.len() as u32))), - (&b"sta:wil:len"[..], vec![].and(&0u32)), - (&b"sta:spe"[..], vec![].and(&self.sessions_per_era)), - (&b"sta:vac"[..], vec![].and(&(self.validators.len() as u32))), - (&b"sta:era"[..], vec![].and(&0u64)), + (&session::SESSION_LENGTH[..], vec![].and(&self.session_length)), + (&session::VALIDATOR_COUNT[..], vec![].and(&(self.validators.len() as u32))), + + (&staking::INTENTION_COUNT[..], vec![].and(&0u32)), + (&staking::SESSIONS_PER_ERA[..], vec![].and(&self.sessions_per_era)), + (&staking::CURRENT_ERA[..], vec![].and(&0u64)), + + (&democracy::LAUNCH_PERIOD[..], vec![].and(&self.launch_period)), + (&democracy::VOTING_PERIOD[..], vec![].and(&self.voting_period)), + (&democracy::MINIMUM_DEPOSIT[..], vec![].and(&self.minimum_deposit)), + + (&council::CANDIDACY_BOND[..], vec![].and(&self.candidacy_bond)), + (&council::VOTING_BOND[..], vec![].and(&self.voter_bond)), + (&council::PRESENT_SLASH_PER_VOTER[..], vec![].and(&self.present_slash_per_voter)), + (&council::CARRY_COUNT[..], vec![].and(&self.carry_count)), + (&council::PRESENTATION_DURATION[..], vec![].and(&self.presentation_duration)), + (&council::VOTING_PERIOD[..], vec![].and(&self.council_election_voting_period)), + (&council::TERM_DURATION[..], vec![].and(&self.council_term_duration)), + (&council::DESIRED_SEATS[..], vec![].and(&self.desired_seats)), + (&council::INACTIVE_GRACE_PERIOD[..], vec![].and(&self.inactive_grace_period)), + + (&council_vote::COOLOFF_PERIOD[..], vec![].and(&self.cooloff_period)), + (&council_vote::VOTING_PERIOD[..], vec![].and(&self.council_proposal_voting_period)) ].into_iter() .map(|(k, v)| (k.into(), v)) .chain(self.validators.iter() .enumerate() - .map(|(i, account)| ((i as u32).to_keyed_vec(b"ses:val:"), vec![].and(account))) - ).chain(self.authorities.iter() - .enumerate() - .map(|(i, account)| ((i as u32).to_keyed_vec(b":auth:"), vec![].and(account))) + .map(|(i, account)| ((i as u32).to_keyed_vec(session::VALIDATOR_AT), vec![].and(account))) ).chain(self.balances.iter() - .map(|&(account, balance)| (account.to_keyed_vec(b"sta:bal:"), vec![].and(&balance))) + .map(|&(account, balance)| (account.to_keyed_vec(staking::BALANCE_OF), vec![].and(&balance))) ) .map(|(k, v)| (twox_128(&k[..])[..].to_vec(), v.to_vec())) .chain(vec![ - (b":code"[..].into(), wasm_runtime), - (b":auth:len"[..].into(), vec![].and(&(self.authorities.len() as u32))), + (system::CODE[..].into(), wasm_runtime), + (consensus::AUTHORITY_COUNT[..].into(), vec![].and(&(self.authorities.len() as u32))), ].into_iter()) .chain(self.authorities.iter() .enumerate() - .map(|(i, account)| ((i as u32).to_keyed_vec(b":auth:"), vec![].and(account))) + .map(|(i, account)| ((i as u32).to_keyed_vec(consensus::AUTHORITY_AT), vec![].and(account))) ) .collect() } @@ -87,6 +127,6 @@ impl GenesisConfig { pub fn additional_storage_with_genesis(genesis_block: &Block) -> HashMap<Vec<u8>, Vec<u8>> { use codec::Slicable; map![ - twox_128(&0u64.to_keyed_vec(b"sys:old:")).to_vec() => genesis_block.header.blake2_256().encode() + twox_128(&0u64.to_keyed_vec(system::BLOCK_HASH_AT)).to_vec() => genesis_block.header.blake2_256().encode() ] } diff --git a/substrate/demo/runtime/src/lib.rs b/substrate/demo/runtime/src/lib.rs index 110061ee7c4c5080be992ce93cbbd528ef112c30..a351da4230daaef0e3cc458072d61ca4c15b9aad 100644 --- a/substrate/demo/runtime/src/lib.rs +++ b/substrate/demo/runtime/src/lib.rs @@ -18,10 +18,10 @@ #![cfg_attr(not(feature = "std"), no_std)] -#[macro_use] extern crate substrate_runtime_std as rstd; +#[allow(unused_imports)] #[macro_use] extern crate substrate_runtime_std as rstd; #[macro_use] extern crate substrate_runtime_io as runtime_io; extern crate substrate_runtime_support as runtime_support; -#[cfg(all(feature = "std", test))] extern crate substrate_keyring as keyring; +#[cfg(any(feature = "std", test))] extern crate substrate_keyring as keyring; #[cfg(feature = "std")] extern crate rustc_hex; diff --git a/substrate/demo/runtime/src/runtime/consensus.rs b/substrate/demo/runtime/src/runtime/consensus.rs index eca7bd46bb7b0aa9fa4a34e601f25d7ab35a7159..8d631d0bb8e9c2a31a8e5eb11e5a93ca548db8ed 100644 --- a/substrate/demo/runtime/src/runtime/consensus.rs +++ b/substrate/demo/runtime/src/runtime/consensus.rs @@ -21,6 +21,7 @@ use runtime_support::storage::unhashed::StorageVec; use demo_primitives::SessionKey; pub const AUTHORITY_AT: &'static[u8] = b":auth:"; +pub const AUTHORITY_COUNT: &'static[u8] = b":auth:len"; struct AuthorityStorageVec {} impl StorageVec for AuthorityStorageVec { diff --git a/substrate/demo/runtime/src/runtime/council.rs b/substrate/demo/runtime/src/runtime/council.rs index 620405bdfdecb76add1b51a32b87bceb7c88a741..a9e217ac97c6f05c5c02023e923b5785822f629f 100644 --- a/substrate/demo/runtime/src/runtime/council.rs +++ b/substrate/demo/runtime/src/runtime/council.rs @@ -560,11 +560,11 @@ pub mod testing { twox_128(CANDIDACY_BOND).to_vec() => vec![].and(&9u64), twox_128(VOTING_BOND).to_vec() => vec![].and(&3u64), twox_128(PRESENT_SLASH_PER_VOTER).to_vec() => vec![].and(&1u64), - twox_128(CARRY_COUNT).to_vec() => vec![].and(&2u64), + twox_128(CARRY_COUNT).to_vec() => vec![].and(&2u32), twox_128(PRESENTATION_DURATION).to_vec() => vec![].and(&2u64), twox_128(VOTING_PERIOD).to_vec() => vec![].and(&4u64), twox_128(TERM_DURATION).to_vec() => vec![].and(&5u64), - twox_128(DESIRED_SEATS).to_vec() => vec![].and(&2u64), + twox_128(DESIRED_SEATS).to_vec() => vec![].and(&2u32), twox_128(INACTIVE_GRACE_PERIOD).to_vec() => vec![].and(&1u32) ]; democracy::testing::externalities() diff --git a/substrate/demo/runtime/src/runtime/session.rs b/substrate/demo/runtime/src/runtime/session.rs index 193274b5682657be2fd7646741b3a7e94fbafead..c5c5387dd9b57e35d078c27e4c4a34098f889e98 100644 --- a/substrate/demo/runtime/src/runtime/session.rs +++ b/substrate/demo/runtime/src/runtime/session.rs @@ -133,7 +133,7 @@ fn rotate_session() { }); } -#[cfg(test)] +#[cfg(any(feature = "std", test))] pub mod testing { use super::*; use runtime_io::{twox_128, TestExternalities}; diff --git a/substrate/demo/runtime/src/runtime/staking.rs b/substrate/demo/runtime/src/runtime/staking.rs index fea37d938359a6525135fac95b362044771eba8d..ad782c22d1799bd29cf795b5242ae5076c69566b 100644 --- a/substrate/demo/runtime/src/runtime/staking.rs +++ b/substrate/demo/runtime/src/runtime/staking.rs @@ -518,7 +518,7 @@ fn new_era() { ); } -#[cfg(test)] +#[cfg(any(feature = "std", test))] pub mod testing { use super::*; use runtime_io::{twox_128, TestExternalities}; diff --git a/substrate/demo/runtime/src/runtime/system.rs b/substrate/demo/runtime/src/runtime/system.rs index 765e29e01ec5bb2facb5f3adf3f86abc7edef75c..1344e365c174dd40ddec67ba3d2ec361dedb1b32 100644 --- a/substrate/demo/runtime/src/runtime/system.rs +++ b/substrate/demo/runtime/src/runtime/system.rs @@ -223,7 +223,7 @@ fn info_expect_equal_hash(given: &Hash, expected: &Hash) { } } -#[cfg(test)] +#[cfg(any(feature = "std", test))] pub mod testing { use super::*; use runtime_io::{twox_128, TestExternalities};