mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-02-01 08:51:09 +03:00
fixup controller tests
This commit is contained in:
parent
1f76d70209
commit
fbc8173629
3 changed files with 26 additions and 17 deletions
|
@ -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,
|
||||
|
|
|
@ -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(())
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue