-
Notifications
You must be signed in to change notification settings - Fork 32
GH-598: second QA fix - first review #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: GH-598-first-QA-fix-second-rev
Are you sure you want to change the base?
Changes from all commits
0637769
0e53e04
bc95399
b9f6c64
1acd12d
f77eaa9
738ead8
af1a075
268eeba
77a1d1c
25af8cb
a151e96
a71cd1f
42eebcc
e82da77
858adfa
dd3bd6b
6dab798
1ba4317
06dd374
422038f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,7 +122,10 @@ impl Scanners { | |
| }); | ||
| } | ||
|
|
||
| Self::start_correct_payable_scanner::<ScanForNewPayables>( | ||
| <(dyn MultistageDualPayableScanner) as StartableScanner< | ||
| ScanForNewPayables, | ||
| InitialTemplatesMessage, | ||
| >>::start_scan( | ||
| &mut *self.payable, | ||
| wallet, | ||
| timestamp, | ||
|
|
@@ -150,7 +153,10 @@ impl Scanners { | |
| ) | ||
| } | ||
|
|
||
| Self::start_correct_payable_scanner::<ScanForRetryPayables>( | ||
| <(dyn MultistageDualPayableScanner) as StartableScanner< | ||
| ScanForRetryPayables, | ||
| InitialTemplatesMessage, | ||
| >>::start_scan( | ||
| &mut *self.payable, | ||
| wallet, | ||
| timestamp, | ||
|
|
@@ -168,10 +174,14 @@ impl Scanners { | |
| automatic_scans_enabled: bool, | ||
| ) -> Result<RequestTransactionReceipts, StartScanError> { | ||
| let triggered_manually = response_skeleton_opt.is_some(); | ||
| self.check_general_conditions_for_pending_payable_scan( | ||
| triggered_manually, | ||
| automatic_scans_enabled, | ||
| )?; | ||
| if triggered_manually && automatic_scans_enabled { | ||
| return Err(StartScanError::ManualTriggerError( | ||
| ManulTriggerError::AutomaticScanConflict, | ||
| )); | ||
| } | ||
|
|
||
| self.check_pending_payable_existence(triggered_manually)?; | ||
|
|
||
| match ( | ||
| self.pending_payable.scan_started_at(), | ||
| self.payable.scan_started_at(), | ||
|
|
@@ -256,6 +266,7 @@ impl Scanners { | |
| } | ||
|
|
||
| pub fn acknowledge_scan_error(&mut self, error: &ScanError, logger: &Logger) { | ||
| debug!(logger, "Acknowledging a scan that couldn't finish"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Insufficient logging detail in scan error handler (Bugbot Rules)The debug log in |
||
| match error.scan_type { | ||
| DetailedScanType::NewPayables | DetailedScanType::RetryPayables => { | ||
| self.payable.mark_as_ended(logger) | ||
|
|
@@ -298,41 +309,14 @@ impl Scanners { | |
| self.initial_pending_payable_scan = false | ||
| } | ||
|
|
||
| // This is a helper function reducing a boilerplate of complex trait resolving where | ||
| // the compiler requires to specify which trigger message distinguishes the scan to run. | ||
| // The payable scanner offers two modes through doubled implementations of StartableScanner | ||
| // which uses the trigger message type as the only distinction between them. | ||
| fn start_correct_payable_scanner<'a, TriggerMessage>( | ||
| scanner: &'a mut (dyn MultistageDualPayableScanner + 'a), | ||
| wallet: &Wallet, | ||
| timestamp: SystemTime, | ||
| response_skeleton_opt: Option<ResponseSkeleton>, | ||
| logger: &Logger, | ||
| ) -> Result<InitialTemplatesMessage, StartScanError> | ||
| where | ||
| TriggerMessage: Message, | ||
| (dyn MultistageDualPayableScanner + 'a): | ||
| StartableScanner<TriggerMessage, InitialTemplatesMessage>, | ||
| { | ||
| <(dyn MultistageDualPayableScanner + 'a) as StartableScanner< | ||
| TriggerMessage, | ||
| InitialTemplatesMessage, | ||
| >>::start_scan(scanner, wallet, timestamp, response_skeleton_opt, logger) | ||
| } | ||
|
|
||
| fn check_general_conditions_for_pending_payable_scan( | ||
| fn check_pending_payable_existence( | ||
| &mut self, | ||
| triggered_manually: bool, | ||
| automatic_scans_enabled: bool, | ||
| ) -> Result<(), StartScanError> { | ||
| if triggered_manually && automatic_scans_enabled { | ||
| return Err(StartScanError::ManualTriggerError( | ||
| ManulTriggerError::AutomaticScanConflict, | ||
| )); | ||
| } | ||
| if self.initial_pending_payable_scan { | ||
| return Ok(()); | ||
| } | ||
|
|
||
| if triggered_manually && !self.aware_of_unresolved_pending_payable { | ||
| return Err(StartScanError::ManualTriggerError( | ||
| ManulTriggerError::UnnecessaryRequest { | ||
|
|
@@ -794,11 +778,11 @@ mod tests { | |
| false | ||
| ); | ||
| let dumped_records = pending_payable_scanner | ||
| .yet_unproven_failed_payables | ||
| .suspected_failed_payables | ||
| .dump_cache(); | ||
| assert!( | ||
| dumped_records.is_empty(), | ||
| "There should be no yet unproven failures but found {:?}.", | ||
| "There should be no suspected failures but found {:?}.", | ||
| dumped_records | ||
| ); | ||
| assert_eq!( | ||
|
|
@@ -1199,7 +1183,9 @@ mod tests { | |
| ); | ||
| TestLogHandler::new().assert_logs_match_in_order(vec![ | ||
| &format!("INFO: {test_name}: Scanning for pending payable"), | ||
| &format!("DEBUG: {test_name}: Found 1 pending payables and 1 unfinalized failures to process"), | ||
| &format!( | ||
| "DEBUG: {test_name}: Found 1 pending payables and 1 suspected failures to process" | ||
| ), | ||
| ]) | ||
| } | ||
|
|
||
|
|
@@ -1340,8 +1326,8 @@ mod tests { | |
|
|
||
| #[test] | ||
| #[should_panic( | ||
| expected = "internal error: entered unreachable code: Automatic pending payable \ | ||
| scan should never start if there are no pending payables to process." | ||
| expected = "internal error: entered unreachable code: Automatic pending payable scan should \ | ||
| never start if there are no pending payables to process." | ||
| )] | ||
| fn pending_payable_scanner_bumps_into_zero_pending_payable_awareness_in_the_automatic_mode() { | ||
| let consuming_wallet = make_paying_wallet(b"consuming"); | ||
|
|
@@ -1360,11 +1346,12 @@ mod tests { | |
| } | ||
|
|
||
| #[test] | ||
| fn check_general_conditions_for_pending_payable_scan_if_it_is_initial_pending_payable_scan() { | ||
| fn check_pending_payable_existence_for_initial_pending_payable_scan_and_zero_awareness() { | ||
| let mut subject = make_dull_subject(); | ||
| subject.aware_of_unresolved_pending_payable = false; | ||
| subject.initial_pending_payable_scan = true; | ||
|
|
||
| let result = subject.check_general_conditions_for_pending_payable_scan(false, true); | ||
| let result = subject.check_pending_payable_existence(false); | ||
|
|
||
| assert_eq!(result, Ok(())); | ||
| assert_eq!(subject.initial_pending_payable_scan, true); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps you could add more details to this log, using the contents of the error.