Skip to content

Commit

Permalink
Rename ExpectedPaymentResult -> TestResult
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Jun 30, 2022
1 parent 319ad1b commit a3cff9b
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions lightning-invoice/src/payment.rs
Expand Up @@ -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();
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -1487,13 +1487,13 @@ mod tests {
}

struct TestScorer {
expectations: Option<VecDeque<ExpectedPaymentResult>>,
expectations: Option<VecDeque<TestResult>>,
}

#[derive(Debug)]
enum ExpectedPaymentResult {
PathFailure { path: Vec<RouteHop>, short_channel_id: u64 },
PathSuccess { path: Vec<RouteHop> },
enum TestResult {
PaymentFailure { path: Vec<RouteHop>, short_channel_id: u64 },
PaymentSuccess { path: Vec<RouteHop> },
ProbeFailure { path: Vec<RouteHop>, short_channel_id: u64 },
ProbeSuccess { path: Vec<RouteHop> },
}
Expand All @@ -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
}
Expand All @@ -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::<Vec<_>>()[..]);
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),
Expand All @@ -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::<Vec<_>>()[..]);
},
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),
Expand All @@ -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::<Vec<_>>()[..]);
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),
Expand All @@ -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::<Vec<_>>()[..]);
},
None => panic!("Unexpected payment_path_successful call: {:?}", actual_path),
Expand Down

0 comments on commit a3cff9b

Please sign in to comment.