Merge milestone/2.1.0 into master (#199)

* version bump for next potential release

* Merge master into milestone/2.1.0 (#182)

* Derive --version output dynamically from cargo package version (#174)

* add --txid to the `wallet txs` command (#176)

* add --txid to the `wallet txs` command

* add test for `wallet txs` command with `--txid` parameter

* Refactor - Split WalletCommAdapter into multiple traits (#180)

* Derive --version output dynamically from cargo package version (#174)

* add server auth argument to http client

* Revert "add server auth argument to http client"

This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee.

* modify WalletCommAdapter, moving dest argument into fields on implementors,
visiting havok on automated tests, at least one of which is now out of date and failing

* Split WalletCommAdapter into four traits, one for each of its intended behaviors.

* Remove two vestigals
1. args, a stringly typed argument to put_tx
2. NullAdapter, which is no longer used

* Remove unused "params" argument from listen method.

* Re-add previously existing TODO comment

* Fix non-test build

* completely Fix non-test build

* Full Lifecycle API Support (#184)

* refactoring wallet lib traits

* rustfmt

* rustfmt

* add new files

* explicit lifetime specifiers on all wallet traits

* rustfmt

* modify apis to use new walletinst

* rustfmt

* converting controller crate

* rustfmt

* controller crate compiling

* rustfmt

* compilation

* rustfmt

* Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl

* rustfmt

* full compilation, changing recovery + init to new model

* rustfmt

* wallet initialisation working, init command output and flow identical to v2.0.0 wallet

* rustfmt

* fix listener and owner api startup

* rustfmt

* rustfmt

* move encryption test

* rustfmt

* fix api doctests

* rustfmt

* fix for most tests in controller crate

* rustfmt

* fix for check tests in controller crate

* fix main wallet tests

* rustfmt

* add explicit functions to handle mnemonic recovery, fix CLI recovery workflow

* rustfmt

* update keybase adapter to use new wallet format

* rustfmt

* test fix

* remove debug output
This commit is contained in:
Yeastplume
2019-07-29 13:25:03 +01:00
committed by GitHub
parent 7b6d597d39
commit c40e8a915b
54 changed files with 2405 additions and 1942 deletions
+37 -43
View File
@@ -19,45 +19,43 @@ extern crate grin_wallet_impls as impls;
extern crate grin_wallet_libwallet as libwallet;
use grin_wallet_util::grin_core as core;
use grin_wallet_util::grin_keychain as keychain;
use grin_wallet_util::grin_util as util;
use self::core::global;
use self::core::global::ChainTypes;
use self::keychain::ExtKeychain;
use self::libwallet::{InitTxArgs, Slate};
use impls::test_framework::{self, LocalWalletClient, WalletProxy};
use impls::FileWalletCommAdapter;
use std::fs;
use impls::test_framework::{self, LocalWalletClient};
use impls::{PathToSlate, SlateGetter as _, SlatePutter as _};
use std::thread;
use std::time::Duration;
fn clean_output_dir(test_dir: &str) {
let _ = fs::remove_dir_all(test_dir);
}
fn setup(test_dir: &str) {
util::init_test_logger();
clean_output_dir(test_dir);
global::set_mining_mode(ChainTypes::AutomatedTesting);
}
#[macro_use]
mod common;
use common::{create_wallet_proxy, setup};
/// self send impl
fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
setup(test_dir);
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy: WalletProxy<LocalWalletClient, ExtKeychain> = WalletProxy::new(test_dir);
let mut wallet_proxy = create_wallet_proxy(test_dir);
let chain = wallet_proxy.chain.clone();
let client1 = LocalWalletClient::new("wallet1", wallet_proxy.tx.clone());
let wallet1 =
test_framework::create_wallet(&format!("{}/wallet1", test_dir), client1.clone(), None);
wallet_proxy.add_wallet("wallet1", client1.get_send_instance(), wallet1.clone());
let client2 = LocalWalletClient::new("wallet2", wallet_proxy.tx.clone());
let wallet2 =
test_framework::create_wallet(&format!("{}/wallet2", test_dir), client2.clone(), None);
wallet_proxy.add_wallet("wallet2", client2.get_send_instance(), wallet2.clone());
// Create a new wallet test client, and set its queues to communicate with the
// proxy
create_wallet_and_add!(
client1,
wallet1,
test_dir,
"wallet1",
None,
&mut wallet_proxy
);
create_wallet_and_add!(
client2,
wallet2,
test_dir,
"wallet2",
None,
&mut wallet_proxy
);
// Set the wallet proxy listener running
thread::spawn(move || {
@@ -85,7 +83,7 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
// Get some mining done
{
let mut w = wallet1.lock();
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("mining")?;
}
let mut bh = 10u64;
@@ -112,10 +110,8 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
selection_strategy_is_use_all: true,
..Default::default()
};
let mut slate = api.init_send_tx(args)?;
// output tx file
let file_adapter = FileWalletCommAdapter::new();
file_adapter.send_tx_async(&send_file, &mut slate)?;
let slate = api.init_send_tx(args)?;
PathToSlate((&send_file).into()).put_tx(&slate)?;
api.tx_lock_outputs(&slate, 0)?;
Ok(())
})?;
@@ -125,28 +121,26 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
// wallet 1 receives file to different account, completes
{
let mut w = wallet1.lock();
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("listener")?;
}
wallet::controller::foreign_single_use(wallet1.clone(), |api| {
let adapter = FileWalletCommAdapter::new();
slate = adapter.receive_tx_async(&send_file)?;
slate = PathToSlate((&send_file).into()).get_tx()?;
slate = api.receive_tx(&slate, None, None)?;
adapter.send_tx_async(&receive_file, &mut slate)?;
PathToSlate((&receive_file).into()).put_tx(&slate)?;
Ok(())
})?;
// wallet 1 receives file to different account, completes
{
let mut w = wallet1.lock();
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("mining")?;
}
// wallet 1 finalize
wallet::controller::owner_single_use(wallet1.clone(), |api| {
let adapter = FileWalletCommAdapter::new();
slate = adapter.receive_tx_async(&receive_file)?;
slate = PathToSlate((&receive_file).into()).get_tx()?;
slate = api.finalize_tx(&slate)?;
Ok(())
})?;
@@ -173,7 +167,7 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
})?;
{
let mut w = wallet1.lock();
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("listener")?;
}
@@ -187,11 +181,11 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
// as above, but syncronously
{
let mut w = wallet1.lock();
wallet_inst!(wallet1, w);
w.set_parent_key_id_by_name("mining")?;
}
{
let mut w = wallet2.lock();
wallet_inst!(wallet2, w);
w.set_parent_key_id_by_name("account1")?;
}