mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-07-31 20:31:24 +00:00
fix tests
This commit is contained in:
@@ -271,6 +271,7 @@ impl LightWallet {
|
|||||||
|
|
||||||
// Read the spending keys
|
// Read the spending keys
|
||||||
let extsks = Vector::read(&mut reader, |r| ExtendedSpendingKey::read(r))?;
|
let extsks = Vector::read(&mut reader, |r| ExtendedSpendingKey::read(r))?;
|
||||||
|
println!("reading version {}", version);
|
||||||
|
|
||||||
let extfvks = if version >= 4 {
|
let extfvks = if version >= 4 {
|
||||||
// Read the viewing keys
|
// Read the viewing keys
|
||||||
@@ -362,7 +363,7 @@ impl LightWallet {
|
|||||||
writer.write_all(&self.seed)?;
|
writer.write_all(&self.seed)?;
|
||||||
|
|
||||||
// Flush after writing the seed, so in case of a disaster, we can still recover the seed.
|
// Flush after writing the seed, so in case of a disaster, we can still recover the seed.
|
||||||
writer.flush()?;
|
//writer.flush()?;
|
||||||
|
|
||||||
// Write all the spending keys
|
// Write all the spending keys
|
||||||
Vector::write(&mut writer, &self.extsks.read().unwrap(),
|
Vector::write(&mut writer, &self.extsks.read().unwrap(),
|
||||||
@@ -1426,17 +1427,6 @@ impl LightWallet {
|
|||||||
return Err("Need at least one destination address".to_string());
|
return Err("Need at least one destination address".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for duplicates in the to list
|
|
||||||
if tos.len() > 1 {
|
|
||||||
let mut to_addresses = tos.iter().map(|t| t.0.to_string()).collect::<Vec<_>>();
|
|
||||||
to_addresses.sort();
|
|
||||||
for i in 0..to_addresses.len()-1 {
|
|
||||||
if to_addresses[i] == to_addresses[i+1] {
|
|
||||||
return Err(format!("To address {} is duplicated", to_addresses[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let total_value = tos.iter().map(|to| to.1).sum::<u64>();
|
let total_value = tos.iter().map(|to| to.1).sum::<u64>();
|
||||||
println!(
|
println!(
|
||||||
"0: Creating transaction sending {} ztoshis to {} addresses",
|
"0: Creating transaction sending {} ztoshis to {} addresses",
|
||||||
|
@@ -1518,11 +1518,11 @@ fn test_bad_send() {
|
|||||||
vec![(&ext_taddr, AMOUNT1 + 10, None)]);
|
vec![(&ext_taddr, AMOUNT1 + 10, None)]);
|
||||||
assert!(raw_tx.err().unwrap().contains("Insufficient verified funds"));
|
assert!(raw_tx.err().unwrap().contains("Insufficient verified funds"));
|
||||||
|
|
||||||
// Duplicated addresses
|
// Duplicated addresses are fine
|
||||||
let raw_tx = wallet.send_to_address(branch_id, &ss, &so,
|
let raw_tx = wallet.send_to_address(branch_id, &ss, &so,
|
||||||
vec![(&ext_taddr, AMOUNT1 + 10, None),
|
vec![(&ext_taddr, AMOUNT1 + 10, None),
|
||||||
(&ext_taddr, AMOUNT1 + 10, None)]);
|
(&ext_taddr, AMOUNT1 + 10, None)]);
|
||||||
assert!(raw_tx.err().unwrap().contains("duplicate"));
|
assert!(raw_tx.is_ok());
|
||||||
|
|
||||||
// No addresses
|
// No addresses
|
||||||
let raw_tx = wallet.send_to_address(branch_id, &ss, &so, vec![]);
|
let raw_tx = wallet.send_to_address(branch_id, &ss, &so, vec![]);
|
||||||
|
Reference in New Issue
Block a user