-
Notifications
You must be signed in to change notification settings - Fork 411
Improve error message. #644
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,4 @@ features = ["bitcoinconsensus"] | |
|
||
[dev-dependencies] | ||
hex = "0.3" | ||
regex = "0.1.80" | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,11 +165,11 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, targ | |
// TODO: Obviously *only* using total fee cost sucks. We should consider weighting by | ||
// uptime/success in using a node in the past. | ||
if *target == *our_node_id { | ||
return Err(LightningError{err: "Cannot generate a route to ourselves", action: ErrorAction::IgnoreError}); | ||
return Err(LightningError{err: "Cannot generate a route to ourselves".to_owned(), action: ErrorAction::IgnoreError}); | ||
} | ||
|
||
if final_value_msat > 21_000_000 * 1_0000_0000 * 1000 { | ||
return Err(LightningError{err: "Cannot generate a route of more value than all existing satoshis", action: ErrorAction::IgnoreError}); | ||
return Err(LightningError{err: "Cannot generate a route of more value than all existing satoshis".to_owned(), action: ErrorAction::IgnoreError}); | ||
} | ||
|
||
// We do a dest-to-source Dijkstra's sorting by each node's distance from the destination | ||
|
@@ -209,7 +209,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, targ | |
first_hop_targets.insert(chan.remote_network_id, (short_channel_id, chan.counterparty_features.clone())); | ||
} | ||
if first_hop_targets.is_empty() { | ||
return Err(LightningError{err: "Cannot route when there are no outbound routes away from us", action: ErrorAction::IgnoreError}); | ||
return Err(LightningError{err: "Cannot route when there are no outbound routes away from us".to_owned(), action: ErrorAction::IgnoreError}); | ||
} | ||
} | ||
|
||
|
@@ -374,7 +374,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, targ | |
|
||
let new_entry = match dist.remove(&res.last().unwrap().pubkey) { | ||
Some(hop) => hop.3, | ||
None => return Err(LightningError{err: "Failed to find a non-fee-overflowing path to the given destination", action: ErrorAction::IgnoreError}), | ||
None => return Err(LightningError{err: "Failed to find a non-fee-overflowing path to the given destination".to_owned(), action: ErrorAction::IgnoreError}), | ||
}; | ||
res.last_mut().unwrap().fee_msat = new_entry.fee_msat; | ||
res.last_mut().unwrap().cltv_expiry_delta = new_entry.cltv_expiry_delta; | ||
|
@@ -395,7 +395,7 @@ pub fn get_route<L: Deref>(our_node_id: &PublicKey, network: &NetworkGraph, targ | |
} | ||
} | ||
|
||
Err(LightningError{err: "Failed to find a path to the given destination", action: ErrorAction::IgnoreError}) | ||
Err(LightningError{err: "Failed to find a path to the given destination".to_owned(), action: ErrorAction::IgnoreError}) | ||
} | ||
|
||
#[cfg(test)] | ||
|
@@ -881,7 +881,7 @@ mod tests { | |
assert_eq!(route.paths[0][0].fee_msat, 200); | ||
assert_eq!(route.paths[0][0].cltv_expiry_delta, (13 << 8) | 1); | ||
assert_eq!(route.paths[0][0].node_features.le_flags(), &vec![0b11]); // it should also override our view of their features | ||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::new()); // No feature flags will meet the relevant-to-channel conversion | ||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::<u8>::new()); // No feature flags will meet the relevant-to-channel conversion | ||
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. Are these changes needed? 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. Yes, my compiler complains that it cannot infer the type. (in every rustc version.). I have absolutely no idea why this happens only in this branch, it works fine in master. But giving an type annotation does not hurt. 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. Strange. I was able to reproduce this but am unsure what would cause rustc to complain. |
||
|
||
assert_eq!(route.paths[0][1].pubkey, node3); | ||
assert_eq!(route.paths[0][1].short_channel_id, 13); | ||
|
@@ -945,7 +945,7 @@ mod tests { | |
assert_eq!(route.paths[0][0].fee_msat, 200); | ||
assert_eq!(route.paths[0][0].cltv_expiry_delta, (13 << 8) | 1); | ||
assert_eq!(route.paths[0][0].node_features.le_flags(), &vec![0b11]); // it should also override our view of their features | ||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::new()); // No feature flags will meet the relevant-to-channel conversion | ||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::<u8>::new()); // No feature flags will meet the relevant-to-channel conversion | ||
|
||
assert_eq!(route.paths[0][1].pubkey, node3); | ||
assert_eq!(route.paths[0][1].short_channel_id, 13); | ||
|
@@ -1008,7 +1008,7 @@ mod tests { | |
assert_eq!(route.paths[0][0].fee_msat, 200); | ||
assert_eq!(route.paths[0][0].cltv_expiry_delta, (13 << 8) | 1); | ||
assert_eq!(route.paths[0][0].node_features.le_flags(), &vec![0b11]); | ||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::new()); // No feature flags will meet the relevant-to-channel conversion | ||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::<u8>::new()); // No feature flags will meet the relevant-to-channel conversion | ||
|
||
assert_eq!(route.paths[0][1].pubkey, node3); | ||
assert_eq!(route.paths[0][1].short_channel_id, 13); | ||
|
@@ -1082,8 +1082,8 @@ mod tests { | |
assert_eq!(route.paths[0][4].short_channel_id, 8); | ||
assert_eq!(route.paths[0][4].fee_msat, 100); | ||
assert_eq!(route.paths[0][4].cltv_expiry_delta, 42); | ||
assert_eq!(route.paths[0][4].node_features.le_flags(), &Vec::new()); // We dont pass flags in from invoices yet | ||
assert_eq!(route.paths[0][4].channel_features.le_flags(), &Vec::new()); // We can't learn any flags from invoices, sadly | ||
assert_eq!(route.paths[0][4].node_features.le_flags(), &Vec::<u8>::new()); // We dont pass flags in from invoices yet | ||
assert_eq!(route.paths[0][4].channel_features.le_flags(), &Vec::<u8>::new()); // We can't learn any flags from invoices, sadly | ||
|
||
// Simple test with outbound channel to 4 to test that last_hops and first_hops connect | ||
let our_chans = vec![channelmanager::ChannelDetails { | ||
|
@@ -1105,14 +1105,14 @@ mod tests { | |
assert_eq!(route.paths[0][0].fee_msat, 0); | ||
assert_eq!(route.paths[0][0].cltv_expiry_delta, (8 << 8) | 1); | ||
assert_eq!(route.paths[0][0].node_features.le_flags(), &vec![0b11]); | ||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::new()); // No feature flags will meet the relevant-to-channel conversion | ||
assert_eq!(route.paths[0][0].channel_features.le_flags(), &Vec::<u8>::new()); // No feature flags will meet the relevant-to-channel conversion | ||
|
||
assert_eq!(route.paths[0][1].pubkey, node7); | ||
assert_eq!(route.paths[0][1].short_channel_id, 8); | ||
assert_eq!(route.paths[0][1].fee_msat, 100); | ||
assert_eq!(route.paths[0][1].cltv_expiry_delta, 42); | ||
assert_eq!(route.paths[0][1].node_features.le_flags(), &Vec::new()); // We dont pass flags in from invoices yet | ||
assert_eq!(route.paths[0][1].channel_features.le_flags(), &Vec::new()); // We can't learn any flags from invoices, sadly | ||
assert_eq!(route.paths[0][1].node_features.le_flags(), &Vec::<u8>::new()); // We dont pass flags in from invoices yet | ||
assert_eq!(route.paths[0][1].channel_features.le_flags(), &Vec::<u8>::new()); // We can't learn any flags from invoices, sadly | ||
|
||
last_hops[0].fees.base_msat = 1000; | ||
|
||
|
@@ -1147,8 +1147,8 @@ mod tests { | |
assert_eq!(route.paths[0][3].short_channel_id, 10); | ||
assert_eq!(route.paths[0][3].fee_msat, 100); | ||
assert_eq!(route.paths[0][3].cltv_expiry_delta, 42); | ||
assert_eq!(route.paths[0][3].node_features.le_flags(), &Vec::new()); // We dont pass flags in from invoices yet | ||
assert_eq!(route.paths[0][3].channel_features.le_flags(), &Vec::new()); // We can't learn any flags from invoices, sadly | ||
assert_eq!(route.paths[0][3].node_features.le_flags(), &Vec::<u8>::new()); // We dont pass flags in from invoices yet | ||
assert_eq!(route.paths[0][3].channel_features.le_flags(), &Vec::<u8>::new()); // We can't learn any flags from invoices, sadly | ||
|
||
// ...but still use 8 for larger payments as 6 has a variable feerate | ||
let route = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &node7, None, &last_hops, 2000, 42, Arc::clone(&logger)).unwrap(); | ||
|
@@ -1188,7 +1188,7 @@ mod tests { | |
assert_eq!(route.paths[0][4].short_channel_id, 8); | ||
assert_eq!(route.paths[0][4].fee_msat, 2000); | ||
assert_eq!(route.paths[0][4].cltv_expiry_delta, 42); | ||
assert_eq!(route.paths[0][4].node_features.le_flags(), &Vec::new()); // We dont pass flags in from invoices yet | ||
assert_eq!(route.paths[0][4].channel_features.le_flags(), &Vec::new()); // We can't learn any flags from invoices, sadly | ||
assert_eq!(route.paths[0][4].node_features.le_flags(), &Vec::<u8>::new()); // We dont pass flags in from invoices yet | ||
assert_eq!(route.paths[0][4].channel_features.le_flags(), &Vec::<u8>::new()); // We can't learn any flags from invoices, sadly | ||
} | ||
} |
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.
Why not regex 1.3?
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.
This was the latest release version which compiles in rustc 1.22.0
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.
Ugh. Hmm, looks like their MSRV is still 1.28 (https://github.com/rust-lang/regex/blob/master/.github/workflows/ci.yml#L34) maybe lets just finally bump the MSRV to that given rust-bitcoin may bump to 1.29 sooner or later anyway.
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.
I suppose bumping the MSRV should be done with other PR so should I rebase after that PR gets merged? I think it is fine to use old regex though.
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.
Fair enough.