mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-01-21 03:21:08 +03:00
Merge pull request #412 from antiochp/local_chain_type
local vs global chain_type (for better test isolation)
This commit is contained in:
commit
038dafcc25
20 changed files with 89 additions and 59 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -1176,7 +1176,7 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_api"
|
name = "grin_api"
|
||||||
version = "4.0.0-alpha.1"
|
version = "4.0.0-alpha.1"
|
||||||
source = "git+https://github.com/mimblewimble/grin#93f5de3d2957f6f30dde8ae8f588efa0754c5ca3"
|
source = "git+https://github.com/mimblewimble/grin#6faa0e8d75be42280f3954eebedb1676cd40bb6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes 0.5.4",
|
"bytes 0.5.4",
|
||||||
"easy-jsonrpc-mw",
|
"easy-jsonrpc-mw",
|
||||||
|
@ -1209,7 +1209,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_chain"
|
name = "grin_chain"
|
||||||
version = "4.0.0-alpha.1"
|
version = "4.0.0-alpha.1"
|
||||||
source = "git+https://github.com/mimblewimble/grin#93f5de3d2957f6f30dde8ae8f588efa0754c5ca3"
|
source = "git+https://github.com/mimblewimble/grin#6faa0e8d75be42280f3954eebedb1676cd40bb6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-vec",
|
"bit-vec",
|
||||||
"bitflags 1.2.1",
|
"bitflags 1.2.1",
|
||||||
|
@ -1232,7 +1232,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_core"
|
name = "grin_core"
|
||||||
version = "4.0.0-alpha.1"
|
version = "4.0.0-alpha.1"
|
||||||
source = "git+https://github.com/mimblewimble/grin#93f5de3d2957f6f30dde8ae8f588efa0754c5ca3"
|
source = "git+https://github.com/mimblewimble/grin#6faa0e8d75be42280f3954eebedb1676cd40bb6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2-rfc",
|
"blake2-rfc",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
@ -1258,7 +1258,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_keychain"
|
name = "grin_keychain"
|
||||||
version = "4.0.0-alpha.1"
|
version = "4.0.0-alpha.1"
|
||||||
source = "git+https://github.com/mimblewimble/grin#93f5de3d2957f6f30dde8ae8f588efa0754c5ca3"
|
source = "git+https://github.com/mimblewimble/grin#6faa0e8d75be42280f3954eebedb1676cd40bb6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2-rfc",
|
"blake2-rfc",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
@ -1280,7 +1280,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_p2p"
|
name = "grin_p2p"
|
||||||
version = "4.0.0-alpha.1"
|
version = "4.0.0-alpha.1"
|
||||||
source = "git+https://github.com/mimblewimble/grin#93f5de3d2957f6f30dde8ae8f588efa0754c5ca3"
|
source = "git+https://github.com/mimblewimble/grin#6faa0e8d75be42280f3954eebedb1676cd40bb6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.2.1",
|
"bitflags 1.2.1",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -1301,7 +1301,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_pool"
|
name = "grin_pool"
|
||||||
version = "4.0.0-alpha.1"
|
version = "4.0.0-alpha.1"
|
||||||
source = "git+https://github.com/mimblewimble/grin#93f5de3d2957f6f30dde8ae8f588efa0754c5ca3"
|
source = "git+https://github.com/mimblewimble/grin#6faa0e8d75be42280f3954eebedb1676cd40bb6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake2-rfc",
|
"blake2-rfc",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -1335,7 +1335,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_store"
|
name = "grin_store"
|
||||||
version = "4.0.0-alpha.1"
|
version = "4.0.0-alpha.1"
|
||||||
source = "git+https://github.com/mimblewimble/grin#93f5de3d2957f6f30dde8ae8f588efa0754c5ca3"
|
source = "git+https://github.com/mimblewimble/grin#6faa0e8d75be42280f3954eebedb1676cd40bb6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"croaring-mw",
|
"croaring-mw",
|
||||||
|
@ -1355,7 +1355,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "grin_util"
|
name = "grin_util"
|
||||||
version = "4.0.0-alpha.1"
|
version = "4.0.0-alpha.1"
|
||||||
source = "git+https://github.com/mimblewimble/grin#93f5de3d2957f6f30dde8ae8f588efa0754c5ca3"
|
source = "git+https://github.com/mimblewimble/grin#6faa0e8d75be42280f3954eebedb1676cd40bb6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"base64 0.9.3",
|
"base64 0.9.3",
|
||||||
|
|
|
@ -102,6 +102,7 @@ where
|
||||||
/// ```
|
/// ```
|
||||||
/// use grin_wallet_util::grin_keychain as keychain;
|
/// use grin_wallet_util::grin_keychain as keychain;
|
||||||
/// use grin_wallet_util::grin_util as util;
|
/// use grin_wallet_util::grin_util as util;
|
||||||
|
/// use grin_wallet_util::grin_core;
|
||||||
/// use grin_wallet_api as api;
|
/// use grin_wallet_api as api;
|
||||||
/// use grin_wallet_config as config;
|
/// use grin_wallet_config as config;
|
||||||
/// use grin_wallet_impls as impls;
|
/// use grin_wallet_impls as impls;
|
||||||
|
@ -113,11 +114,15 @@ where
|
||||||
/// use std::sync::Arc;
|
/// use std::sync::Arc;
|
||||||
/// use util::{Mutex, ZeroingString};
|
/// use util::{Mutex, ZeroingString};
|
||||||
///
|
///
|
||||||
|
/// use grin_core::global;
|
||||||
|
///
|
||||||
/// use api::Foreign;
|
/// use api::Foreign;
|
||||||
/// use config::WalletConfig;
|
/// use config::WalletConfig;
|
||||||
/// use impls::{DefaultWalletImpl, DefaultLCProvider, HTTPNodeClient};
|
/// use impls::{DefaultWalletImpl, DefaultLCProvider, HTTPNodeClient};
|
||||||
/// use libwallet::WalletInst;
|
/// use libwallet::WalletInst;
|
||||||
///
|
///
|
||||||
|
/// global::set_local_chain_type(global::ChainTypes::AutomatedTesting);
|
||||||
|
///
|
||||||
/// let mut wallet_config = WalletConfig::default();
|
/// let mut wallet_config = WalletConfig::default();
|
||||||
/// # let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
|
/// # let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
|
||||||
/// # let dir = dir
|
/// # let dir = dir
|
||||||
|
@ -406,9 +411,11 @@ macro_rules! doctest_helper_setup_doc_env_foreign {
|
||||||
use grin_wallet_config as config;
|
use grin_wallet_config as config;
|
||||||
use grin_wallet_impls as impls;
|
use grin_wallet_impls as impls;
|
||||||
use grin_wallet_libwallet as libwallet;
|
use grin_wallet_libwallet as libwallet;
|
||||||
|
use grin_wallet_util::grin_core;
|
||||||
use grin_wallet_util::grin_keychain as keychain;
|
use grin_wallet_util::grin_keychain as keychain;
|
||||||
use grin_wallet_util::grin_util as util;
|
use grin_wallet_util::grin_util as util;
|
||||||
|
|
||||||
|
use grin_core::global;
|
||||||
use keychain::ExtKeychain;
|
use keychain::ExtKeychain;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
|
@ -423,7 +430,10 @@ macro_rules! doctest_helper_setup_doc_env_foreign {
|
||||||
// don't run on windows CI, which gives very inconsistent results
|
// don't run on windows CI, which gives very inconsistent results
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set our local chain_type for testing.
|
||||||
|
global::set_local_chain_type(global::ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
|
let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
|
||||||
let dir = dir
|
let dir = dir
|
||||||
|
|
|
@ -360,7 +360,7 @@ pub fn run_doctest_foreign(
|
||||||
|
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
let _ = fs::remove_dir_all(test_dir);
|
let _ = fs::remove_dir_all(test_dir);
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let mut wallet_proxy: WalletProxy<
|
let mut wallet_proxy: WalletProxy<
|
||||||
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
|
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
|
||||||
|
|
|
@ -109,11 +109,13 @@ where
|
||||||
/// ```
|
/// ```
|
||||||
/// use grin_wallet_util::grin_keychain as keychain;
|
/// use grin_wallet_util::grin_keychain as keychain;
|
||||||
/// use grin_wallet_util::grin_util as util;
|
/// use grin_wallet_util::grin_util as util;
|
||||||
|
/// use grin_wallet_util::grin_core;
|
||||||
/// use grin_wallet_api as api;
|
/// use grin_wallet_api as api;
|
||||||
/// use grin_wallet_config as config;
|
/// use grin_wallet_config as config;
|
||||||
/// use grin_wallet_impls as impls;
|
/// use grin_wallet_impls as impls;
|
||||||
/// use grin_wallet_libwallet as libwallet;
|
/// use grin_wallet_libwallet as libwallet;
|
||||||
///
|
///
|
||||||
|
/// use grin_core::global;
|
||||||
/// use keychain::ExtKeychain;
|
/// use keychain::ExtKeychain;
|
||||||
/// use tempfile::tempdir;
|
/// use tempfile::tempdir;
|
||||||
///
|
///
|
||||||
|
@ -125,6 +127,8 @@ where
|
||||||
/// use impls::{DefaultWalletImpl, DefaultLCProvider, HTTPNodeClient};
|
/// use impls::{DefaultWalletImpl, DefaultLCProvider, HTTPNodeClient};
|
||||||
/// use libwallet::WalletInst;
|
/// use libwallet::WalletInst;
|
||||||
///
|
///
|
||||||
|
/// global::set_local_chain_type(global::ChainTypes::AutomatedTesting);
|
||||||
|
///
|
||||||
/// let mut wallet_config = WalletConfig::default();
|
/// let mut wallet_config = WalletConfig::default();
|
||||||
/// # let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
|
/// # let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
|
||||||
/// # let dir = dir
|
/// # let dir = dir
|
||||||
|
@ -2113,6 +2117,8 @@ macro_rules! doctest_helper_setup_doc_env {
|
||||||
use grin_wallet_util::grin_keychain as keychain;
|
use grin_wallet_util::grin_keychain as keychain;
|
||||||
use grin_wallet_util::grin_util as util;
|
use grin_wallet_util::grin_util as util;
|
||||||
|
|
||||||
|
use grin_core::global;
|
||||||
|
|
||||||
use keychain::ExtKeychain;
|
use keychain::ExtKeychain;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
|
@ -2129,7 +2135,10 @@ macro_rules! doctest_helper_setup_doc_env {
|
||||||
// don't run on windows CI, which gives very inconsistent results
|
// don't run on windows CI, which gives very inconsistent results
|
||||||
if cfg!(windows) {
|
if cfg!(windows) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set our local chain_type for testing.
|
||||||
|
global::set_local_chain_type(global::ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
|
let dir = tempdir().map_err(|e| format!("{:#?}", e)).unwrap();
|
||||||
let dir = dir
|
let dir = dir
|
||||||
|
|
|
@ -1937,7 +1937,7 @@ pub fn run_doctest_owner(
|
||||||
|
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
let _ = fs::remove_dir_all(test_dir);
|
let _ = fs::remove_dir_all(test_dir);
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let mut wallet_proxy: WalletProxy<
|
let mut wallet_proxy: WalletProxy<
|
||||||
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
|
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
|
||||||
|
|
|
@ -54,7 +54,6 @@ pub struct GlobalArgs {
|
||||||
pub api_secret: Option<String>,
|
pub api_secret: Option<String>,
|
||||||
pub node_api_secret: Option<String>,
|
pub node_api_secret: Option<String>,
|
||||||
pub show_spent: bool,
|
pub show_spent: bool,
|
||||||
pub chain_type: global::ChainTypes,
|
|
||||||
pub password: Option<ZeroingString>,
|
pub password: Option<ZeroingString>,
|
||||||
pub tls_conf: Option<TLSConfig>,
|
pub tls_conf: Option<TLSConfig>,
|
||||||
}
|
}
|
||||||
|
@ -71,7 +70,7 @@ pub struct InitArgs {
|
||||||
|
|
||||||
pub fn init<L, C, K>(
|
pub fn init<L, C, K>(
|
||||||
owner_api: &mut Owner<L, C, K>,
|
owner_api: &mut Owner<L, C, K>,
|
||||||
g_args: &GlobalArgs,
|
_g_args: &GlobalArgs,
|
||||||
args: InitArgs,
|
args: InitArgs,
|
||||||
) -> Result<(), Error>
|
) -> Result<(), Error>
|
||||||
where
|
where
|
||||||
|
@ -79,15 +78,12 @@ where
|
||||||
C: NodeClient + 'static,
|
C: NodeClient + 'static,
|
||||||
K: keychain::Keychain + 'static,
|
K: keychain::Keychain + 'static,
|
||||||
{
|
{
|
||||||
|
// Assume global chain type has already been initialized.
|
||||||
|
let chain_type = global::get_chain_type();
|
||||||
|
|
||||||
let mut w_lock = owner_api.wallet_inst.lock();
|
let mut w_lock = owner_api.wallet_inst.lock();
|
||||||
let p = w_lock.lc_provider()?;
|
let p = w_lock.lc_provider()?;
|
||||||
p.create_config(
|
p.create_config(&chain_type, WALLET_CONFIG_FILE_NAME, None, None, None)?;
|
||||||
&g_args.chain_type,
|
|
||||||
WALLET_CONFIG_FILE_NAME,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)?;
|
|
||||||
p.create_wallet(
|
p.create_wallet(
|
||||||
None,
|
None,
|
||||||
args.recovery_phrase,
|
args.recovery_phrase,
|
||||||
|
|
|
@ -84,7 +84,15 @@ pub fn clean_output_dir(test_dir: &str) {
|
||||||
pub fn setup(test_dir: &str) {
|
pub fn setup(test_dir: &str) {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
clean_output_dir(test_dir);
|
clean_output_dir(test_dir);
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Some tests require the global chain_type to be configured due to threads being spawned internally.
|
||||||
|
/// It is recommended to avoid relying on this if at all possible as global chain_type
|
||||||
|
/// leaks across multiple tests and will likely have unintended consequences.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn setup_global_chain_type() {
|
||||||
|
global::init_global_chain_type(global::ChainTypes::AutomatedTesting);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_wallet_proxy(
|
pub fn create_wallet_proxy(
|
||||||
|
|
|
@ -29,7 +29,7 @@ use std::time::Duration;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod common;
|
mod common;
|
||||||
use common::{clean_output_dir, create_wallet_proxy, setup};
|
use common::{clean_output_dir, create_wallet_proxy, setup, setup_global_chain_type};
|
||||||
|
|
||||||
/// updater thread test impl
|
/// updater thread test impl
|
||||||
fn updater_thread_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
fn updater_thread_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||||
|
@ -110,6 +110,10 @@ fn updater_thread_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn updater_thread() {
|
fn updater_thread() {
|
||||||
|
// The "updater" kicks off a new thread so we need to ensure the global chain_type
|
||||||
|
// is set for this to work correctly.
|
||||||
|
setup_global_chain_type();
|
||||||
|
|
||||||
let test_dir = "test_output/updater_thread";
|
let test_dir = "test_output/updater_thread";
|
||||||
setup(test_dir);
|
setup(test_dir);
|
||||||
if let Err(e) = updater_thread_test_impl(test_dir) {
|
if let Err(e) = updater_thread_test_impl(test_dir) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ where
|
||||||
logging_config: Option<LoggingConfig>,
|
logging_config: Option<LoggingConfig>,
|
||||||
tor_config: Option<TorConfig>,
|
tor_config: Option<TorConfig>,
|
||||||
) -> Result<(), Error> {
|
) -> 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 {
|
let logging = match logging_config {
|
||||||
Some(l) => Some(l),
|
Some(l) => Some(l),
|
||||||
None => match default_config.members.as_ref() {
|
None => match default_config.members.as_ref() {
|
||||||
|
|
|
@ -21,7 +21,7 @@ use crate::chain::types::NoopAdapter;
|
||||||
use crate::chain::Chain;
|
use crate::chain::Chain;
|
||||||
use crate::core::core::verifier_cache::LruVerifierCache;
|
use crate::core::core::verifier_cache::LruVerifierCache;
|
||||||
use crate::core::core::{Transaction, TxKernel};
|
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::core::pow;
|
||||||
use crate::keychain::Keychain;
|
use crate::keychain::Keychain;
|
||||||
use crate::libwallet;
|
use crate::libwallet;
|
||||||
|
@ -93,7 +93,7 @@ where
|
||||||
{
|
{
|
||||||
/// Create a new client that will communicate with the given grin node
|
/// Create a new client that will communicate with the given grin node
|
||||||
pub fn new(chain_dir: &str) -> Self {
|
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 genesis_block = pow::mine_genesis_block().unwrap();
|
||||||
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
let verifier_cache = Arc::new(RwLock::new(LruVerifierCache::new()));
|
||||||
let dir_name = format!("{}/.grin", chain_dir);
|
let dir_name = format!("{}/.grin", chain_dir);
|
||||||
|
@ -136,6 +136,10 @@ where
|
||||||
/// Run the incoming message queue and respond more or less
|
/// Run the incoming message queue and respond more or less
|
||||||
/// synchronously
|
/// synchronously
|
||||||
pub fn run(&mut self) -> Result<(), libwallet::Error> {
|
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);
|
self.running.store(true, Ordering::Relaxed);
|
||||||
loop {
|
loop {
|
||||||
thread::sleep(Duration::from_millis(10));
|
thread::sleep(Duration::from_millis(10));
|
||||||
|
|
|
@ -33,7 +33,7 @@ fn simple_server_wallet() {
|
||||||
init_test_logger();
|
init_test_logger();
|
||||||
info!("starting simple_server_wallet");
|
info!("starting simple_server_wallet");
|
||||||
let _test_name_dir = "test_servers";
|
let _test_name_dir = "test_servers";
|
||||||
core::global::set_mining_mode(core::global::ChainTypes::AutomatedTesting);
|
core::global::set_local_chain_type(core::global::ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
// Run a separate coinbase wallet for coinbase transactions
|
// Run a separate coinbase wallet for coinbase transactions
|
||||||
let coinbase_dir = "coinbase_wallet_api";
|
let coinbase_dir = "coinbase_wallet_api";
|
||||||
|
@ -142,7 +142,7 @@ fn simple_server_wallet() {
|
||||||
fn test_p2p() {
|
fn test_p2p() {
|
||||||
init_test_logger();
|
init_test_logger();
|
||||||
info!("starting test_p2p");
|
info!("starting test_p2p");
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let _test_name_dir = "test_servers";
|
let _test_name_dir = "test_servers";
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ use std::{thread, time};
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn test_dandelion_timeout() {
|
fn test_dandelion_timeout() {
|
||||||
let test_name_dir = "test_dandelion_timeout";
|
let test_name_dir = "test_dandelion_timeout";
|
||||||
core::global::set_mining_mode(core::global::ChainTypes::AutomatedTesting);
|
core::global::set_local_chain_type(core::global::ChainTypes::AutomatedTesting);
|
||||||
framework::clean_all_output(test_name_dir);
|
framework::clean_all_output(test_name_dir);
|
||||||
let mut log_config = util::LoggingConfig::default();
|
let mut log_config = util::LoggingConfig::default();
|
||||||
//log_config.stdout_log_level = util::LogLevel::Trace;
|
//log_config.stdout_log_level = util::LogLevel::Trace;
|
||||||
|
|
|
@ -52,7 +52,7 @@ use crate::framework::{
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_genesis_mine() {
|
fn basic_genesis_mine() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let test_name_dir = "genesis_mine";
|
let test_name_dir = "genesis_mine";
|
||||||
framework::clean_all_output(test_name_dir);
|
framework::clean_all_output(test_name_dir);
|
||||||
|
@ -84,7 +84,7 @@ fn basic_genesis_mine() {
|
||||||
#[test]
|
#[test]
|
||||||
fn simulate_seeding() {
|
fn simulate_seeding() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let test_name_dir = "simulate_seeding";
|
let test_name_dir = "simulate_seeding";
|
||||||
framework::clean_all_output(test_name_dir);
|
framework::clean_all_output(test_name_dir);
|
||||||
|
@ -151,7 +151,7 @@ fn simulate_seeding() {
|
||||||
#[ignore]
|
#[ignore]
|
||||||
#[test]
|
#[test]
|
||||||
fn simulate_parallel_mining() {
|
fn simulate_parallel_mining() {
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let test_name_dir = "simulate_parallel_mining";
|
let test_name_dir = "simulate_parallel_mining";
|
||||||
// framework::clean_all_output(test_name_dir);
|
// framework::clean_all_output(test_name_dir);
|
||||||
|
@ -208,7 +208,7 @@ fn simulate_block_propagation() {
|
||||||
|
|
||||||
// we actually set the chain_type in the ServerConfig below
|
// we actually set the chain_type in the ServerConfig below
|
||||||
// TODO - avoid needing to set it in two places?
|
// TODO - avoid needing to set it in two places?
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let test_name_dir = "grin-prop";
|
let test_name_dir = "grin-prop";
|
||||||
framework::clean_all_output(test_name_dir);
|
framework::clean_all_output(test_name_dir);
|
||||||
|
@ -268,7 +268,7 @@ fn simulate_full_sync() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
|
|
||||||
// we actually set the chain_type in the ServerConfig below
|
// we actually set the chain_type in the ServerConfig below
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let test_name_dir = "grin-sync";
|
let test_name_dir = "grin-sync";
|
||||||
framework::clean_all_output(test_name_dir);
|
framework::clean_all_output(test_name_dir);
|
||||||
|
@ -324,7 +324,7 @@ fn simulate_fast_sync() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
|
|
||||||
// we actually set the chain_type in the ServerConfig below
|
// we actually set the chain_type in the ServerConfig below
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let test_name_dir = "grin-fast";
|
let test_name_dir = "grin-fast";
|
||||||
framework::clean_all_output(test_name_dir);
|
framework::clean_all_output(test_name_dir);
|
||||||
|
@ -417,7 +417,7 @@ fn simulate_long_fork() {
|
||||||
println!("starting simulate_long_fork");
|
println!("starting simulate_long_fork");
|
||||||
|
|
||||||
// we actually set the chain_type in the ServerConfig below
|
// we actually set the chain_type in the ServerConfig below
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let test_name_dir = "grin-long-fork";
|
let test_name_dir = "grin-long-fork";
|
||||||
framework::clean_all_output(test_name_dir);
|
framework::clean_all_output(test_name_dir);
|
||||||
|
@ -903,7 +903,7 @@ pub fn create_wallet(
|
||||||
#[test]
|
#[test]
|
||||||
fn replicate_tx_fluff_failure() {
|
fn replicate_tx_fluff_failure() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
global::set_mining_mode(ChainTypes::UserTesting);
|
global::set_local_chain_type(ChainTypes::UserTesting);
|
||||||
framework::clean_all_output("tx_fluff");
|
framework::clean_all_output("tx_fluff");
|
||||||
|
|
||||||
// Create Wallet 1 (Mining Input) and start it listening
|
// Create Wallet 1 (Mining Input) and start it listening
|
||||||
|
|
|
@ -38,7 +38,7 @@ use std::{thread, time};
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_stratum_server() {
|
fn basic_stratum_server() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(ChainTypes::AutomatedTesting);
|
||||||
|
|
||||||
let test_name_dir = "stratum_server";
|
let test_name_dir = "stratum_server";
|
||||||
framework::clean_all_output(test_name_dir);
|
framework::clean_all_output(test_name_dir);
|
||||||
|
|
|
@ -141,7 +141,7 @@ fn real_main() -> i32 {
|
||||||
|
|
||||||
log_build_info();
|
log_build_info();
|
||||||
|
|
||||||
global::set_mining_mode(
|
global::init_global_chain_type(
|
||||||
config
|
config
|
||||||
.members
|
.members
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -32,7 +32,6 @@ use grin_wallet_libwallet::Slate;
|
||||||
use grin_wallet_libwallet::{IssueInvoiceTxArgs, NodeClient, WalletInst, WalletLCProvider};
|
use grin_wallet_libwallet::{IssueInvoiceTxArgs, NodeClient, WalletInst, WalletLCProvider};
|
||||||
use grin_wallet_util::grin_core as core;
|
use grin_wallet_util::grin_core as core;
|
||||||
use grin_wallet_util::grin_core::core::amount_to_hr_string;
|
use grin_wallet_util::grin_core::core::amount_to_hr_string;
|
||||||
use grin_wallet_util::grin_core::global;
|
|
||||||
use grin_wallet_util::grin_keychain as keychain;
|
use grin_wallet_util::grin_keychain as keychain;
|
||||||
use grin_wallet_util::OnionV3Address;
|
use grin_wallet_util::OnionV3Address;
|
||||||
use linefeed::terminal::Signal;
|
use linefeed::terminal::Signal;
|
||||||
|
@ -275,18 +274,9 @@ pub fn parse_global_args(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let chain_type = match config.chain_type.clone() {
|
|
||||||
None => {
|
|
||||||
let param_ref = global::CHAIN_TYPE.read();
|
|
||||||
param_ref.clone()
|
|
||||||
}
|
|
||||||
Some(c) => c,
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(command::GlobalArgs {
|
Ok(command::GlobalArgs {
|
||||||
account: account.to_owned(),
|
account: account.to_owned(),
|
||||||
show_spent: show_spent,
|
show_spent: show_spent,
|
||||||
chain_type: chain_type,
|
|
||||||
api_secret: api_secret,
|
api_secret: api_secret,
|
||||||
node_api_secret: node_api_secret,
|
node_api_secret: node_api_secret,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -843,10 +833,6 @@ where
|
||||||
>,
|
>,
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
if let Some(t) = wallet_config.chain_type.clone() {
|
|
||||||
core::global::set_mining_mode(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
if wallet_args.is_present("external") {
|
if wallet_args.is_present("external") {
|
||||||
wallet_config.api_listen_interface = "0.0.0.0".to_string();
|
wallet_config.api_listen_interface = "0.0.0.0".to_string();
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,17 @@ pub fn clean_output_dir(test_dir: &str) {
|
||||||
pub fn setup(test_dir: &str) {
|
pub fn setup(test_dir: &str) {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
clean_output_dir(test_dir);
|
clean_output_dir(test_dir);
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
global::set_local_chain_type(global::ChainTypes::AutomatedTesting);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Some tests require the global chain_type to be configured.
|
||||||
|
/// If tokio is used in any tests we need to ensure any threads spawned
|
||||||
|
/// have the chain_type configured correctly.
|
||||||
|
/// It is recommended to avoid relying on this if at all possible as global chain_type
|
||||||
|
/// leaks across multiple tests and will likely have unintended consequences.
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn setup_global_chain_type() {
|
||||||
|
global::init_global_chain_type(global::ChainTypes::AutomatedTesting);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a wallet config file in the given current directory
|
/// Create a wallet config file in the given current directory
|
||||||
|
|
|
@ -36,11 +36,13 @@ use serde_json;
|
||||||
mod common;
|
mod common;
|
||||||
use common::{
|
use common::{
|
||||||
clean_output_dir, derive_ecdh_key, execute_command, initial_setup_wallet, instantiate_wallet,
|
clean_output_dir, derive_ecdh_key, execute_command, initial_setup_wallet, instantiate_wallet,
|
||||||
send_request, send_request_enc, setup, RetrieveSummaryInfoResp,
|
send_request, send_request_enc, setup, setup_global_chain_type, RetrieveSummaryInfoResp,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn owner_v3_init_secure() -> Result<(), grin_wallet_controller::Error> {
|
fn owner_v3_init_secure() -> Result<(), grin_wallet_controller::Error> {
|
||||||
|
setup_global_chain_type();
|
||||||
|
|
||||||
let test_dir = "target/test_output/owner_v3_init_secure";
|
let test_dir = "target/test_output/owner_v3_init_secure";
|
||||||
setup(test_dir);
|
setup(test_dir);
|
||||||
|
|
||||||
|
|
|
@ -40,11 +40,13 @@ mod common;
|
||||||
use common::{
|
use common::{
|
||||||
clean_output_dir, derive_ecdh_key, execute_command, execute_command_no_setup,
|
clean_output_dir, derive_ecdh_key, execute_command, execute_command_no_setup,
|
||||||
initial_setup_wallet, instantiate_wallet, send_request, send_request_enc, setup,
|
initial_setup_wallet, instantiate_wallet, send_request, send_request_enc, setup,
|
||||||
RetrieveSummaryInfoResp,
|
setup_global_chain_type, RetrieveSummaryInfoResp,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn owner_v3_lifecycle() -> Result<(), grin_wallet_controller::Error> {
|
fn owner_v3_lifecycle() -> Result<(), grin_wallet_controller::Error> {
|
||||||
|
setup_global_chain_type();
|
||||||
|
|
||||||
let test_dir = "target/test_output/owner_v3_lifecycle";
|
let test_dir = "target/test_output/owner_v3_lifecycle";
|
||||||
setup(test_dir);
|
setup(test_dir);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ extern crate log;
|
||||||
extern crate grin_wallet;
|
extern crate grin_wallet;
|
||||||
|
|
||||||
use grin_wallet_impls::test_framework::{self, LocalWalletClient, WalletProxy};
|
use grin_wallet_impls::test_framework::{self, LocalWalletClient, WalletProxy};
|
||||||
use grin_wallet_util::grin_core::global::{self, ChainTypes};
|
|
||||||
|
|
||||||
use clap::App;
|
use clap::App;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
@ -33,14 +32,14 @@ use grin_wallet_util::grin_util as util;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod common;
|
mod common;
|
||||||
use common::{execute_command, initial_setup_wallet, instantiate_wallet};
|
use common::{execute_command, initial_setup_wallet, instantiate_wallet, setup_global_chain_type};
|
||||||
|
|
||||||
// Development testing helper for tor/socks investigation.
|
// Development testing helper for tor/socks investigation.
|
||||||
// Not (yet) to be run as part of automated testing
|
// Not (yet) to be run as part of automated testing
|
||||||
|
|
||||||
fn setup_no_clean() {
|
fn setup_no_clean() {
|
||||||
util::init_test_logger();
|
util::init_test_logger();
|
||||||
global::set_mining_mode(ChainTypes::AutomatedTesting);
|
setup_global_chain_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[ignore]
|
#[ignore]
|
||||||
|
|
Loading…
Reference in a new issue