Add linter to CI (#823)

Co-authored-by: wiesche <wiesche89@googlemail.com>
This commit is contained in:
ardocrat
2026-10-07 20:48:38 +03:00
committed by GitHub
co-authored by wiesche
parent ec1e9910af
commit fe79256467
87 changed files with 1300 additions and 1639 deletions
+2 -2
View File
@@ -52,7 +52,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
@@ -66,7 +66,7 @@ fn accounts_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+2 -2
View File
@@ -50,7 +50,7 @@ fn build_chain(test_dir: &'static str, block_height: usize) -> Result<(), libwal
true,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
debug!("Mask1: {:?}", mask1);
create_wallet_and_add!(
client2,
@@ -63,7 +63,7 @@ fn build_chain(test_dir: &'static str, block_height: usize) -> Result<(), libwal
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
debug!("Mask2: {:?}", mask2);
// Set the wallet proxy listener running
+1 -1
View File
@@ -55,7 +55,7 @@ fn build_output_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+18 -18
View File
@@ -68,7 +68,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -80,7 +80,7 @@ fn scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
@@ -223,7 +223,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
_m_api
);
let miner_mask = (&miner_mask_i).as_ref();
let miner_mask = miner_mask_i.as_ref();
// non-mining recipient wallets
create_wallet_and_add!(
@@ -237,7 +237,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -249,7 +249,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
_api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// we'll restore into here
create_wallet_and_add!(
client3,
@@ -262,7 +262,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
api3
);
let mask3 = (&mask3_i).as_ref();
let mask3 = mask3_i.as_ref();
// also restore into here
create_wallet_and_add!(
client4,
@@ -275,7 +275,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
api4
);
let mask4 = (&mask4_i).as_ref();
let mask4 = mask4_i.as_ref();
// Simulate a recover from seed without restore into here
create_wallet_and_add!(
client5,
@@ -289,7 +289,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
api5
);
//simulate a recover from seed without restore into here
let mask5 = (&mask5_i).as_ref();
let mask5 = mask5_i.as_ref();
create_wallet_and_add!(
client6,
wallet6,
@@ -301,7 +301,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
api6
);
let mask6 = (&mask6_i).as_ref();
let mask6 = mask6_i.as_ref();
create_wallet_and_add!(
client7,
@@ -314,7 +314,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
api7
);
let mask7 = (&mask7_i).as_ref();
let mask7 = mask7_i.as_ref();
create_wallet_and_add!(
client8,
wallet8,
@@ -326,7 +326,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
api8
);
let mask8 = (&mask8_i).as_ref();
let mask8 = mask8_i.as_ref();
create_wallet_and_add!(
client9,
wallet9,
@@ -338,7 +338,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
api9
);
let mask9 = (&mask9_i).as_ref();
let mask9 = mask9_i.as_ref();
create_wallet_and_add!(
client10,
wallet10,
@@ -350,7 +350,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
false,
api10
);
let mask10 = (&mask10_i).as_ref();
let mask10 = mask10_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
@@ -380,7 +380,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
miner_mask,
m_client.clone(),
"wallet1",
base_amount * 1
base_amount
)?;
send_to_dest!(
miner.clone(),
@@ -579,7 +579,7 @@ fn two_wallets_one_seed_impl(test_dir: &'static str) -> Result<(), libwallet::Er
miner_mask,
m_client.clone(),
"wallet7",
base_amount * 1
base_amount
)?;
send_to_dest!(
miner.clone(),
@@ -710,7 +710,7 @@ fn output_scanning_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
false,
_api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
error!("Wallet Proxy error: {}", e);
@@ -795,7 +795,7 @@ fn multi_batch_scan_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
@@ -886,7 +886,7 @@ fn restore_corrupted_outputs_across_batches_impl(
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
+11 -22
View File
@@ -109,6 +109,7 @@ pub fn create_wallet_proxy(
WalletProxy::new(test_dir)
}
#[allow(clippy::type_complexity)]
pub fn create_local_wallet(
test_dir: &str,
name: &str,
@@ -116,17 +117,11 @@ pub fn create_local_wallet(
client: LocalWalletClient,
create_mask: bool,
) -> (
Arc<
Mutex<
Box<
dyn WalletInst<
'static,
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
LocalWalletClient,
ExtKeychain,
>,
>,
>,
grin_wallet_libwallet::WalletHandle<
'static,
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
LocalWalletClient,
ExtKeychain,
>,
Option<SecretKey>,
Owner<DefaultLCProvider<LocalWalletClient, ExtKeychain>, LocalWalletClient, ExtKeychain>,
@@ -178,17 +173,11 @@ pub fn open_local_wallet(
client: LocalWalletClient,
create_mask: bool,
) -> (
Arc<
Mutex<
Box<
dyn WalletInst<
'static,
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
LocalWalletClient,
ExtKeychain,
>,
>,
>,
grin_wallet_libwallet::WalletHandle<
'static,
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
LocalWalletClient,
ExtKeychain,
>,
Option<SecretKey>,
) {
+2 -2
View File
@@ -53,7 +53,7 @@ fn file_exchange_test_impl(test_dir: &'static str, use_bin: bool) -> Result<(),
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -65,7 +65,7 @@ fn file_exchange_test_impl(test_dir: &'static str, use_bin: bool) -> Result<(),
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+2 -2
View File
@@ -49,7 +49,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
true,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -61,7 +61,7 @@ fn invoice_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
true,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+2 -2
View File
@@ -49,7 +49,7 @@ fn late_lock_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -61,7 +61,7 @@ fn late_lock_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+4 -4
View File
@@ -53,7 +53,7 @@ fn mwixnet_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
true,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
@@ -135,11 +135,11 @@ fn mwixnet_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
let server_pubkey_str_2 = "0c9414341f2140ed34a5a12a6479bf5a6404820d001ab81d9d3e8cc38f049b4e";
let server_pubkey_str_3 = "b58ece97d60e71bb7e53218400b0d67bfe6a3cb7d3b4a67a44f8fb7c525cbca5";
let server_key_1 =
SecretKey::from_slice(&secp, &grin_util::from_hex(&server_pubkey_str_1).unwrap())?;
SecretKey::from_slice(&secp, &grin_util::from_hex(server_pubkey_str_1).unwrap())?;
let server_key_2 =
SecretKey::from_slice(&secp, &grin_util::from_hex(&server_pubkey_str_2).unwrap())?;
SecretKey::from_slice(&secp, &grin_util::from_hex(server_pubkey_str_2).unwrap())?;
let server_key_3 =
SecretKey::from_slice(&secp, &grin_util::from_hex(&server_pubkey_str_3).unwrap())?;
SecretKey::from_slice(&secp, &grin_util::from_hex(server_pubkey_str_3).unwrap())?;
let params = MixnetReqCreationParams {
server_keys: vec![server_key_1, server_key_2, server_key_3],
fee_per_hop: 50_000_000,
+2 -2
View File
@@ -48,7 +48,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
@@ -62,7 +62,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+2 -2
View File
@@ -48,7 +48,7 @@ fn payment_proofs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
@@ -62,7 +62,7 @@ fn payment_proofs_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+2 -2
View File
@@ -52,7 +52,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -64,7 +64,7 @@ fn file_repost_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+13 -15
View File
@@ -23,32 +23,25 @@ use grin_core::core::Transaction;
use grin_core::global;
use grin_keychain::ExtKeychain;
use grin_util::secp::key::SecretKey;
use grin_util::Mutex;
use grin_wallet_api::Owner;
use grin_wallet_impls::test_framework::*;
use grin_wallet_impls::{DefaultLCProvider, PathToSlate, SlatePutter};
use grin_wallet_libwallet as libwallet;
use grin_wallet_libwallet::api_impl::types::InitTxArgs;
use grin_wallet_libwallet::WalletInst;
use log::error;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
type Wallet = Arc<
Mutex<
Box<
dyn WalletInst<
'static,
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
LocalWalletClient,
ExtKeychain,
>,
>,
>,
type Wallet = grin_wallet_libwallet::WalletHandle<
'static,
DefaultLCProvider<LocalWalletClient, ExtKeychain>,
LocalWalletClient,
ExtKeychain,
>;
#[allow(clippy::type_complexity)]
fn revert(
test_dir: &'static str,
) -> Result<
@@ -189,8 +182,13 @@ fn revert(
// Build 2 blocks at same height: 1 with the tx, 1 without
let head = chain.head_header().unwrap();
let block_with =
create_block_for_wallet(&chain, head.clone(), &[tx.clone()], wallet1.clone(), mask1)?;
let block_with = create_block_for_wallet(
&chain,
head.clone(),
std::slice::from_ref(&tx),
wallet1.clone(),
mask1,
)?;
let block_without = create_block_for_wallet(&chain, head, &[], wallet1.clone(), mask1)?;
// Add block with tx to the chain
+1 -1
View File
@@ -51,7 +51,7 @@ fn self_send_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
true,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+12 -12
View File
@@ -57,7 +57,7 @@ fn output_slatepack(
if armored {
file = format!("{}.armored", file);
}
PathToSlatepack::new(file.into(), &packer, armored).put_tx(&slate, use_bin)
PathToSlatepack::new(file.into(), &packer, armored).put_tx(slate, use_bin)
}
fn slate_from_packed(
@@ -103,7 +103,7 @@ fn slatepack_exchange_test_impl(
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -115,7 +115,7 @@ fn slatepack_exchange_test_impl(
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
@@ -217,7 +217,7 @@ fn slatepack_exchange_test_impl(
}
let (mut slatepack, mut slate) =
slate_from_packed(&send_file, use_armored, (&dec_key_2).as_ref())?;
slate_from_packed(&send_file, use_armored, dec_key_2.as_ref())?;
// wallet 2 receives file, completes, sends file back
wallet::controller::foreign_single_use(
@@ -243,7 +243,7 @@ fn slatepack_exchange_test_impl(
)?;
// wallet 1 finalizes and posts
let (_, mut slate) = slate_from_packed(&receive_file, use_armored, (&dec_key_1).as_ref())?;
let (_, mut slate) = slate_from_packed(&receive_file, use_armored, dec_key_1.as_ref())?;
slate = api1.finalize_tx(mask1, &slate)?;
// Output final file for reference
output_slatepack(&slate, &final_file, use_armored, use_bin, None, vec![])?;
@@ -303,7 +303,7 @@ fn slatepack_exchange_test_impl(
selection_strategy_is_use_all: true,
..Default::default()
};
let res = slate_from_packed(&send_file, use_armored, (&dec_key_1).as_ref())?;
let res = slate_from_packed(&send_file, use_armored, dec_key_1.as_ref())?;
slatepack = res.0;
slate = res.1;
slate = api1.process_invoice_tx(mask1, &slate, args)?;
@@ -325,7 +325,7 @@ fn slatepack_exchange_test_impl(
mask2_i.clone(),
|api| {
// Wallet 2 receives the invoice transaction
let res = slate_from_packed(&receive_file, use_armored, (&dec_key_2).as_ref())?;
let res = slate_from_packed(&receive_file, use_armored, dec_key_2.as_ref())?;
slate = res.1;
slate = api.finalize_tx(&slate, false)?;
output_slatepack(&slate, &final_file, use_armored, use_bin, None, vec![])?;
@@ -378,7 +378,7 @@ fn slatepack_exchange_test_impl(
PathBuf::from(test_dir),
mask2_i.clone(),
|api| {
let res = slate_from_packed(&send_file, use_armored, (&dec_key_2).as_ref())?;
let res = slate_from_packed(&send_file, use_armored, dec_key_2.as_ref())?;
let slatepack = res.0;
slate = res.1;
slate = api.receive_tx(&slate, None, None)?;
@@ -398,7 +398,7 @@ fn slatepack_exchange_test_impl(
)?;
// wallet 1 finalizes and posts
let res = slate_from_packed(&receive_file, use_armored, (&dec_key_1).as_ref())?;
let res = slate_from_packed(&receive_file, use_armored, dec_key_1.as_ref())?;
slate = res.1;
slate = api1.finalize_tx(mask1, &slate)?;
// Output final file for reference
@@ -432,7 +432,7 @@ fn slatepack_api_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
@@ -494,7 +494,7 @@ fn slatepack_address_validation(test_dir: &'static str) -> Result<(), libwallet:
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
@@ -507,7 +507,7 @@ fn slatepack_address_validation(test_dir: &'static str) -> Result<(), libwallet:
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
let proxy_thread = thread::spawn(move || {
if let Err(e) = wallet_proxy.run() {
+11 -12
View File
@@ -56,7 +56,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
true,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
println!("Mask1: {:?}", mask1);
create_wallet_and_add!(
client2,
@@ -69,7 +69,7 @@ fn basic_transaction_api(test_dir: &'static str) -> Result<(), libwallet::Error>
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
println!("Mask2: {:?}", mask2);
// Set the wallet proxy listener running
@@ -530,7 +530,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -542,7 +542,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
@@ -592,10 +592,10 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
api1.retrieve_outputs(mask1, true, false, Some(tx.unwrap().id))?;
for m in output_mappings.clone() {
if m.output.status == OutputStatus::Locked {
locked_count = locked_count + 1;
locked_count += 1;
}
if m.output.status == OutputStatus::Unconfirmed {
unconfirmed_count = unconfirmed_count + 1;
unconfirmed_count += 1;
}
}
assert_eq!(output_mappings.len(), 3);
@@ -614,7 +614,7 @@ fn tx_rollback(test_dir: &'static str) -> Result<(), libwallet::Error> {
let (_, outputs) = api2.retrieve_outputs(mask2, true, false, Some(tx.unwrap().id))?;
for m in outputs.clone() {
if m.output.status == OutputStatus::Unconfirmed {
unconfirmed_count = unconfirmed_count + 1;
unconfirmed_count += 1;
}
}
assert_eq!(outputs.len(), 1);
@@ -697,7 +697,7 @@ fn big_amount_error(test_dir: &'static str) -> Result<(), libwallet::Error> {
true,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
println!("Mask1: {:?}", mask1);
// Set the wallet proxy listener running
@@ -762,16 +762,15 @@ fn big_amount_error(test_dir: &'static str) -> Result<(), libwallet::Error> {
match result {
Ok(_) => {}
Err(e) => match e {
libwallet::Error::BigAmountError(a, fee, num_inputs) => {
Err(e) => {
if let libwallet::Error::BigAmountError(a, fee, num_inputs) = e {
let (_, e_a, e_fee, e_num_inputs) =
api1.estimate_max_sendable(mask1, true, min_confirmations)?;
assert_eq!(e_a, a - fee);
assert_eq!(e_fee, fee);
assert_eq!(e_num_inputs, num_inputs);
}
_ => {}
},
}
}
// let logging finish
+2 -2
View File
@@ -48,7 +48,7 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
@@ -62,7 +62,7 @@ fn ttl_cutoff_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {
+81 -50
View File
@@ -50,10 +50,11 @@ fn test_wallet_tx_filtering(
assert!(!txs.is_empty());
let before_first_tx =
txs.iter().map(|tx| tx.creation_ts).min().unwrap() - Duration::from_secs(1);
let mut tx_query_args = RetrieveTxQueryArgs::default();
// Max creation time before all test transactions
tx_query_args.max_creation_timestamp = Some(before_first_tx);
let mut tx_query_args = RetrieveTxQueryArgs {
max_creation_timestamp: Some(before_first_tx),
..Default::default()
};
assert!(query(tx_query_args.clone())?.is_empty());
// Min confirmation time should not affect creation time
@@ -61,8 +62,10 @@ fn test_wallet_tx_filtering(
tx_query_args.min_confirmed_timestamp = Some(before_first_tx);
assert_eq!(query(tx_query_args)?.len(), txs.len());
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.min_id = Some(5);
let tx_query_args = RetrieveTxQueryArgs {
min_id: Some(5),
..Default::default()
};
// Min ID
let tx_results = api
@@ -72,9 +75,11 @@ fn test_wallet_tx_filtering(
assert_eq!(tx_results[tx_results.len() - 1].id, 33);
// Max ID
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.min_id = Some(5);
tx_query_args.max_id = Some(20);
let tx_query_args = RetrieveTxQueryArgs {
min_id: Some(5),
max_id: Some(20),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
@@ -82,109 +87,133 @@ fn test_wallet_tx_filtering(
assert_eq!(tx_results[tx_results.len() - 1].id, 20);
// Exclude 1 canceled
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.exclude_cancelled = Some(true);
tx_query_args.min_id = Some(5);
tx_query_args.max_id = Some(50);
let tx_query_args = RetrieveTxQueryArgs {
exclude_cancelled: Some(true),
min_id: Some(5),
max_id: Some(50),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 28);
// Exclude 1 canceled, show confirmed only
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.exclude_cancelled = Some(true);
tx_query_args.include_confirmed_only = Some(true);
tx_query_args.min_id = Some(5);
tx_query_args.max_id = Some(50);
let tx_query_args = RetrieveTxQueryArgs {
exclude_cancelled: Some(true),
include_confirmed_only: Some(true),
min_id: Some(5),
max_id: Some(50),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 14);
// show outstanding only (including canceled)
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.exclude_cancelled = Some(false);
tx_query_args.include_outstanding_only = Some(true);
tx_query_args.min_id = Some(5);
tx_query_args.max_id = Some(50);
let tx_query_args = RetrieveTxQueryArgs {
exclude_cancelled: Some(false),
include_outstanding_only: Some(true),
min_id: Some(5),
max_id: Some(50),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 15);
// outstanding only and confirmed only should give empty set
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.exclude_cancelled = Some(false);
tx_query_args.include_outstanding_only = Some(true);
tx_query_args.include_confirmed_only = Some(true);
tx_query_args.min_id = Some(5);
tx_query_args.max_id = Some(50);
let tx_query_args = RetrieveTxQueryArgs {
exclude_cancelled: Some(false),
include_outstanding_only: Some(true),
include_confirmed_only: Some(true),
min_id: Some(5),
max_id: Some(50),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 0);
// include sent only
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.include_sent_only = Some(true);
let tx_query_args = RetrieveTxQueryArgs {
include_sent_only: Some(true),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 15);
// include received only (none in this set)
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.include_received_only = Some(true);
let tx_query_args = RetrieveTxQueryArgs {
include_received_only: Some(true),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 0);
// include reverted only (none in this set)
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.include_reverted_only = Some(true);
let tx_query_args = RetrieveTxQueryArgs {
include_reverted_only: Some(true),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 0);
// include coinbase only
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.include_coinbase_only = Some(true);
let tx_query_args = RetrieveTxQueryArgs {
include_coinbase_only: Some(true),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 19);
// Amounts
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.min_amount = Some(60_000_000_000 - 59_963_300_000);
let tx_query_args = RetrieveTxQueryArgs {
min_amount: Some(60_000_000_000 - 59_963_300_000),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 27);
// amount, should see as above with coinbases excluded
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.min_amount = Some(60_000_000_000 - 59_963_300_000);
tx_query_args.max_amount = Some(60_000_000_000 - 1);
let tx_query_args = RetrieveTxQueryArgs {
min_amount: Some(60_000_000_000 - 59_963_300_000),
max_amount: Some(60_000_000_000 - 1),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 8);
// Amount - should only see coinbase (incoming)
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.min_amount = Some(60_000_000_000);
let tx_query_args = RetrieveTxQueryArgs {
min_amount: Some(60_000_000_000),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
assert_eq!(tx_results.len(), 19);
// sort order
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.sort_order = Some(libwallet::RetrieveTxQuerySortOrder::Desc);
let tx_query_args = RetrieveTxQueryArgs {
sort_order: Some(libwallet::RetrieveTxQuerySortOrder::Desc),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
@@ -193,9 +222,11 @@ fn test_wallet_tx_filtering(
assert_eq!(tx_results[tx_results.len() - 1].id, 0);
// change sort field to amount desc, should have coinbases first
let mut tx_query_args = RetrieveTxQueryArgs::default();
tx_query_args.sort_order = Some(libwallet::RetrieveTxQuerySortOrder::Desc);
tx_query_args.sort_field = Some(RetrieveTxQuerySortField::TotalAmount);
let tx_query_args = RetrieveTxQueryArgs {
sort_order: Some(libwallet::RetrieveTxQuerySortOrder::Desc),
sort_field: Some(RetrieveTxQuerySortField::TotalAmount),
..Default::default()
};
let tx_results = api
.retrieve_txs(mask, true, None, None, Some(tx_query_args))?
.1;
@@ -224,7 +255,7 @@ fn build_chain_for_tx_filtering(
true,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
debug!("Mask1: {:?}", mask1);
create_wallet_and_add!(
client2,
@@ -237,7 +268,7 @@ fn build_chain_for_tx_filtering(
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
debug!("Mask2: {:?}", mask2);
// Set the wallet proxy listener running
+2 -2
View File
@@ -49,7 +49,7 @@ fn updater_thread_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
false,
api1
);
let mask1 = (&mask1_i).as_ref();
let mask1 = mask1_i.as_ref();
create_wallet_and_add!(
client2,
wallet2,
@@ -61,7 +61,7 @@ fn updater_thread_test_impl(test_dir: &'static str) -> Result<(), libwallet::Err
false,
api2
);
let mask2 = (&mask2_i).as_ref();
let mask2 = mask2_i.as_ref();
// Set the wallet proxy listener running
thread::spawn(move || {