mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-01-20 19:11:09 +03:00
post late locked tx and assert amount on both wallets (#542)
cleanup wallet account setup
This commit is contained in:
parent
78960015fc
commit
92c5918e42
1 changed files with 10 additions and 15 deletions
|
@ -70,14 +70,12 @@ fn late_lock_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||||
// add some accounts
|
// add some accounts
|
||||||
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
|
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
|
||||||
api.create_account_path(m, "mining")?;
|
api.create_account_path(m, "mining")?;
|
||||||
api.create_account_path(m, "listener")?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// add some accounts
|
// add some accounts
|
||||||
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
|
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
|
||||||
api.create_account_path(m, "account1")?;
|
api.create_account_path(m, "account1")?;
|
||||||
api.create_account_path(m, "account2")?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -91,12 +89,10 @@ fn late_lock_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||||
w.set_parent_key_id_by_name("account1")?;
|
w.set_parent_key_id_by_name("account1")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let bh = 10u64;
|
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 10, false)?;
|
||||||
let _ =
|
|
||||||
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, bh as usize, false);
|
|
||||||
|
|
||||||
let mut slate = Slate::blank(2, false);
|
let mut slate = Slate::blank(2, false);
|
||||||
let amount = 60_000_000_000;
|
let amount = 100_000_000_000;
|
||||||
|
|
||||||
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
|
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |sender_api, m| {
|
||||||
let args = InitTxArgs {
|
let args = InitTxArgs {
|
||||||
|
@ -120,29 +116,28 @@ fn late_lock_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||||
slate = sender_api.finalize_tx(m, &slate)?;
|
slate = sender_api.finalize_tx(m, &slate)?;
|
||||||
println!("S3 SLATE: {}", slate);
|
println!("S3 SLATE: {}", slate);
|
||||||
|
|
||||||
|
// Now post tx to our node for inclusion in the next block.
|
||||||
|
sender_api.post_tx(m, &slate, true)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 3, false);
|
test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), mask1, 3, false)?;
|
||||||
|
|
||||||
// update/test contents of both accounts
|
// update/test contents of both accounts
|
||||||
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
|
wallet::controller::owner_single_use(Some(wallet1.clone()), mask1, None, |api, m| {
|
||||||
let (wallet1_refreshed, wallet_info) = api.retrieve_summary_info(m, true, 1)?;
|
let (wallet1_refreshed, wallet_info) = api.retrieve_summary_info(m, true, 1)?;
|
||||||
assert!(wallet1_refreshed);
|
assert!(wallet1_refreshed);
|
||||||
print!(
|
// Reward from mining 11 blocks, minus the amount sent.
|
||||||
"Wallet 1 amount: {}",
|
// Note: We mined the block containing the tx, so fees are effectively refunded.
|
||||||
wallet_info.amount_currently_spendable
|
assert_eq!(560_000_000_000, wallet_info.amount_currently_spendable);
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
|
wallet::controller::owner_single_use(Some(wallet2.clone()), mask2, None, |api, m| {
|
||||||
let (wallet2_refreshed, wallet_info) = api.retrieve_summary_info(m, true, 1)?;
|
let (wallet2_refreshed, wallet_info) = api.retrieve_summary_info(m, true, 1)?;
|
||||||
assert!(wallet2_refreshed);
|
assert!(wallet2_refreshed);
|
||||||
println!(
|
assert_eq!(amount, wallet_info.amount_currently_spendable);
|
||||||
"Wallet 2 amount: {}",
|
|
||||||
wallet_info.amount_currently_spendable
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue