Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
326b79b
GH-642: interim commit
bertllll Jun 24, 2025
b73925a
GH-642: interim commit
Jul 1, 2025
0071b8e
GH-642: interim commit
Jul 2, 2025
da59853
GH-642: big initial messy reconstruction continuing...
Jul 6, 2025
9276aad
GH-642: big initial messy reconstruction... just realized I may've fo…
Jul 7, 2025
a24cbc1
GH-642: big initial messy reconstruction... finished other card merge…
Jul 9, 2025
fbbfaa9
GH-642: merged in Utkarshe's help (Quick PR to unload me from too man…
Jul 9, 2025
ce84ef4
GH-642: tests compiling...failing lots of them
Jul 10, 2025
2b3cc52
GH-642: fn confirm_transactions has been reimplemented
Jul 12, 2025
1b3abb5
GH-642: fn handle_failed_transactions has been reimplemented
Jul 12, 2025
1573bde
GH-642: fixed mainly internal, but smaller functions in the pending p…
Jul 14, 2025
c42b6d0
GH-642: progressed quite greatelly; fixed many tests; took action aga…
Jul 14, 2025
6d17bf6
GH-642: another bunch fixed...down to 24
Jul 15, 2025
c299f91
GH-642: another bunch fixed...down to 10
Jul 15, 2025
7e224e4
GH-642: the base of this card is done
Jul 16, 2025
4515d82
GH-642: lots of fixes in names
Jul 17, 2025
6ef6f0f
GH-642: filling cache with failed txs to recheck at startup
Jul 21, 2025
874d1c8
GH-642: merged in a contribution from Utkarsh
Jul 21, 2025
4aa18d4
GH-642: rpc failers during receipt checks can be handled now
Jul 22, 2025
9e2fc52
GH-642: interim commit
Jul 22, 2025
0d10884
GH-642: first I need to finish the impl of the db system of tx status…
Jul 23, 2025
9e07df1
GH-642: finally compiling after merge from GH-598; the need for new b…
Jul 27, 2025
21368d7
GH-642: pending payable scanner machinery has been given the true ske…
Jul 29, 2025
c1127c5
GH-642: before creating a new whole folder for scanner utils
Jul 30, 2025
1554a88
GH-642: merged file reorganization in scanners
Jul 30, 2025
e1506ea
GH-642: interim commit
Jul 31, 2025
e8e2428
GH-642: preparing tests before writing the guts of the core fns
Aug 1, 2025
b2f4c77
GH-642: integration of the caches...100% at start_scan, 90% finish_scan
Aug 4, 2025
2eb5ea4
GH-642: another big portion of work in interpreting the receipts
Aug 5, 2025
e16c21a
GH-642: finishing tests for the receipt interpretation but I should r…
Aug 6, 2025
a0e9df7
GH-642: mod structure changed, new file for TxReceiptInterpreter
Aug 7, 2025
d8d6ef1
GH-642: fixed two unreliable tests
Aug 7, 2025
7c51118
GH-642: interim commit
Aug 7, 2025
a0454aa
GH-642: worked away on the implementation of handling failed txs
Aug 9, 2025
d984e40
GH-642: more todos!() gone
Aug 9, 2025
9750756
GH-642: processing failures is done; next tx confiramtions
Aug 10, 2025
f245a51
GH-642: tx reclaim implemented
Aug 10, 2025
a01a1b5
GH-642: finished the brain functions in PPS
Aug 11, 2025
eddcec4
GH-642: ValidationStatus extension - huge chunk of work; still some f…
Aug 13, 2025
3f102e7
GH-642: interim commit (some of the Validation error stuff will have …
Aug 15, 2025
cc70df9
GH-683: savepoint
Aug 15, 2025
b8187ef
GH-683: interim commit
Aug 17, 2025
527fe25
GH-683: mostly done
Aug 17, 2025
47353a6
GH-683: renamed error
Aug 18, 2025
5055e54
GH-683: additional fix to renaming
Aug 18, 2025
7a33d30
GH-683: finished
Aug 18, 2025
609b7f1
GH-642: merged GH-683 in
Aug 18, 2025
b4d3a36
GH-642: finished
Aug 18, 2025
97edae5
GH-683: fixed for a review
Aug 20, 2025
dca1552
GH-683: fixed screwed string replacement
Aug 20, 2025
819bdd9
GH-683: finished fixing it
Aug 21, 2025
a9505af
GH-683: another fix...BlockchainError
Aug 21, 2025
2f85e80
GH-642: merged GH-598 in
Aug 22, 2025
bff1382
GH-642: added unreachable!
Aug 22, 2025
9a13c56
GH-642: before bigger issue addressing
Sep 5, 2025
b8bbee7
GH-642: got rid of the BlockchainFailure::Unrecognized layer
Sep 5, 2025
9498689
GH-642: savepoint
Sep 5, 2025
08eb7fb
GH-642: hashmap for receipt status result deployed
Sep 6, 2025
4f056ef
GH-642: finally solid... as much as under this card, tests fixed
Sep 8, 2025
e6ed5d5
GH-598-json-hotfix: interim commit
Sep 8, 2025
7395b9c
GH-642: bigger messy merge with error fixes and some other tretment f…
Sep 9, 2025
dbee7b4
GH-642: dragging the failing tests down to bare minimum
Sep 10, 2025
73dc080
GH-642: interim commit
Sep 10, 2025
5548e53
GH-642: before fixing the todo!() left over
Sep 10, 2025
40351e9
GH-642: finished
Sep 11, 2025
41ba5ab
GH-642: cosmetics
Sep 11, 2025
4ab5b6b
GH-642: grrr - cosmetics - forgot e
Sep 11, 2025
bca75ae
GH-642: review 2 addressed
Sep 12, 2025
24ec9d8
GH-642: added the cache clean-up on getting a scan error
Sep 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 119 additions & 3 deletions masq_lib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,25 @@ macro_rules! test_only_use {
}
}

#[macro_export(local_inner_macros)]
macro_rules! btreemap {
() => {
::std::collections::BTreeMap::new()
};
($($key:expr => $val:expr,)+) => {
btreemap!($($key => $val),+)
};
($($key:expr => $value:expr),+) => {
{
let mut _btm = ::std::collections::BTreeMap::new();
$(
let _ = _btm.insert($key, $value);
)*
_btm
}
};
}

#[macro_export(local_inner_macros)]
macro_rules! hashmap {
() => {
Expand All @@ -482,10 +501,30 @@ macro_rules! hashmap {
};
}

#[macro_export(local_inner_macros)]
macro_rules! hashset {
() => {
::std::collections::HashSet::new()
};
($($val:expr,)+) => {
hashset!($($val),+)
};
($($value:expr),+) => {
{
let mut _hs = ::std::collections::HashSet::new();
$(
let _ = _hs.insert($value);
)*
_hs
}
};
}

#[cfg(test)]
mod tests {
use super::*;
use std::collections::HashMap;
use itertools::Itertools;
use std::collections::{BTreeMap, HashMap, HashSet};
use std::env::current_dir;
use std::fmt::Write;
use std::fs::{create_dir_all, File, OpenOptions};
Expand Down Expand Up @@ -814,7 +853,8 @@ mod tests {
let hashmap_with_one_element = hashmap!(1 => 2);
let hashmap_with_multiple_elements = hashmap!(1 => 2, 10 => 20, 12 => 42);
let hashmap_with_trailing_comma = hashmap!(1 => 2, 10 => 20,);
let hashmap_of_string = hashmap!("key" => "val");
let hashmap_of_string = hashmap!("key_1" => "val_a", "key_2" => "val_b");
let hashmap_with_duplicate = hashmap!(1 => 2, 1 => 2);

let expected_empty_hashmap: HashMap<i32, i32> = HashMap::new();
let mut expected_hashmap_with_one_element = HashMap::new();
Expand All @@ -827,7 +867,10 @@ mod tests {
expected_hashmap_with_trailing_comma.insert(1, 2);
expected_hashmap_with_trailing_comma.insert(10, 20);
let mut expected_hashmap_of_string = HashMap::new();
expected_hashmap_of_string.insert("key", "val");
expected_hashmap_of_string.insert("key_1", "val_a");
expected_hashmap_of_string.insert("key_2", "val_b");
let mut expected_hashmap_with_duplicate = HashMap::new();
expected_hashmap_with_duplicate.insert(1, 2);
assert_eq!(empty_hashmap, expected_empty_hashmap);
assert_eq!(hashmap_with_one_element, expected_hashmap_with_one_element);
assert_eq!(
Expand All @@ -839,5 +882,78 @@ mod tests {
expected_hashmap_with_trailing_comma
);
assert_eq!(hashmap_of_string, expected_hashmap_of_string);
assert_eq!(hashmap_with_duplicate, expected_hashmap_with_duplicate);
}

#[test]
fn btreemap_macro_works() {
let empty_btm: BTreeMap<String, i32> = btreemap!();
let btm_with_one_element = btreemap!("ABC" => "234");
let btm_with_multiple_elements = btreemap!("Bobble" => 2, "Hurrah" => 20, "Boom" => 42);
let btm_with_trailing_comma = btreemap!(12 => 1, 22 =>2,);
let btm_with_duplicate = btreemap!("A"=>123, "A"=>222);

let expected_empty_btm: BTreeMap<String, i32> = BTreeMap::new();
let mut expected_btm_with_one_element = BTreeMap::new();
expected_btm_with_one_element.insert("ABC", "234");
let mut expected_btm_with_multiple_elements = BTreeMap::new();
expected_btm_with_multiple_elements.insert("Bobble", 2);
expected_btm_with_multiple_elements.insert("Hurrah", 20);
expected_btm_with_multiple_elements.insert("Boom", 42);
let mut expected_btm_with_trailing_comma = BTreeMap::new();
expected_btm_with_trailing_comma.insert(12, 1);
expected_btm_with_trailing_comma.insert(22, 2);
let mut expected_btm_with_duplicate = BTreeMap::new();
expected_btm_with_duplicate.insert("A", 222);
assert_eq!(empty_btm, expected_empty_btm);
assert_eq!(btm_with_one_element, expected_btm_with_one_element);
assert_eq!(
btm_with_multiple_elements,
expected_btm_with_multiple_elements
);
assert_eq!(
btm_with_multiple_elements.into_iter().collect_vec(),
vec![("Bobble", 2), ("Boom", 42), ("Hurrah", 20)]
);
assert_eq!(btm_with_trailing_comma, expected_btm_with_trailing_comma);
assert_eq!(btm_with_duplicate, expected_btm_with_duplicate);
}

#[test]
fn hashset_macro_works() {
let empty_hashset: HashSet<i32> = hashset!();
let hashset_with_one_element = hashset!(2);
let hashset_with_multiple_elements = hashset!(2, 20, 42);
let hashset_with_trailing_comma = hashset!(2, 20,);
let hashset_of_string = hashset!("val_a", "val_b");
let hashset_with_duplicate = hashset!(2, 2);

let expected_empty_hashset: HashSet<i32> = HashSet::new();
let mut expected_hashset_with_one_element = HashSet::new();
expected_hashset_with_one_element.insert(2);
let mut expected_hashset_with_multiple_elements = HashSet::new();
expected_hashset_with_multiple_elements.insert(2);
expected_hashset_with_multiple_elements.insert(20);
expected_hashset_with_multiple_elements.insert(42);
let mut expected_hashset_with_trailing_comma = HashSet::new();
expected_hashset_with_trailing_comma.insert(2);
expected_hashset_with_trailing_comma.insert(20);
let mut expected_hashset_of_string = HashSet::new();
expected_hashset_of_string.insert("val_a");
expected_hashset_of_string.insert("val_b");
let mut expected_hashset_with_duplicate = HashSet::new();
expected_hashset_with_duplicate.insert(2);
assert_eq!(empty_hashset, expected_empty_hashset);
assert_eq!(hashset_with_one_element, expected_hashset_with_one_element);
assert_eq!(
hashset_with_multiple_elements,
expected_hashset_with_multiple_elements
);
assert_eq!(
hashset_with_trailing_comma,
expected_hashset_with_trailing_comma
);
assert_eq!(hashset_of_string, expected_hashset_of_string);
assert_eq!(hashset_with_duplicate, expected_hashset_with_duplicate);
}
}
Loading