Skip to content

Commit

Permalink
fixup controller tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antiochp committed Aug 19, 2019
1 parent 1f76d70 commit fbc8173
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
10 changes: 6 additions & 4 deletions controller/tests/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion controller/tests/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
31 changes: 19 additions & 12 deletions impls/src/test_framework/testclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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(),
})
}

Expand Down Expand Up @@ -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();
Expand All @@ -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))
}
}

Expand Down

0 comments on commit fbc8173

Please sign in to comment.