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);
|
assert_eq!(txs.len(), 5);
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// now check second account
|
// now check second account
|
||||||
{
|
{
|
||||||
let mut w_lock = wallet1.lock();
|
// let mut w_lock = wallet1.lock();
|
||||||
let lc = w_lock.lc_provider()?;
|
// let lc = w_lock.lc_provider()?;
|
||||||
let w = lc.wallet_inst()?;
|
// let w = lc.wallet_inst()?;
|
||||||
|
wallet_inst!(wallet1, w);
|
||||||
w.set_parent_key_id_by_name("account1")?;
|
w.set_parent_key_id_by_name("account1")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
|
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
|
||||||
// check last confirmed height on this account is different from above (should be 0)
|
// check last confirmed height on this account is different from above (should be 0)
|
||||||
let (_, wallet1_info) = api.retrieve_summary_info(m, false, 1)?;
|
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);
|
wallet_inst!(wallet1, w);
|
||||||
w.set_parent_key_id_by_name("account1")?;
|
w.set_parent_key_id_by_name("account1")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
|
wallet::controller::owner_single_use(wallet1.clone(), mask1, |api, m| {
|
||||||
let args = InitTxArgs {
|
let args = InitTxArgs {
|
||||||
src_acct_name: None,
|
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().len(), 1);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
slate.tx.kernels().first().map(|k| k.features).unwrap(),
|
slate.tx.kernels().first().map(|k| k.features).unwrap(),
|
||||||
transaction::KernelFeatures::Plain { fee: 0 }
|
transaction::KernelFeatures::Plain { fee: 2000000 }
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -26,6 +26,7 @@ use crate::core::{pow, ser};
|
||||||
use crate::keychain::Keychain;
|
use crate::keychain::Keychain;
|
||||||
use crate::libwallet;
|
use crate::libwallet;
|
||||||
use crate::libwallet::api_impl::foreign;
|
use crate::libwallet::api_impl::foreign;
|
||||||
|
use crate::libwallet::slate_versions::v2::SlateV2;
|
||||||
use crate::libwallet::{
|
use crate::libwallet::{
|
||||||
NodeClient, NodeVersionInfo, Slate, TxWrapper, WalletInst, WalletLCProvider,
|
NodeClient, NodeVersionInfo, Slate, TxWrapper, WalletInst, WalletLCProvider,
|
||||||
};
|
};
|
||||||
|
@ -214,23 +215,30 @@ where
|
||||||
Some(w) => w,
|
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()),
|
libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper".to_owned()),
|
||||||
)?;
|
)?;
|
||||||
;
|
|
||||||
{
|
let slate: Slate = {
|
||||||
let mut w_lock = wallet.1.lock();
|
let mut w_lock = wallet.1.lock();
|
||||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||||
let mask = wallet.2.clone();
|
let mask = wallet.2.clone();
|
||||||
// receive tx
|
// 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 {
|
Ok(WalletProxyMessage {
|
||||||
sender_id: m.dest,
|
sender_id: m.dest,
|
||||||
dest: m.sender_id,
|
dest: m.sender_id,
|
||||||
method: m.method,
|
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(),
|
sender_id: self.id.clone(),
|
||||||
dest: dest.to_owned(),
|
dest: dest.to_owned(),
|
||||||
method: "send_tx_slate".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();
|
let p = self.proxy_tx.lock();
|
||||||
|
@ -343,11 +351,10 @@ impl LocalWalletClient {
|
||||||
let r = self.rx.lock();
|
let r = self.rx.lock();
|
||||||
let m = r.recv().unwrap();
|
let m = r.recv().unwrap();
|
||||||
trace!("Received send_tx_slate response: {:?}", m.clone());
|
trace!("Received send_tx_slate response: {:?}", m.clone());
|
||||||
Ok(
|
let slate: SlateV2 = serde_json::from_str(&m.body).context(
|
||||||
serde_json::from_str(&m.body).context(libwallet::ErrorKind::ClientCallback(
|
libwallet::ErrorKind::ClientCallback("Parsing send_tx_slate response".to_owned()),
|
||||||
"Parsing send_tx_slate response".to_owned(),
|
)?;
|
||||||
))?,
|
Ok(Slate::from(slate))
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue