Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 9 additions & 3 deletions core/test-runtime/src/genesismap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use std::collections::HashMap;
use runtime_io::{blake2_256, twox_128};
use super::{AuthorityId, AccountId, WASM_BINARY};
use super::{AuthorityId, AccountId, WASM_BINARY, system};
use codec::{Encode, KeyedVec, Joiner};
use primitives::{ChangesTrieConfiguration, map, storage::well_known_keys};
use sr_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
Expand Down Expand Up @@ -77,10 +77,16 @@ impl GenesisConfig {
map.insert(well_known_keys::CHANGES_TRIE_CONFIG.to_vec(), changes_trie_config.encode());
}
map.insert(twox_128(&b"sys:auth"[..])[..].to_vec(), self.authorities.encode());
// Finally, add the extra storage entries.
// Add the extra storage entries.
map.extend(self.extra_storage.clone().into_iter());

(map, self.child_extra_storage.clone())
// Assimilate the system genesis config.
let mut storage = (map, self.child_extra_storage.clone());
let mut config = system::GenesisConfig::default();
config.authorities = self.authorities.clone();
config.assimilate_storage(&mut storage);

storage
}
}

Expand Down
29 changes: 20 additions & 9 deletions core/test-runtime/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
use rstd::prelude::*;
use runtime_io::{storage_root, storage_changes_root, blake2_256};
use runtime_support::storage::{self, StorageValue, StorageMap};
use runtime_support::storage_items;
use runtime_support::{decl_storage, decl_module};
use sr_primitives::{
traits::{Hash as HashT, BlakeTwo256, Header as _}, generic, ApplyError, ApplyResult,
transaction_validity::{TransactionValidity, ValidTransaction, InvalidTransaction},
};
use codec::{KeyedVec, Encode};
use srml_system::Trait;
use crate::{
AccountId, BlockNumber, Extrinsic, Transfer, H256 as Hash, Block, Header, Digest, AuthorityId
};
Expand All @@ -34,14 +35,20 @@ use primitives::storage::well_known_keys;
const NONCE_OF: &[u8] = b"nonce:";
const BALANCE_OF: &[u8] = b"balance:";

storage_items! {
ExtrinsicData: b"sys:xtd" => required map [ u32 => Vec<u8> ];
// The current block number being processed. Set by `execute_block`.
Number: b"sys:num" => BlockNumber;
ParentHash: b"sys:pha" => required Hash;
NewAuthorities: b"sys:new_auth" => Vec<AuthorityId>;
StorageDigest: b"sys:digest" => Digest;
Authorities get(authorities): b"sys:auth" => default Vec<AuthorityId>;
decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {}
}

decl_storage! {
trait Store for Module<T: Trait> as TestRuntime {
ExtrinsicData: map u32 => Vec<u8>;
// The current block number being processed. Set by `execute_block`.
Number get(fn number): Option<BlockNumber>;
ParentHash get(fn parent_hash): Hash;
NewAuthorities get(fn new_authorities): Option<Vec<AuthorityId>>;
StorageDigest get(fn storage_digest): Option<Digest>;
Authorities get(fn authorities) config(): Vec<AuthorityId>;
}
}

pub fn balance_of_key(who: AccountId) -> Vec<u8> {
Expand Down Expand Up @@ -70,6 +77,10 @@ pub fn initialize_block(header: &Header) {
}
}

pub fn authorities() -> Vec<AuthorityId> {
Authorities::get()
}

pub fn get_block_number() -> Option<BlockNumber> {
Number::get()
}
Expand Down
1 change: 0 additions & 1 deletion srml/support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub use sr_primitives::RuntimeDebug;
pub mod debug;
#[macro_use]
pub mod dispatch;
#[macro_use]
pub mod storage;
mod hash;
#[macro_use]
Expand Down
2 changes: 0 additions & 2 deletions srml/support/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ use rstd::prelude::*;
use codec::{FullCodec, FullEncode, Encode, EncodeAppend, EncodeLike};
use crate::traits::Len;

#[macro_use]
pub mod storage_items;
pub mod unhashed;
pub mod hashed;
pub mod child;
Expand Down
Loading