-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Test random usage of peerset api #2243
Conversation
|
@tomaka One issue I ran into is that one can't keep exactly track of the "last message" for a given peer, since some messages come with a So for example if a Would there be a way to figure out one from the other? Perhaps we should add the |
|
Will properly review later, but I don't think we should change the API because of tests. Also, since it's pretty large and only deals with the public API, I suggest we move the code that this PR adds into the |
When a message comes in with an indice, how to associate it with a peer id?
Ok |
|
Oh I didn't realize you were only dumping a lot of messages into the peerset then reading the results. |
|
Ok so re the index vs id, they can be associated when setting things up.
Why do we need a network setup? It seems easier to test the peerset as a blackbox by randomly using the API, even in ways that currently isn't used as part of an actually running network. For example, from the current test failure it appears to be quite easy to have an |
By "simulate an actual network", I mean "use the API to make the peerset believe that we have an actual network".
"Connect -> dropped -> incoming -> Accept" is indeed a valid API usage. |
|
Ok I've added some checks that can actually express an expectations of a sequence of actions like "Connect -> dropped -> incoming -> Accept". It seems that " dropped -> incoming -> Accept" holds so far, but that serie comes out often without first having received a
If we focus more on using the API in a way that an actual network would, are we not going to exclude weird unexpected cases? The "random" input could be adapted to not be completely random and match what would otherwise be expected... |
|
Currently tests are failing on the assertions of "Connect -> dropped -> incoming -> Accept" always being received in that order. If we reduce this to only "dropped -> incoming -> Accept", they would pass. Other then that technicality, we need to decide on an overall approach. I am in favor of the approach taken here, which is to send completely random messages to the peer set as input, and then make assertions on the output we get from the peerset, ensuring that no matter the sequence of input, certain invariant hold on the output. @tomaka I think you wanted to take a different approach? Do you have suggestions on steps that could be taken in that direction? |
I'm fine with the approach in this PR, but I think it's insufficient. We should adjust the messages we send to the PSM based on what it is sending back to us. I opened #2470 with that other approach, but we could merge both. |
|
Ok, I've taken a look and I think it wouldn't hurt to have both tests run side by side. I've also fixed a logical error in the assertions on this one, it now passes. The folder introduced here is named |
core/peerset/src/test/mod.rs
Outdated
| (Some(drop), Some(incoming)) => { | ||
| assert!(drop < incoming); | ||
| println!("Last messages: {:?}", last_messages); | ||
| assert!(last_messages.contains(&Message::Connect(peer_id.clone()))); |
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.
Since the Connect message has already been removed from the VecDeque above, this was a faulty assertion...
I went for an external test since we test the API surface of the crate, as opposed to an internal API. |
|
Ok, I'd be happy to rebase after the other PR merges, and just add this test to the same file. Fixed a couple of bugs in this test. Perhaps you could also take a look that the main assertions, about the order of operations, make sense? I'll look more into the other PR, and see if I can dig up the reason for the current failure... |
It's entirely possible that there's an issue in the PSM. It wouldn't be a bad idea to test this PR (and mine as well) against #2440. |
|
@gterzian this looks stale - should it be closed? |
|
Ok, closing because I think #2470 gives us the coverage we want... |
FIX #2200