Skip to content

Add tests for routing message handler #570

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

Conversation

naumenkogs
Copy link
Contributor

Addressing the issue #524

@naumenkogs naumenkogs changed the title WIP: Add tests for handling node announcements WIP: Add tests for routing message handler Apr 2, 2020
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good as-is (there's always more to test, but this is a nice start), let me know if you plan on adding more stuff (since its tagged WIP) or if you want this to be merged. An obvious additional test may be testing that excess_data results in the announcement(s) being accepted, but not relayed (ie Ok(false) as a return value).

@naumenkogs
Copy link
Contributor Author

@TheBlueMatt I want to do all routing handlers within this PR. I'll let you know once it's fully ready for review!

@naumenkogs naumenkogs changed the title WIP: Add tests for routing message handler Add tests for routing message handler Apr 4, 2020
@naumenkogs
Copy link
Contributor Author

@TheBlueMatt ready for review! I left some questions along my tests.

Answering those would help me to get better intuition on the current state of the repo and approaches to things, so I'd be grateful.

@naumenkogs naumenkogs force-pushed the 2020_04_routing_message_handler_tests branch from e807e87 to b1bafd0 Compare April 4, 2020 22:01
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad this is getting some testing, but it seems a bunch of the internal state modifications are causing invalid states, which leave your comments that panics shoulnd't occur.

@naumenkogs naumenkogs force-pushed the 2020_04_routing_message_handler_tests branch from b1bafd0 to 1690c40 Compare April 6, 2020 23:49
@codecov
Copy link

codecov bot commented Apr 6, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@60dd37d). Click here to learn what that means.
The diff coverage is n/a.

@naumenkogs
Copy link
Contributor Author

@TheBlueMatt I think I addressed all your comments.
Sorry in advance for the formatting issues: still getting used to tabs.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One comment, though.

@naumenkogs naumenkogs force-pushed the 2020_04_routing_message_handler_tests branch from 1690c40 to 14d10e5 Compare April 7, 2020 23:02
@naumenkogs
Copy link
Contributor Author

Done!

@naumenkogs naumenkogs force-pushed the 2020_04_routing_message_handler_tests branch from 14d10e5 to f9f90e9 Compare April 7, 2020 23:04
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The comments are mostly all nits, so you're welcome to chose to ignore some, but get_next_channel_announcements probably doesn't make sense as-is.

let network = router.network_map.write().unwrap();
assert_eq!(network.channels.len(), 0);
// Nodes are also deleted because there are no associated channels anymore
assert_eq!(network.nodes.len(), 1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why does it end with 1? (and maybe test that it starts with 1 at the top).

Copy link
Contributor Author

@naumenkogs naumenkogs Apr 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is "our" node, the one we initiate a router with.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add an assert at the top of the test + a comment indicating that, I think.

}

// No updates.
let next_announcements = router.get_next_channel_announcements(channel_key, 2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. I actually think this is a bug, and have a commit to fix it that I haven't gotten around to PR'ing yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, so should we wait when you merge that first then?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you. You're welcome to take the top commit from https://github.com/TheBlueMatt/rust-lightning/tree/2020-04-relay-no-node in this PR or I can do it separately and you can drop the relevant commit from this PR.

};
}

// Updates with empty messages are not returned.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@naumenkogs naumenkogs force-pushed the 2020_04_routing_message_handler_tests branch 3 times, most recently from 80e676e to 82c5995 Compare April 10, 2020 13:55
@naumenkogs
Copy link
Contributor Author

@TheBlueMatt Addressed latest suggestions!

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Travis found that a few spots don't compile with older rustcs that we support (I suggested changes that I think will fix it, but no guarantees).

Comment on lines 2472 to 2474
let (_, update_1, update_2) = channel_announcements;
assert_ne!(update_1.clone(), None);
assert_eq!(update_2.clone(), None);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let (_, update_1, update_2) = channel_announcements;
assert_ne!(update_1.clone(), None);
assert_eq!(update_2.clone(), None);
let &(_, ref update_1, ref update_2) = channel_announcements;
assert_ne!(update_1, &None);
assert_eq!(update_2, &None);

Comment on lines 2436 to 2438
let (_, update_1, update_2) = channel_announcements;
assert_eq!(update_1.clone(), None);
assert_eq!(update_2.clone(), None);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let (_, update_1, update_2) = channel_announcements;
assert_eq!(update_1.clone(), None);
assert_eq!(update_2.clone(), None);
let &(_, ref update_1, ref update_2) = channel_announcements;
assert_eq!(update_1, &None);
assert_eq!(update_2, &None);

Comment on lines 2509 to 2511
let (_, update_1, update_2) = channel_announcements;
assert_eq!(update_1.clone(), None);
assert_eq!(update_2.clone(), None);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let (_, update_1, update_2) = channel_announcements;
assert_eq!(update_1.clone(), None);
assert_eq!(update_2.clone(), None);
let &(_, ref update_1, ref update_2) = channel_announcements;
assert_eq!(update_1, &None);
assert_eq!(update_2, &None);

@TheBlueMatt
Copy link
Collaborator

Also needs rebase on master.

@naumenkogs naumenkogs force-pushed the 2020_04_routing_message_handler_tests branch from 82c5995 to 79c8491 Compare April 11, 2020 13:00
@naumenkogs
Copy link
Contributor Author

@TheBlueMatt done. Thanks for patience :)

@TheBlueMatt
Copy link
Collaborator

Oops, I had the github settings set wrong, turns out didn't need a rebase. Anyway, looks great!

@TheBlueMatt TheBlueMatt merged commit c9c9415 into lightningdevkit:master Apr 11, 2020
@naumenkogs naumenkogs deleted the 2020_04_routing_message_handler_tests branch April 11, 2020 21:28
@naumenkogs naumenkogs restored the 2020_04_routing_message_handler_tests branch April 11, 2020 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants