From 79241f263d6db4771778fbf5f5b391a93357fa3e Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Thu, 30 Jun 2022 15:33:09 +0200 Subject: [PATCH] Rename `ExpectedPaymentResult` -> `TestResult` --- lightning-invoice/src/payment.rs | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lightning-invoice/src/payment.rs b/lightning-invoice/src/payment.rs index f46888e4992..0aa5358d569 100644 --- a/lightning-invoice/src/payment.rs +++ b/lightning-invoice/src/payment.rs @@ -1353,7 +1353,7 @@ mod tests { .expect_send(Amount::ForInvoice(final_value_msat)) .expect_send(Amount::OnRetry(final_value_msat / 2)); let router = TestRouter {}; - let scorer = RefCell::new(TestScorer::new().expect(ExpectedPaymentResult::PathFailure { + let scorer = RefCell::new(TestScorer::new().expect(TestResult::PaymentFailure { path: path.clone(), short_channel_id: path[0].short_channel_id, })); let logger = TestLogger::new(); @@ -1389,8 +1389,8 @@ mod tests { let payer = TestPayer::new().expect_send(Amount::ForInvoice(final_value_msat)); let router = TestRouter {}; let scorer = RefCell::new(TestScorer::new() - .expect(ExpectedPaymentResult::PathSuccess { path: route.paths[0].clone() }) - .expect(ExpectedPaymentResult::PathSuccess { path: route.paths[1].clone() }) + .expect(TestResult::PaymentSuccess { path: route.paths[0].clone() }) + .expect(TestResult::PaymentSuccess { path: route.paths[1].clone() }) ); let logger = TestLogger::new(); let invoice_payer = @@ -1487,13 +1487,13 @@ mod tests { } struct TestScorer { - expectations: Option>, + expectations: Option>, } #[derive(Debug)] - enum ExpectedPaymentResult { - PathFailure { path: Vec, short_channel_id: u64 }, - PathSuccess { path: Vec }, + enum TestResult { + PaymentFailure { path: Vec, short_channel_id: u64 }, + PaymentSuccess { path: Vec }, ProbeFailure { path: Vec, short_channel_id: u64 }, ProbeSuccess { path: Vec }, } @@ -1505,7 +1505,7 @@ mod tests { } } - fn expect(mut self, expectation: ExpectedPaymentResult) -> Self { + fn expect(mut self, expectation: TestResult) -> Self { self.expectations.get_or_insert_with(|| VecDeque::new()).push_back(expectation); self } @@ -1524,17 +1524,17 @@ mod tests { fn payment_path_failed(&mut self, actual_path: &[&RouteHop], actual_short_channel_id: u64) { if let Some(expectations) = &mut self.expectations { match expectations.pop_front() { - Some(ExpectedPaymentResult::PathFailure { path, short_channel_id }) => { + Some(TestResult::PaymentFailure { path, short_channel_id }) => { assert_eq!(actual_path, &path.iter().collect::>()[..]); assert_eq!(actual_short_channel_id, short_channel_id); }, - Some(ExpectedPaymentResult::PathSuccess { path }) => { + Some(TestResult::PaymentSuccess { path }) => { panic!("Unexpected successful payment path: {:?}", path) }, - Some(ExpectedPaymentResult::ProbeFailure { path, .. }) => { + Some(TestResult::ProbeFailure { path, .. }) => { panic!("Unexpected failed payment probe: {:?}", path) }, - Some(ExpectedPaymentResult::ProbeSuccess { path }) => { + Some(TestResult::ProbeSuccess { path }) => { panic!("Unexpected successful payment probe: {:?}", path) }, None => panic!("Unexpected payment_path_failed call: {:?}", actual_path), @@ -1545,16 +1545,16 @@ mod tests { fn payment_path_successful(&mut self, actual_path: &[&RouteHop]) { if let Some(expectations) = &mut self.expectations { match expectations.pop_front() { - Some(ExpectedPaymentResult::PathFailure { path, .. }) => { + Some(TestResult::PaymentFailure { path, .. }) => { panic!("Unexpected payment path failure: {:?}", path) }, - Some(ExpectedPaymentResult::PathSuccess { path }) => { + Some(TestResult::PaymentSuccess { path }) => { assert_eq!(actual_path, &path.iter().collect::>()[..]); }, - Some(ExpectedPaymentResult::ProbeFailure { path, .. }) => { + Some(TestResult::ProbeFailure { path, .. }) => { panic!("Unexpected failed payment probe: {:?}", path) }, - Some(ExpectedPaymentResult::ProbeSuccess { path }) => { + Some(TestResult::ProbeSuccess { path }) => { panic!("Unexpected successful payment probe: {:?}", path) }, None => panic!("Unexpected payment_path_successful call: {:?}", actual_path), @@ -1565,17 +1565,17 @@ mod tests { fn probe_failed(&mut self, actual_path: &[&RouteHop], actual_short_channel_id: u64) { if let Some(expectations) = &mut self.expectations { match expectations.pop_front() { - Some(ExpectedPaymentResult::PathFailure { path, .. }) => { + Some(TestResult::PaymentFailure { path, .. }) => { panic!("Unexpected failed payment path: {:?}", path) }, - Some(ExpectedPaymentResult::PathSuccess { path }) => { + Some(TestResult::PaymentSuccess { path }) => { panic!("Unexpected successful payment path: {:?}", path) }, - Some(ExpectedPaymentResult::ProbeFailure { path, short_channel_id }) => { + Some(TestResult::ProbeFailure { path, short_channel_id }) => { assert_eq!(actual_path, &path.iter().collect::>()[..]); assert_eq!(actual_short_channel_id, short_channel_id); }, - Some(ExpectedPaymentResult::ProbeSuccess { path }) => { + Some(TestResult::ProbeSuccess { path }) => { panic!("Unexpected successful payment probe: {:?}", path) }, None => panic!("Unexpected payment_path_failed call: {:?}", actual_path), @@ -1585,16 +1585,16 @@ mod tests { fn probe_successful(&mut self, actual_path: &[&RouteHop]) { if let Some(expectations) = &mut self.expectations { match expectations.pop_front() { - Some(ExpectedPaymentResult::PathFailure { path, .. }) => { + Some(TestResult::PaymentFailure { path, .. }) => { panic!("Unexpected payment path failure: {:?}", path) }, - Some(ExpectedPaymentResult::PathSuccess { path }) => { + Some(TestResult::PaymentSuccess { path }) => { panic!("Unexpected successful payment path: {:?}", path) }, - Some(ExpectedPaymentResult::ProbeFailure { path, .. }) => { + Some(TestResult::ProbeFailure { path, .. }) => { panic!("Unexpected failed payment probe: {:?}", path) }, - Some(ExpectedPaymentResult::ProbeSuccess { path }) => { + Some(TestResult::ProbeSuccess { path }) => { assert_eq!(actual_path, &path.iter().collect::>()[..]); }, None => panic!("Unexpected payment_path_successful call: {:?}", actual_path),