Skip to content

Commit

Permalink
GH-600: Revert scanner changes
Browse files Browse the repository at this point in the history
  • Loading branch information
masqrauder committed Sep 23, 2023
1 parent dd74d77 commit 673763c
Showing 1 changed file with 2 additions and 40 deletions.
42 changes: 2 additions & 40 deletions node/src/accountant/scanners/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,13 @@ where
pub struct ScannerCommon {
initiated_at_opt: Option<SystemTime>,
pub payment_thresholds: Rc<PaymentThresholds>,
timeout: Duration,
}

impl ScannerCommon {
fn new(payment_thresholds: Rc<PaymentThresholds>) -> Self {
Self {
initiated_at_opt: None,
payment_thresholds,
timeout: Duration::from_secs(30u64),
}
}

Expand Down Expand Up @@ -732,15 +730,8 @@ impl Scanner<RetrieveTransactions, ReceivedPayments> for ReceivableScanner {
response_skeleton_opt: Option<ResponseSkeleton>,
logger: &Logger,
) -> Result<RetrieveTransactions, BeginScanError> {
if let Some(scan_started_at) = self.scan_started_at() {
return match scan_started_at.elapsed() {
Ok(elapsed) if elapsed.as_secs() >= self.common.timeout.as_secs() => {
info!(logger, "Receivables scan timed out");
self.mark_as_ended(logger);
Err(BeginScanError::NothingToProcess)
}
_ => Err(BeginScanError::ScanAlreadyRunning(scan_started_at)),
};
if let Some(timestamp) = self.scan_started_at() {
return Err(BeginScanError::ScanAlreadyRunning(timestamp));
}
self.mark_as_started(timestamp);
info!(
Expand Down Expand Up @@ -2716,35 +2707,6 @@ mod tests {
assert_eq!(result, Err(BeginScanError::ScanAlreadyRunning(now)));
}

#[test]
fn receivable_scanner_ends_scan_after_timeout_elapses() {
init_test_logging();
let test_name = "receivable_scanner_ends_scan_after_timeout_elapses";
let scan_start_time = SystemTime::now().sub(Duration::from_secs(60u64));
let receivable_dao = ReceivableDaoMock::new()
.new_delinquencies_result(vec![])
.paid_delinquencies_result(vec![]);
let earning_wallet = make_wallet("earning");
let mut receivable_scanner = ReceivableScannerBuilder::new()
.receivable_dao(receivable_dao)
.earning_wallet(earning_wallet.clone())
.build();
let _ = receivable_scanner.begin_scan(scan_start_time, None, &Logger::new(test_name));
receivable_scanner.mark_as_started(scan_start_time); // pretend we started the scan a minute ago

let result =
receivable_scanner.begin_scan(SystemTime::now(), None, &Logger::new(test_name));

let is_scan_running = receivable_scanner.scan_started_at().is_some();
assert_eq!(is_scan_running, false);
assert_eq!(result, Err(BeginScanError::NothingToProcess));
TestLogHandler::new().exists_log_containing(&format!(
"INFO: {test_name}: Scanning for receivables to {earning_wallet}"
));
TestLogHandler::new()
.exists_log_containing(&format!("INFO: {test_name}: Receivables scan timed out"));
}

#[test]
fn receivable_scanner_scans_for_delinquencies() {
init_test_logging();
Expand Down

0 comments on commit 673763c

Please sign in to comment.