From fbc8173629cc240132539ee1e9dfe8565108bb0a Mon Sep 17 00:00:00 2001 From: antiochp <30642645+antiochp@users.noreply.github.com> Date: Tue, 20 Aug 2019 00:51:35 +0100 Subject: [PATCH] fixup controller tests --- controller/tests/accounts.rs | 10 +++++---- controller/tests/transaction.rs | 2 +- impls/src/test_framework/testclient.rs | 31 ++++++++++++++++---------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/controller/tests/accounts.rs b/controller/tests/accounts.rs index 8350a55b..aee816f0 100644 --- a/controller/tests/accounts.rs +++ b/controller/tests/accounts.rs @@ -137,13 +137,16 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> { assert_eq!(txs.len(), 5); Ok(()) })?; + // now check second account { - let mut w_lock = wallet1.lock(); - let lc = w_lock.lc_provider()?; - let w = lc.wallet_inst()?; + // let mut w_lock = wallet1.lock(); + // let lc = w_lock.lc_provider()?; + // let w = lc.wallet_inst()?; + wallet_inst!(wallet1, w); w.set_parent_key_id_by_name("account1")?; } + wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| { // check last confirmed height on this account is different from above (should be 0) let (_, wallet1_info) = api.retrieve_summary_info(m, false, 1)?; @@ -183,7 +186,6 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> { wallet_inst!(wallet1, w); w.set_parent_key_id_by_name("account1")?; } - wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| { let args = InitTxArgs { src_acct_name: None, diff --git a/controller/tests/transaction.rs b/controller/tests/transaction.rs index 6c79e1f5..361f12f6 100644 --- a/controller/tests/transaction.rs +++ b/controller/tests/transaction.rs @@ -121,7 +121,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error> assert_eq!(slate.tx.kernels().len(), 1); assert_eq!( slate.tx.kernels().first().map(|k| k.features).unwrap(), - transaction::KernelFeatures::Plain { fee: 0 } + transaction::KernelFeatures::Plain { fee: 2000000 } ); Ok(()) diff --git a/impls/src/test_framework/testclient.rs b/impls/src/test_framework/testclient.rs index 0c9b67f7..1e75889b 100644 --- a/impls/src/test_framework/testclient.rs +++ b/impls/src/test_framework/testclient.rs @@ -26,6 +26,7 @@ use crate::core::{pow, ser}; use crate::keychain::Keychain; use crate::libwallet; use crate::libwallet::api_impl::foreign; +use crate::libwallet::slate_versions::v2::SlateV2; use crate::libwallet::{ NodeClient, NodeVersionInfo, Slate, TxWrapper, WalletInst, WalletLCProvider, }; @@ -214,23 +215,30 @@ where Some(w) => w, }; - let mut slate = serde_json::from_str(&m.body).context( + let slate: SlateV2 = serde_json::from_str(&m.body).context( libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper".to_owned()), )?; -; - { + + let slate: Slate = { let mut w_lock = wallet.1.lock(); let w = w_lock.lc_provider()?.wallet_inst()?; let mask = wallet.2.clone(); // receive tx - slate = foreign::receive_tx(&mut **w, (&mask).as_ref(), &slate, None, None, false)?; - } + foreign::receive_tx( + &mut **w, + (&mask).as_ref(), + &Slate::from(slate), + None, + None, + false, + )? + }; Ok(WalletProxyMessage { sender_id: m.dest, dest: m.sender_id, method: m.method, - body: serde_json::to_string(&slate).unwrap(), + body: serde_json::to_string(&SlateV2::from(slate)).unwrap(), }) } @@ -332,7 +340,7 @@ impl LocalWalletClient { sender_id: self.id.clone(), dest: dest.to_owned(), method: "send_tx_slate".to_owned(), - body: serde_json::to_string(slate).unwrap(), + body: serde_json::to_string(&SlateV2::from(slate)).unwrap(), }; { let p = self.proxy_tx.lock(); @@ -343,11 +351,10 @@ impl LocalWalletClient { let r = self.rx.lock(); let m = r.recv().unwrap(); trace!("Received send_tx_slate response: {:?}", m.clone()); - Ok( - serde_json::from_str(&m.body).context(libwallet::ErrorKind::ClientCallback( - "Parsing send_tx_slate response".to_owned(), - ))?, - ) + let slate: SlateV2 = serde_json::from_str(&m.body).context( + libwallet::ErrorKind::ClientCallback("Parsing send_tx_slate response".to_owned()), + )?; + Ok(Slate::from(slate)) } }