Eradicate native_equivalent (#3494)

* Add ability to supply extra storage in test-client

* Don't use native_equivalent in tests.

* Get rid of native_equivalent

* Try to make fields private

* Apply Basti's suggestions

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Sergei Pepyakin
2019-08-27 22:20:47 +02:00
committed by GitHub
parent 095c7de7ff
commit 36ef4c067b
9 changed files with 70 additions and 51 deletions
+12 -4
View File
@@ -25,10 +25,12 @@ use sr_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
/// Configuration of a general Substrate test genesis block.
pub struct GenesisConfig {
pub changes_trie_config: Option<ChangesTrieConfiguration>,
pub authorities: Vec<AuthorityId>,
pub balances: Vec<(AccountId, u64)>,
pub heap_pages_override: Option<u64>,
changes_trie_config: Option<ChangesTrieConfiguration>,
authorities: Vec<AuthorityId>,
balances: Vec<(AccountId, u64)>,
heap_pages_override: Option<u64>,
/// Additional storage key pairs that will be added to the genesis map.
extra_storage: Vec<(Vec<u8>, Vec<u8>)>,
}
impl GenesisConfig {
@@ -38,6 +40,7 @@ impl GenesisConfig {
endowed_accounts: Vec<AccountId>,
balance: u64,
heap_pages_override: Option<u64>,
extra_storage: Vec<(Vec<u8>, Vec<u8>)>,
) -> Self {
GenesisConfig {
changes_trie_config: match support_changes_trie {
@@ -47,6 +50,7 @@ impl GenesisConfig {
authorities: authorities.clone(),
balances: endowed_accounts.into_iter().map(|a| (a, balance)).collect(),
heap_pages_override,
extra_storage,
}
}
@@ -70,6 +74,10 @@ 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.
for (key, value) in self.extra_storage.iter().cloned() {
map.insert(key, value);
}
(map, Default::default())
}
}