This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Rewrite the network TestNet #3016
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arkpar
reviewed
Jul 4, 2019
core/finality-grandpa/src/tests.rs
Outdated
| let mut net = GrandpaTestNet::new(TestApi::new(voters), 4); | ||
| net.peer(0).push_blocks(20, false); | ||
| net.sync(); | ||
| runtime.block_on(futures::future::poll_fn::<(), (), _>(|| Ok(net.poll_until_sync()))).unwrap(); |
Member
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.
Would rather see . poll_until_sync' accept runtime parameter and calling block_oninternally, to avoid repeating all thepoll_fnugliness. A more genericpoll_until` that accepts a function would also be useful.
Member
|
Looks good, except for a minor nitpick |
andresilva
approved these changes
Jul 5, 2019
Contributor
andresilva
left a comment
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.
lgtm
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
TestNetstruct insubstrate-networkallows simulating a network. It is used in the tests of the network, of Aura, of Babe, and of GrandPa.At the moment, it uses the internals of the network crate (more specifically:
Protocol) and simulates a network on top of that. This PR changes that so that it uses the API surface of the network crate, therefore including discovery, pinging, and all that the networking actually does.In order to do so, it is now possible to put the network in "memory only" mode. In this mode, the node addresses are in the form
/memory/NwhereNis a randomly-generated u64. Nodes "connect" to each other using channels.In the process, I've made all the tests asynchronous. No background thread is being spawned anymore.
Since we no longer decide which node is connected to which, "disconnecting" is now done by destroying nodes altogether. Other than this detail, I have tried to not change anything in the logic of the tests.
This will make it possible to continue the internal refactoring of the network crate, as we can now move touch things that would break the tests before. I've already opened #2962 that should be merged on top of this PR.