Refactor crate names, API Crate refactor (#20)

* refactor/rename api crate contents, make crate naming consistent (all starting with grin_wallet)

* refactor/rename api crate contents, make crate naming consistent (all starting with grin_wallet)

* fix rpc api tests

* rustfmt

* done refactor

* rustfmt

* travis CI fixes
This commit is contained in:
Yeastplume
2019-03-14 12:06:03 +00:00
committed by GitHub
parent 550d93b2d2
commit baa5e46d7d
28 changed files with 1281 additions and 1192 deletions
+2 -2
View File
@@ -15,8 +15,8 @@
use crate::cmd::wallet_args;
use crate::config::GlobalWalletConfig;
use clap::ArgMatches;
use grin_refwallet::{self, HTTPNodeClient, WalletSeed};
use grin_wallet_config::WalletConfig;
use grin_wallet_refwallet::{self, HTTPNodeClient, WalletSeed};
use std::path::PathBuf;
use std::thread;
use std::time::Duration;
@@ -31,7 +31,7 @@ pub fn _init_wallet_seed(wallet_config: WalletConfig, password: &str) {
pub fn seed_exists(wallet_config: WalletConfig) -> bool {
let mut data_file_dir = PathBuf::new();
data_file_dir.push(wallet_config.data_file_dir);
data_file_dir.push(grin_refwallet::SEED_FILE);
data_file_dir.push(grin_wallet_refwallet::SEED_FILE);
if data_file_dir.exists() {
true
} else {
+3 -3
View File
@@ -20,9 +20,9 @@ use clap::ArgMatches;
use failure::Fail;
use grin_core as core;
use grin_keychain as keychain;
use grin_refwallet::{command, instantiate_wallet, NodeClient, WalletInst, WalletSeed};
use grin_refwallet::{Error, ErrorKind};
use grin_wallet_config::WalletConfig;
use grin_wallet_refwallet::{command, instantiate_wallet, NodeClient, WalletInst, WalletSeed};
use grin_wallet_refwallet::{Error, ErrorKind};
use linefeed::terminal::Signal;
use linefeed::{Interface, ReadResult};
use rpassword;
@@ -399,7 +399,7 @@ pub fn parse_send_args(args: &ArgMatches) -> Result<command::SendArgs, ParseErro
true => {
let v = parse_required(args, "target_slate_version")?;
Some(parse_u64(v, "target_slate_version")? as u16)
},
}
false => None,
}
};
+33 -29
View File
@@ -15,10 +15,10 @@
#[cfg(test)]
mod wallet_tests {
use clap;
use grin_refwallet;
use grin_util as util;
use grin_wallet_refwallet;
use grin_refwallet::test_framework::{self, LocalWalletClient, WalletProxy};
use grin_wallet_refwallet::test_framework::{self, LocalWalletClient, WalletProxy};
use clap::{App, ArgMatches};
use grin_util::Mutex;
@@ -30,8 +30,8 @@ mod wallet_tests {
use grin_core::global;
use grin_core::global::ChainTypes;
use grin_keychain::ExtKeychain;
use grin_refwallet::{LMDBBackend, WalletBackend, WalletInst, WalletSeed};
use grin_wallet_config::{GlobalWalletConfig, WalletConfig};
use grin_wallet_refwallet::{LMDBBackend, WalletBackend, WalletInst, WalletSeed};
use super::super::wallet_args;
@@ -49,7 +49,7 @@ mod wallet_tests {
pub fn config_command_wallet(
dir_name: &str,
wallet_name: &str,
) -> Result<(), grin_refwallet::Error> {
) -> Result<(), grin_wallet_refwallet::Error> {
let mut current_dir;
let mut default_config = GlobalWalletConfig::default();
current_dir = env::current_dir().unwrap_or_else(|e| {
@@ -61,7 +61,7 @@ mod wallet_tests {
let mut config_file_name = current_dir.clone();
config_file_name.push("grin-wallet.toml");
if config_file_name.exists() {
return Err(grin_refwallet::ErrorKind::ArgumentError(
return Err(grin_wallet_refwallet::ErrorKind::ArgumentError(
"grin-wallet.toml already exists in the target directory. Please remove it first"
.to_owned(),
))?;
@@ -122,7 +122,8 @@ mod wallet_tests {
node_client: LocalWalletClient,
passphrase: &str,
account: &str,
) -> Result<Arc<Mutex<WalletInst<LocalWalletClient, ExtKeychain>>>, grin_refwallet::Error> {
) -> Result<Arc<Mutex<WalletInst<LocalWalletClient, ExtKeychain>>>, grin_wallet_refwallet::Error>
{
wallet_config.chain_type = None;
// First test decryption, so we can abort early if we have the wrong password
let _ = WalletSeed::from_file(&wallet_config, passphrase)?;
@@ -138,7 +139,7 @@ mod wallet_tests {
wallet_name: &str,
client: &LocalWalletClient,
arg_vec: Vec<&str>,
) -> Result<String, grin_refwallet::Error> {
) -> Result<String, grin_wallet_refwallet::Error> {
let args = app.clone().get_matches_from(arg_vec);
let _ = get_wallet_subcommand(test_dir, wallet_name, args.clone());
let mut config = initial_setup_wallet(test_dir, wallet_name);
@@ -148,7 +149,7 @@ mod wallet_tests {
}
/// command line tests
fn command_line_test_impl(test_dir: &str) -> Result<(), grin_refwallet::Error> {
fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_refwallet::Error> {
setup(test_dir);
// Create a new proxy to simulate server and wallet responses
let mut wallet_proxy: WalletProxy<LocalWalletClient, ExtKeychain> =
@@ -191,9 +192,7 @@ mod wallet_tests {
});
// Create some accounts in wallet 1
let arg_vec = vec![
"grin-wallet", "-p", "password", "account", "-c", "mining",
];
let arg_vec = vec!["grin-wallet", "-p", "password", "account", "-c", "mining"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec![
@@ -240,7 +239,7 @@ mod wallet_tests {
// Mine a bit into wallet 1 so we have something to send
// (TODO: Be able to stop listeners so we can test this better)
let wallet1 = instantiate_wallet(config1.clone(), client1.clone(), "password", "default")?;
grin_refwallet::controller::owner_single_use(wallet1.clone(), |api| {
grin_wallet_refwallet::controller::owner_single_use(wallet1.clone(), |api| {
api.set_active_account("mining")?;
Ok(())
})?;
@@ -313,7 +312,7 @@ mod wallet_tests {
let wallet1 = instantiate_wallet(config1.clone(), client1.clone(), "password", "default")?;
// Check our transaction log, should have 10 entries
grin_refwallet::controller::owner_single_use(wallet1.clone(), |api| {
grin_wallet_refwallet::controller::owner_single_use(wallet1.clone(), |api| {
api.set_active_account("mining")?;
let (refreshed, txs) = api.retrieve_txs(true, None, None)?;
assert!(refreshed);
@@ -328,19 +327,12 @@ mod wallet_tests {
let arg_vec = vec!["grin-wallet", "-p", "password", "-a", "mining", "info"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec![
"grin-wallet",
"-p",
"password",
"-a",
"account_1",
"info",
];
let arg_vec = vec!["grin-wallet", "-p", "password", "-a", "account_1", "info"];
execute_command(&app, test_dir, "wallet2", &client1, arg_vec)?;
// check results in wallet 2
let wallet2 = instantiate_wallet(config2.clone(), client2.clone(), "password", "default")?;
grin_refwallet::controller::owner_single_use(wallet2.clone(), |api| {
grin_wallet_refwallet::controller::owner_single_use(wallet2.clone(), |api| {
api.set_active_account("account_1")?;
let (_, wallet1_info) = api.retrieve_summary_info(true, 1)?;
assert_eq!(wallet1_info.last_confirmed_height, bh);
@@ -396,7 +388,7 @@ mod wallet_tests {
// Check our transaction log, should have bh entries + one for the self receive
let wallet1 = instantiate_wallet(config1.clone(), client1.clone(), "password", "default")?;
grin_refwallet::controller::owner_single_use(wallet1.clone(), |api| {
grin_wallet_refwallet::controller::owner_single_use(wallet1.clone(), |api| {
api.set_active_account("mining")?;
let (refreshed, txs) = api.retrieve_txs(true, None, None)?;
assert!(refreshed);
@@ -430,7 +422,7 @@ mod wallet_tests {
// Check our transaction log, should have bh entries + 2 for the self receives
let wallet1 = instantiate_wallet(config1.clone(), client1.clone(), "password", "default")?;
grin_refwallet::controller::owner_single_use(wallet1.clone(), |api| {
grin_wallet_refwallet::controller::owner_single_use(wallet1.clone(), |api| {
api.set_active_account("mining")?;
let (refreshed, txs) = api.retrieve_txs(true, None, None)?;
assert!(refreshed);
@@ -478,7 +470,14 @@ mod wallet_tests {
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
let arg_vec = vec![
"grin-wallet", "-p", "password", "-a", "mining", "cancel", "-i", "26",
"grin-wallet",
"-p",
"password",
"-a",
"mining",
"cancel",
"-i",
"26",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
@@ -488,14 +487,19 @@ mod wallet_tests {
// message output (mostly spit out for a visual in test logs)
let arg_vec = vec![
"grin-wallet", "-p", "password", "-a", "mining", "txs", "-i", "10",
"grin-wallet",
"-p",
"password",
"-a",
"mining",
"txs",
"-i",
"10",
];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
// txs and outputs (mostly spit out for a visual in test logs)
let arg_vec = vec![
"grin-wallet", "-p", "password", "-a", "mining", "outputs",
];
let arg_vec = vec!["grin-wallet", "-p", "password", "-a", "mining", "outputs"];
execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;
// let logging finish