Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop proxy in controller tests to allow dir cleanup on Windows #363

Merged
merged 5 commits into from
Mar 10, 2020
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
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions controller/tests/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use self::keychain::{ExtKeychain, Keychain};
use grin_wallet_libwallet as libwallet;
use impls::test_framework::{self, LocalWalletClient};
use libwallet::InitTxArgs;
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -37,6 +38,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

create_wallet_and_add!(
client1,
Expand Down Expand Up @@ -258,6 +260,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand Down
10 changes: 9 additions & 1 deletion controller/tests/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use grin_wallet_libwallet as libwallet;
use impls::test_framework::{self, LocalWalletClient};
use impls::{PathToSlate, SlatePutter as _};
use libwallet::{InitTxArgs, NodeClient};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;
use util::ZeroingString;
Expand All @@ -51,6 +52,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

// Create a new wallet test client, and set its queues to communicate with the
// proxy
Expand Down Expand Up @@ -215,12 +217,12 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}

fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
setup(test_dir);
let seed_phrase = "affair pistol cancel crush garment candy ancient flag work \
market crush dry stand focus mutual weapon offer ceiling rival turn team spring \
where swift";
Expand All @@ -229,6 +231,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

// Create a new wallet test client, and set its queues to communicate with the
// proxy
Expand Down Expand Up @@ -752,6 +755,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand All @@ -761,6 +765,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
fn output_scanning_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();
// Create a new wallet test client, and set its queues to communicate with the
// proxy
create_wallet_and_add!(
Expand Down Expand Up @@ -836,6 +841,9 @@ fn output_scanning_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
assert_eq!(outputs.2.len(), 16);
}

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}

Expand Down
5 changes: 4 additions & 1 deletion controller/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ macro_rules! open_wallet_and_add {
};
}
pub fn clean_output_dir(test_dir: &str) {
let _ = fs::remove_dir_all(test_dir);
let path = std::path::Path::new(test_dir);
if path.is_dir() {
fs::remove_dir_all(test_dir).unwrap();
}
}

pub fn setup(test_dir: &str) {
Expand Down
3 changes: 3 additions & 0 deletions controller/tests/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use grin_wallet_util::grin_core as core;

use impls::test_framework::{self, LocalWalletClient};
use impls::{PathToSlate, SlateGetter as _, SlatePutter as _};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -38,6 +39,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

// Create a new wallet test client, and set its queues to communicate with the
// proxy
Expand Down Expand Up @@ -215,6 +217,7 @@ fn file_exchange_test_impl(test_dir: &'static str) -> Result<(), libwallet::Erro
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions controller/tests/invoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use grin_wallet_util::grin_core as core;

use impls::test_framework::{self, LocalWalletClient};
use libwallet::{InitTxArgs, IssueInvoiceTxArgs, Slate};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -34,6 +35,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

create_wallet_and_add!(
client1,
Expand Down Expand Up @@ -201,6 +203,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
//bh += 3;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));

Ok(())
Expand Down
3 changes: 3 additions & 0 deletions controller/tests/no_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use grin_wallet_util::grin_core as core;
use grin_wallet_libwallet as libwallet;
use impls::test_framework::{self, LocalWalletClient};
use libwallet::{InitTxArgs, IssueInvoiceTxArgs, Slate};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -32,6 +33,7 @@ use common::{clean_output_dir, create_wallet_proxy, setup};
fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

create_wallet_and_add!(
client1,
Expand Down Expand Up @@ -153,6 +155,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions controller/tests/payment_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern crate grin_wallet_util;
use grin_wallet_libwallet as libwallet;
use impls::test_framework::{self, LocalWalletClient};
use libwallet::{InitTxArgs, Slate};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -35,6 +36,7 @@ fn payment_proofs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

create_wallet_and_add!(
client1,
Expand Down Expand Up @@ -157,6 +159,7 @@ fn payment_proofs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions controller/tests/repost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use grin_wallet_util::grin_core as core;
use self::libwallet::{InitTxArgs, Slate};
use impls::test_framework::{self, LocalWalletClient};
use impls::{PathToSlate, SlateGetter as _, SlatePutter as _};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -35,6 +36,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

// Create a new wallet test client, and set its queues to communicate with the
// proxy
Expand Down Expand Up @@ -248,6 +250,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions controller/tests/self_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use grin_wallet_util::grin_core as core;
use grin_wallet_libwallet as libwallet;
use impls::test_framework::{self, LocalWalletClient};
use libwallet::InitTxArgs;
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -34,6 +35,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

// Create a new wallet test client, and set its queues to communicate with the
// proxy
Expand Down Expand Up @@ -130,6 +132,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand Down
5 changes: 5 additions & 0 deletions controller/tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use self::core::core::transaction;
use self::core::global;
use self::libwallet::{InitTxArgs, OutputStatus, Slate};
use impls::test_framework::{self, LocalWalletClient};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -37,6 +38,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

create_wallet_and_add!(
client1,
Expand Down Expand Up @@ -338,6 +340,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand All @@ -348,6 +351,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

create_wallet_and_add!(
client1,
Expand Down Expand Up @@ -515,6 +519,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand Down
3 changes: 3 additions & 0 deletions controller/tests/ttl_cutoff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern crate grin_wallet_util;
use grin_wallet_libwallet as libwallet;
use impls::test_framework::{self, LocalWalletClient};
use libwallet::{InitTxArgs, Slate, TxLogEntryType};
use std::sync::atomic::Ordering;
use std::thread;
use std::time::Duration;

Expand All @@ -33,6 +34,7 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let stopper = wallet_proxy.running.clone();

create_wallet_and_add!(
client1,
Expand Down Expand Up @@ -167,6 +169,7 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
})?;

// let logging finish
stopper.store(false, Ordering::Relaxed);
thread::sleep(Duration::from_millis(200));
Ok(())
}
Expand Down
Loading