use local chain_type and global chain_type as necessary

This commit is contained in:
antiochp
2020-05-22 14:35:35 +01:00
parent 2769436117
commit 72ff4b4e13
19 changed files with 79 additions and 49 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ where
logging_config: Option<LoggingConfig>,
tor_config: Option<TorConfig>,
) -> Result<(), Error> {
let mut default_config = GlobalWalletConfig::for_chain(chain_type);
let mut default_config = GlobalWalletConfig::for_chain(&chain_type);
let logging = match logging_config {
Some(l) => Some(l),
None => match default_config.members.as_ref() {
+6 -2
View File
@@ -21,7 +21,7 @@ use crate::chain::types::NoopAdapter;
use crate::chain::Chain;
use crate::core::core::verifier_cache::LruVerifierCache;
use crate::core::core::{Transaction, TxKernel};
use crate::core::global::{set_mining_mode, ChainTypes};
use crate::core::global::{set_local_chain_type, ChainTypes};
use crate::core::pow;
use crate::keychain::Keychain;
use crate::libwallet;
@@ -93,7 +93,7 @@ where
{
/// Create a new client that will communicate with the given grin node
pub fn new(chain_dir: &str) -> Self {
set_mining_mode(ChainTypes::AutomatedTesting);
set_local_chain_type(ChainTypes::AutomatedTesting);
let genesis_block = pow::mine_genesis_block().unwrap();
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
let dir_name = format!("{}/.grin", chain_dir);
@@ -136,6 +136,10 @@ where
/// Run the incoming message queue and respond more or less
/// synchronously
pub fn run(&mut self) -> Result<(), libwallet::Error> {
// We run the wallet_proxy within a spawned thread in tests.
// We set the local chain_type here within the thread.
set_local_chain_type(ChainTypes::AutomatedTesting);
self.running.store(true, Ordering::Relaxed);
loop {
thread::sleep(Duration::from_millis(10));