[WIP] V2 API Doctest generation (#24)

V2 API Doctest generation
This commit is contained in:
Yeastplume
2019-03-22 12:03:25 +00:00
committed by GitHub
parent 64772e6021
commit 94960b3edd
37 changed files with 1645 additions and 725 deletions
+1 -1
View File
@@ -27,7 +27,7 @@ term = "0.5"
tokio = "= 0.1.11"
tokio-core = "0.1"
tokio-retry = "0.1"
uuid = { version = "0.6", features = ["serde", "v4"] }
uuid = { version = "0.7", features = ["serde", "v4"] }
url = "1.7.0"
chrono = { version = "0.4.4", features = ["serde"] }
+4 -4
View File
@@ -247,7 +247,7 @@ pub fn send(
let strategies = vec!["smallest", "all"]
.into_iter()
.map(|strategy| {
let (total, fee) = api
let est = api
.estimate_initiate_tx(
None,
args.amount,
@@ -257,7 +257,7 @@ pub fn send(
strategy == "all",
)
.unwrap();
(strategy, total, fee)
(strategy, est.total, est.fee)
})
.collect();
display::estimate(args.amount, strategies, dark_scheme);
@@ -307,7 +307,7 @@ pub fn send(
error!("Error validating participant messages: {}", e);
return Err(e);
}
api.finalize_tx(&mut slate)?;
slate = api.finalize_tx(&slate)?;
} else {
adapter.send_tx_async(&args.dest, &slate)?;
api.tx_lock_outputs(&slate)?;
@@ -378,7 +378,7 @@ pub fn finalize(
error!("Error validating participant messages: {}", e);
return Err(e);
}
let _ = api.finalize_tx(&mut slate).expect("Finalize failed");
slate = api.finalize_tx(&mut slate).expect("Finalize failed");
let result = api.post_tx(&slate.tx, args.fluff);
match result {
+5 -6
View File
@@ -23,10 +23,9 @@ use crate::impls::{FileWalletCommAdapter, HTTPWalletCommAdapter, KeybaseWalletCo
use crate::keychain::Keychain;
use crate::libwallet::slate::Slate;
use crate::libwallet::types::{
CbData, NodeClient, OutputData, SendTXArgs, TxLogEntry, WalletBackend, WalletInfo,
CbData, NodeClient, OutputCommitMapping, SendTXArgs, TxLogEntry, WalletBackend, WalletInfo,
};
use crate::libwallet::{Error, ErrorKind};
use crate::util::secp::pedersen;
use crate::util::to_base64;
use crate::util::Mutex;
use failure::ResultExt;
@@ -187,7 +186,7 @@ where
&self,
req: &Request<Body>,
api: Owner<T, C, K>,
) -> Result<(bool, Vec<(OutputData, pedersen::Commitment)>), Error> {
) -> Result<(bool, Vec<OutputCommitMapping>), Error> {
let mut update_from_node = false;
let mut id = None;
let mut show_spent = false;
@@ -373,7 +372,7 @@ where
}
api.tx_lock_outputs(&slate)?;
if args.method != "file" {
api.finalize_tx(&mut slate)?;
slate = api.finalize_tx(&slate)?;
}
Ok(slate)
}))
@@ -385,8 +384,8 @@ where
api: Owner<T, C, K>,
) -> Box<dyn Future<Item = Slate, Error = Error> + Send> {
Box::new(
parse_body(req).and_then(move |mut slate| match api.finalize_tx(&mut slate) {
Ok(_) => ok(slate.clone()),
parse_body(req).and_then(move |slate| match api.finalize_tx(&slate) {
Ok(s) => ok(s.clone()),
Err(e) => {
error!("finalize_tx: failed with error: {}", e);
err(e)
+16 -15
View File
@@ -14,10 +14,11 @@
use crate::core::core::{self, amount_to_hr_string};
use crate::core::global;
use crate::libwallet::types::{AcctPathMapping, OutputData, OutputStatus, TxLogEntry, WalletInfo};
use crate::libwallet::types::{
AcctPathMapping, OutputCommitMapping, OutputStatus, TxLogEntry, WalletInfo,
};
use crate::libwallet::Error;
use crate::util;
use crate::util::secp::pedersen;
use prettytable;
use std::io::prelude::Write;
use term;
@@ -27,7 +28,7 @@ pub fn outputs(
account: &str,
cur_height: u64,
validated: bool,
outputs: Vec<(OutputData, pedersen::Commitment)>,
outputs: Vec<OutputCommitMapping>,
dark_background_color_scheme: bool,
) -> Result<(), Error> {
let title = format!(
@@ -54,25 +55,25 @@ pub fn outputs(
bMG->"Tx"
]);
for (out, commit) in outputs {
let commit = format!("{}", util::to_hex(commit.as_ref().to_vec()));
let index = match out.mmr_index {
for m in outputs {
let commit = format!("{}", util::to_hex(m.commit.as_ref().to_vec()));
let index = match m.output.mmr_index {
None => "None".to_owned(),
Some(t) => t.to_string(),
};
let height = format!("{}", out.height);
let lock_height = format!("{}", out.lock_height);
let is_coinbase = format!("{}", out.is_coinbase);
let height = format!("{}", m.output.height);
let lock_height = format!("{}", m.output.lock_height);
let is_coinbase = format!("{}", m.output.is_coinbase);
// Mark unconfirmed coinbase outputs as "Mining" instead of "Unconfirmed"
let status = match out.status {
OutputStatus::Unconfirmed if out.is_coinbase => "Mining".to_string(),
_ => format!("{}", out.status),
let status = match m.output.status {
OutputStatus::Unconfirmed if m.output.is_coinbase => "Mining".to_string(),
_ => format!("{}", m.output.status),
};
let num_confirmations = format!("{}", out.num_confirmations(cur_height));
let value = format!("{}", core::amount_to_hr_string(out.value, false));
let tx = match out.tx_log_entry {
let num_confirmations = format!("{}", m.output.num_confirmations(cur_height));
let value = format!("{}", core::amount_to_hr_string(m.output.value, false));
let tx = match m.output.tx_log_entry {
None => "".to_owned(),
Some(t) => t.to_string(),
};
+3 -3
View File
@@ -111,14 +111,14 @@ fn accounts_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
w.set_parent_key_id_by_name("account1")?;
assert_eq!(w.parent_key_id(), ExtKeychain::derive_key_id(2, 1, 0, 0, 0));
}
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 7);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 7, false);
{
let mut w = wallet1.lock();
w.set_parent_key_id_by_name("account2")?;
assert_eq!(w.parent_key_id(), ExtKeychain::derive_key_id(2, 2, 0, 0, 0));
}
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 5);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 5, false);
// Should have 5 in account1 (5 spendable), 5 in account (2 spendable)
wallet::controller::owner_single_use(wallet1.clone(), |api| {
@@ -188,7 +188,7 @@ fn accounts_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
)?;
slate = client1.send_tx_slate_direct("wallet2", &slate)?;
api.tx_lock_outputs(&slate)?;
api.finalize_tx(&mut slate)?;
slate = api.finalize_tx(&slate)?;
api.post_tx(&slate.tx, false)?;
Ok(())
})?;
+9 -9
View File
@@ -38,7 +38,7 @@ macro_rules! send_to_dest {
WalletInst<LocalWalletClient, ExtKeychain>,
LocalWalletClient,
ExtKeychain,
>($a, $b, $c, $d)
>($a, $b, $c, $d, false)
};
}
@@ -111,7 +111,7 @@ fn check_repair_impl(test_dir: &str) -> Result<(), libwallet::Error> {
// Do some mining
let bh = 20u64;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), bh as usize);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), bh as usize, false);
// Sanity check contents
wallet::controller::owner_single_use(wallet1.clone(), |api| {
@@ -135,7 +135,7 @@ fn check_repair_impl(test_dir: &str) -> Result<(), libwallet::Error> {
Ok(())
})?;
let w1_outputs: Vec<libwallet::types::OutputData> =
w1_outputs_commits.into_iter().map(|o| o.0).collect();
w1_outputs_commits.into_iter().map(|m| m.output).collect();
{
let mut w = wallet1.lock();
w.open_with_credentials()?;
@@ -337,7 +337,7 @@ fn two_wallets_one_seed_impl(test_dir: &str) -> Result<(), libwallet::Error> {
// Do some mining
let mut bh = 20u64;
let base_amount = consensus::GRIN_BASE;
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), bh as usize);
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), bh as usize, false);
// send some funds to wallets 1
send_to_dest!(miner.clone(), m_client.clone(), "wallet1", base_amount * 1)?;
@@ -360,7 +360,7 @@ fn two_wallets_one_seed_impl(test_dir: &str) -> Result<(), libwallet::Error> {
send_to_dest!(miner.clone(), m_client.clone(), "wallet2", base_amount * 6)?;
bh += 3;
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm);
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm, false);
bh += cm as u64;
// confirm balances
@@ -411,7 +411,7 @@ fn two_wallets_one_seed_impl(test_dir: &str) -> Result<(), libwallet::Error> {
send_to_dest!(miner.clone(), m_client.clone(), "wallet4", base_amount * 9)?;
bh += 3;
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm);
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm, false);
bh += cm as u64;
wallet::controller::owner_single_use(wallet4.clone(), |api| {
@@ -442,7 +442,7 @@ fn two_wallets_one_seed_impl(test_dir: &str) -> Result<(), libwallet::Error> {
send_to_dest!(miner.clone(), m_client.clone(), "wallet6", base_amount * 12)?;
bh += 3;
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm as usize);
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm as usize, false);
bh += cm as u64;
wallet::controller::owner_single_use(wallet6.clone(), |api| {
@@ -487,7 +487,7 @@ fn two_wallets_one_seed_impl(test_dir: &str) -> Result<(), libwallet::Error> {
bh += 3;
// check balances
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm);
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm, false);
bh += cm as u64;
wallet::controller::owner_single_use(wallet7.clone(), |api| {
@@ -552,7 +552,7 @@ fn two_wallets_one_seed_impl(test_dir: &str) -> Result<(), libwallet::Error> {
Ok(())
})?;
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm);
let _ = test_framework::award_blocks_to_wallet(&chain, miner.clone(), cm, false);
// 7) Ensure check_repair creates missing accounts
wallet::controller::owner_single_use(wallet10.clone(), |api| {
+3 -3
View File
@@ -89,7 +89,7 @@ fn file_exchange_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
w.set_parent_key_id_by_name("mining")?;
}
let mut bh = 10u64;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), bh as usize);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), bh as usize, false);
let send_file = format!("{}/part_tx_1.tx", test_dir);
let receive_file = format!("{}/part_tx_2.tx", test_dir);
@@ -153,13 +153,13 @@ fn file_exchange_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
let adapter = FileWalletCommAdapter::new();
let mut slate = adapter.receive_tx_async(&receive_file)?;
api.verify_slate_messages(&slate)?;
api.finalize_tx(&mut slate)?;
slate = api.finalize_tx(&slate)?;
api.post_tx(&slate.tx, false)?;
bh += 1;
Ok(())
})?;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
bh += 3;
// Check total in mining account
+7 -7
View File
@@ -88,7 +88,7 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
w.set_parent_key_id_by_name("mining")?;
}
let mut bh = 10u64;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), bh as usize);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), bh as usize, false);
let send_file = format!("{}/part_tx_1.tx", test_dir);
let receive_file = format!("{}/part_tx_2.tx", test_dir);
@@ -119,7 +119,7 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
Ok(())
})?;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
bh += 3;
// wallet 1 receives file to different account, completes
@@ -146,7 +146,7 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
wallet::controller::owner_single_use(wallet1.clone(), |api| {
let adapter = FileWalletCommAdapter::new();
slate = adapter.receive_tx_async(&receive_file)?;
api.finalize_tx(&mut slate)?;
slate = api.finalize_tx(&slate)?;
Ok(())
})?;
@@ -159,7 +159,7 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
Ok(())
})?;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
bh += 3;
// update/test contents of both accounts
@@ -211,11 +211,11 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
)?;
slate = client1.send_tx_slate_direct("wallet2", &slate_i)?;
sender_api.tx_lock_outputs(&slate)?;
sender_api.finalize_tx(&mut slate)?;
slate = sender_api.finalize_tx(&mut slate)?;
Ok(())
})?;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
bh += 3;
// Now repost from cached
@@ -227,7 +227,7 @@ fn file_repost_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
Ok(())
})?;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
bh += 3;
//
// update/test contents of both accounts
+9 -9
View File
@@ -228,7 +228,7 @@ fn setup_restore(test_dir: &str) -> Result<(), libwallet::Error> {
});
// mine a few blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 10);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 10, false);
// assert wallet contents
// and a single use api for a send command
@@ -246,13 +246,13 @@ fn setup_restore(test_dir: &str) -> Result<(), libwallet::Error> {
)?;
slate = client1.send_tx_slate_direct("wallet2", &slate_i)?;
sender_api.tx_lock_outputs(&slate)?;
sender_api.finalize_tx(&mut slate)?;
slate = sender_api.finalize_tx(&slate)?;
sender_api.post_tx(&slate.tx, false)?;
Ok(())
})?;
// mine a few more blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
// Send some to wallet 3
wallet::controller::owner_single_use(wallet1.clone(), |sender_api| {
@@ -269,13 +269,13 @@ fn setup_restore(test_dir: &str) -> Result<(), libwallet::Error> {
)?;
slate = client1.send_tx_slate_direct("wallet3", &slate_i)?;
sender_api.tx_lock_outputs(&slate)?;
sender_api.finalize_tx(&mut slate)?;
slate = sender_api.finalize_tx(&slate)?;
sender_api.post_tx(&slate.tx, false)?;
Ok(())
})?;
// mine a few more blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet3.clone(), 10);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet3.clone(), 10, false);
// Wallet3 to wallet 2
wallet::controller::owner_single_use(wallet3.clone(), |sender_api| {
@@ -292,7 +292,7 @@ fn setup_restore(test_dir: &str) -> Result<(), libwallet::Error> {
)?;
slate = client3.send_tx_slate_direct("wallet2", &slate_i)?;
sender_api.tx_lock_outputs(&slate)?;
sender_api.finalize_tx(&mut slate)?;
slate = sender_api.finalize_tx(&slate)?;
sender_api.post_tx(&slate.tx, false)?;
Ok(())
})?;
@@ -304,7 +304,7 @@ fn setup_restore(test_dir: &str) -> Result<(), libwallet::Error> {
}
// mine a few more blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 2);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 2, false);
// Wallet3 to wallet 2 again (to another account)
wallet::controller::owner_single_use(wallet3.clone(), |sender_api| {
@@ -321,13 +321,13 @@ fn setup_restore(test_dir: &str) -> Result<(), libwallet::Error> {
)?;
slate = client3.send_tx_slate_direct("wallet2", &slate_i)?;
sender_api.tx_lock_outputs(&slate)?;
sender_api.finalize_tx(&mut slate)?;
slate = sender_api.finalize_tx(&slate)?;
sender_api.post_tx(&slate.tx, false)?;
Ok(())
})?;
// mine a few more blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 5);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 5, false);
// update everyone
wallet::controller::owner_single_use(wallet1.clone(), |api| {
+3 -3
View File
@@ -76,7 +76,7 @@ fn self_send_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
w.set_parent_key_id_by_name("mining")?;
}
let mut bh = 10u64;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), bh as usize);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), bh as usize, false);
// Should have 5 in account1 (5 spendable), 5 in account (2 spendable)
wallet::controller::owner_single_use(wallet1.clone(), |api| {
@@ -101,13 +101,13 @@ fn self_send_test_impl(test_dir: &str) -> Result<(), libwallet::Error> {
api.receive_tx(&mut slate, Some("listener"), None)?;
Ok(())
})?;
api.finalize_tx(&mut slate)?;
slate = api.finalize_tx(&slate)?;
api.post_tx(&slate.tx, false)?; // mines a block
bh += 1;
Ok(())
})?;
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
bh += 3;
// Check total in mining account
+21 -21
View File
@@ -75,7 +75,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
let reward = core::consensus::REWARD;
let cm = global::coinbase_maturity(); // assume all testing precedes soft fork height
// mine a few blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 10);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 10, false);
// Check wallet 1 contents are as expected
wallet::controller::owner_single_use(wallet1.clone(), |api| {
@@ -114,7 +114,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
slate = client1.send_tx_slate_direct("wallet2", &slate_i)?;
sender_api.tx_lock_outputs(&slate)?;
sender_api.finalize_tx(&mut slate)?;
slate = sender_api.finalize_tx(&slate)?;
// Check we have a single kernel and that it is a Plain kernel (no lock_height).
assert_eq!(slate.tx.kernels().len(), 1);
@@ -213,7 +213,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
})?;
// mine a few more blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
// refresh wallets and retrieve info/tests for each wallet after maturity
wallet::controller::owner_single_use(wallet1.clone(), |api| {
@@ -249,7 +249,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
// Estimate fee and locked amount for a transaction
wallet::controller::owner_single_use(wallet1.clone(), |sender_api| {
let (total, fee) = sender_api.estimate_initiate_tx(
let est = sender_api.estimate_initiate_tx(
None,
amount * 2, // amount
2, // minimum confirmations
@@ -257,10 +257,10 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
1, // num change outputs
true, // select all outputs
)?;
assert_eq!(total, 600_000_000_000);
assert_eq!(fee, 4_000_000);
assert_eq!(est.total, 600_000_000_000);
assert_eq!(est.fee, 4_000_000);
let (total, fee) = sender_api.estimate_initiate_tx(
let est = sender_api.estimate_initiate_tx(
None,
amount * 2, // amount
2, // minimum confirmations
@@ -268,8 +268,8 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
1, // num change outputs
false, // select the smallest amount of outputs
)?;
assert_eq!(total, 180_000_000_000);
assert_eq!(fee, 6_000_000);
assert_eq!(est.total, 180_000_000_000);
assert_eq!(est.fee, 6_000_000);
Ok(())
})?;
@@ -290,7 +290,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
)?;
slate = client1.send_tx_slate_direct("wallet2", &slate_i)?;
sender_api.tx_lock_outputs(&slate)?;
sender_api.finalize_tx(&mut slate)?;
slate = sender_api.finalize_tx(&slate)?;
Ok(())
})?;
@@ -315,7 +315,7 @@ fn basic_transaction_api(test_dir: &str) -> Result<(), libwallet::Error> {
})?;
// mine a few more blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 3, false);
// check wallet2 has stored transaction
wallet::controller::owner_single_use(wallet2.clone(), |api| {
@@ -371,7 +371,7 @@ fn tx_rollback(test_dir: &str) -> Result<(), libwallet::Error> {
let reward = core::consensus::REWARD;
let cm = global::coinbase_maturity(); // assume all testing precedes soft fork height
// mine a few blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 5);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 5, false);
let amount = 30_000_000_000;
let mut slate = Slate::blank(1);
@@ -387,7 +387,7 @@ fn tx_rollback(test_dir: &str) -> Result<(), libwallet::Error> {
)?;
slate = client1.send_tx_slate_direct("wallet2", &slate_i)?;
sender_api.tx_lock_outputs(&slate)?;
sender_api.finalize_tx(&mut slate)?;
slate = sender_api.finalize_tx(&slate)?;
Ok(())
})?;
@@ -406,16 +406,16 @@ fn tx_rollback(test_dir: &str) -> Result<(), libwallet::Error> {
let mut locked_count = 0;
let mut unconfirmed_count = 0;
// get the tx entry, check outputs are as expected
let (_, outputs) = api.retrieve_outputs(true, false, Some(tx.unwrap().id))?;
for (o, _) in outputs.clone() {
if o.status == OutputStatus::Locked {
let (_, output_mappings) = api.retrieve_outputs(true, false, Some(tx.unwrap().id))?;
for m in output_mappings.clone() {
if m.output.status == OutputStatus::Locked {
locked_count = locked_count + 1;
}
if o.status == OutputStatus::Unconfirmed {
if m.output.status == OutputStatus::Unconfirmed {
unconfirmed_count = unconfirmed_count + 1;
}
}
assert_eq!(outputs.len(), 3);
assert_eq!(output_mappings.len(), 3);
assert_eq!(locked_count, 2);
assert_eq!(unconfirmed_count, 1);
@@ -431,8 +431,8 @@ fn tx_rollback(test_dir: &str) -> Result<(), libwallet::Error> {
assert!(tx.is_some());
// get the tx entry, check outputs are as expected
let (_, outputs) = api.retrieve_outputs(true, false, Some(tx.unwrap().id))?;
for (o, _) in outputs.clone() {
if o.status == OutputStatus::Unconfirmed {
for m in outputs.clone() {
if m.output.status == OutputStatus::Unconfirmed {
unconfirmed_count = unconfirmed_count + 1;
}
}
@@ -447,7 +447,7 @@ fn tx_rollback(test_dir: &str) -> Result<(), libwallet::Error> {
// wallet 1 is bold and doesn't ever post the transaction
// mine a few more blocks
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 5);
let _ = test_framework::award_blocks_to_wallet(&chain, wallet1.clone(), 5, false);
// Wallet 1 decides to roll back instead
wallet::controller::owner_single_use(wallet1.clone(), |api| {