Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Nov 7, 2023
1 parent e33587d commit cb42440
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tools/genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pub mod genesis_reader;
pub mod genesis_registration;
pub mod github_extensions;
pub mod parse_json;
pub mod process_comm_wallet;
pub mod supply;
pub mod testnet_setup;
pub mod vm;
pub mod wizard;
pub mod process_comm_wallet;
25 changes: 15 additions & 10 deletions tools/genesis/src/process_comm_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn prepare_cw_and_receipts(
split_factor: f64,
) -> anyhow::Result<(DonorReceipts, AllCommWallets)> {
let mut dr = rebuild_donor_receipts(recovery, split_factor)?;
let mut cw = rebuild_cw_cumu_deposits(recovery,split_factor)?;
let mut cw = rebuild_cw_cumu_deposits(recovery, split_factor)?;
update_cw_with_donor(&mut cw, &mut dr, split_factor);

Ok((dr, cw))
Expand All @@ -66,7 +66,7 @@ pub fn rebuild_donor_receipts(
.iter()
.map(|&a| a.try_into().expect("could not cast LegacyAdresss"))
.collect();
// this resource should now show the split numbers
// this resource should now show the split numbers
let mut cast_receipts = ReceiptsResourceV7 {
destination: destinations_cast,
cumulative: temp_receipts.clone().cumulative,
Expand All @@ -83,9 +83,9 @@ pub fn rebuild_donor_receipts(
.iter_mut()
.map(|el| {
*el = (split_factor * (*el as f64)) as u64;
return el;
el
})
.fold(0u64, |sum, e| return sum.checked_add(*e).unwrap());
.fold(0u64, |sum, e| sum.checked_add(*e).unwrap());

// add to totals for comparison purposes
total_cumu += user_cumu;
Expand Down Expand Up @@ -172,13 +172,13 @@ pub fn update_cw_with_donor(

// populate the list of depositors to that CW
if !w.depositors.contains(donor) {
w.depositors.push(donor.clone())
w.depositors.push(*donor)
}
} else {
// does this community wallet exist
// say we can't find it in cw list
if !donors.audit_not_cw.contains(&maybe_cw) {
donors.audit_not_cw.push(maybe_cw.clone())
donors.audit_not_cw.push(maybe_cw)
}

return Some(maybe_cw);
Expand Down Expand Up @@ -242,7 +242,10 @@ fn test_receipt_recovery() {

assert!(&t.list.get(&test_addr).is_some());
dbg!(&t.total_cumu);
assert!(t.total_cumu == (split_factor * old_cumu as f64) as u64, "cumu not equal");
assert!(
t.total_cumu == (split_factor * old_cumu as f64) as u64,
"cumu not equal"
);
}

#[test]
Expand All @@ -269,8 +272,7 @@ fn test_update_cw_from_receipts() {
"receipts value not equal"
);


let recovery = parse_json::recovery_file_parse(p.clone()).unwrap();
let recovery = parse_json::recovery_file_parse(p).unwrap();

// now add the split
let split_factor = 2.0;
Expand All @@ -282,7 +284,10 @@ fn test_update_cw_from_receipts() {
.get(&AccountAddress::from_hex_literal("0x7209c13e1253ad8fb2d96a30552052aa").unwrap())
.unwrap();

assert!(v.cumulative_value == (original_value as f64 * split_factor) as u64, "cumu value not equal");
assert!(
v.cumulative_value == (original_value as f64 * split_factor) as u64,
"cumu value not equal"
);

// assert!(
// v.audit_deposits_with_receipts == 116726512,
Expand Down
1 change: 0 additions & 1 deletion types/src/legacy_types/legacy_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,5 @@ mod tests {
let parsed = AccountAddress::from_hex_literal(&old_str).unwrap();
let p: AccountAddress = address.try_into().unwrap();
assert!(&parsed == &p, "not equal");

Check failure on line 405 in types/src/legacy_types/legacy_address.rs

View workflow job for this annotation

GitHub Actions / clippy

needlessly taken reference of both operands

}
}
4 changes: 2 additions & 2 deletions types/src/legacy_types/receipts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! fullnode counter for system address
use anyhow::Result;
use super::legacy_address::LegacyAddress;
use anyhow::Result;
use move_core_types::{ident_str, identifier::IdentStr, move_resource::MoveStructType};
use serde::{Deserialize, Serialize};

Expand All @@ -28,4 +28,4 @@ impl ReceiptsResource {
pub fn try_from_bytes(bytes: &[u8]) -> Result<Self> {
bcs::from_bytes(bytes).map_err(Into::into)
}
}
}

0 comments on commit cb42440

Please sign in to comment.