mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Add test for cli keystore path generation (#4571)
* Add test for cli keystore path generation * Fix test
This commit is contained in:
@@ -165,10 +165,11 @@ fn new_full_parts<TBl, TRtApi, TExecDisp, TCfg, TGen, TCSExt>(
|
||||
{
|
||||
let keystore = match &config.keystore {
|
||||
KeystoreConfig::Path { path, password } => Keystore::open(
|
||||
path.clone().ok_or("No basepath configured")?,
|
||||
path.clone(),
|
||||
password.clone()
|
||||
)?,
|
||||
KeystoreConfig::InMemory => Keystore::new_in_memory()
|
||||
KeystoreConfig::InMemory => Keystore::new_in_memory(),
|
||||
KeystoreConfig::None => return Err("No keystore config provided!".into()),
|
||||
};
|
||||
|
||||
let executor = NativeExecutor::<TExecDisp>::new(
|
||||
@@ -289,10 +290,11 @@ where TGen: RuntimeGenesis, TCSExt: Extension {
|
||||
>, Error> {
|
||||
let keystore = match &config.keystore {
|
||||
KeystoreConfig::Path { path, password } => Keystore::open(
|
||||
path.clone().ok_or("No basepath configured")?,
|
||||
path.clone(),
|
||||
password.clone()
|
||||
)?,
|
||||
KeystoreConfig::InMemory => Keystore::new_in_memory()
|
||||
KeystoreConfig::InMemory => Keystore::new_in_memory(),
|
||||
KeystoreConfig::None => return Err("No keystore config provided!".into()),
|
||||
};
|
||||
|
||||
let executor = NativeExecutor::<TExecDisp>::new(
|
||||
|
||||
@@ -21,7 +21,7 @@ pub use sc_client_db::{kvdb::KeyValueDB, PruningMode};
|
||||
pub use sc_network::config::{ExtTransport, NetworkConfiguration, Roles};
|
||||
pub use sc_executor::WasmExecutionMethod;
|
||||
|
||||
use std::{path::PathBuf, net::SocketAddr, sync::Arc};
|
||||
use std::{path::{PathBuf, Path}, net::SocketAddr, sync::Arc};
|
||||
pub use sc_transaction_pool::txpool::Options as TransactionPoolOptions;
|
||||
use sc_chain_spec::{ChainSpec, RuntimeGenesis, Extension, NoExtension};
|
||||
use sp_core::crypto::Protected;
|
||||
@@ -107,10 +107,12 @@ pub struct Configuration<C, G, E = NoExtension> {
|
||||
/// Configuration of the client keystore.
|
||||
#[derive(Clone)]
|
||||
pub enum KeystoreConfig {
|
||||
/// No config supplied.
|
||||
None,
|
||||
/// Keystore at a path on-disk. Recommended for native nodes.
|
||||
Path {
|
||||
/// The path of the keystore. Will panic if no path is specified.
|
||||
path: Option<PathBuf>,
|
||||
/// The path of the keystore.
|
||||
path: PathBuf,
|
||||
/// Node keystore's password.
|
||||
password: Option<Protected<String>>
|
||||
},
|
||||
@@ -118,6 +120,16 @@ pub enum KeystoreConfig {
|
||||
InMemory
|
||||
}
|
||||
|
||||
impl KeystoreConfig {
|
||||
/// Returns the path for the keystore.
|
||||
pub fn path(&self) -> Option<&Path> {
|
||||
match self {
|
||||
Self::Path { path, .. } => Some(&path),
|
||||
Self::None | Self::InMemory => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Configuration of the database of the client.
|
||||
#[derive(Clone)]
|
||||
pub enum DatabaseConfig {
|
||||
@@ -150,10 +162,7 @@ impl<C, G, E> Configuration<C, G, E> where
|
||||
roles: Roles::FULL,
|
||||
transaction_pool: Default::default(),
|
||||
network: Default::default(),
|
||||
keystore: KeystoreConfig::Path {
|
||||
path: config_dir.map(|c| c.join("keystore")),
|
||||
password: None
|
||||
},
|
||||
keystore: KeystoreConfig::None,
|
||||
database: DatabaseConfig::Path {
|
||||
path: Default::default(),
|
||||
cache_size: Default::default(),
|
||||
|
||||
Reference in New Issue
Block a user