Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
35a4aa63
Commit
35a4aa63
authored
6 years ago
by
Pierre Krieger
Committed by
Bastian Köcher
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make the discovery test more strict (#1721)
parent
c860787d
Branches
gh-readonly-queue/master/pr-4586-11dd10b46511647d8663afe063015b16a8c1e124
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/core/network-libp2p/tests/test.rs
+12
-6
12 additions, 6 deletions
substrate/core/network-libp2p/tests/test.rs
with
12 additions
and
6 deletions
substrate/core/network-libp2p/tests/test.rs
+
12
−
6
View file @
35a4aa63
...
...
@@ -141,18 +141,23 @@ fn many_nodes_connectivity() {
let
mut
num_connecs
=
0
;
stream
::
poll_fn
(
move
||
->
io
::
Result
<
_
>
{
loop
{
const
MAX_BANDWIDTH
:
u64
=
NUM_NODES
as
u64
*
1024
;
// 1kiB/s/node
assert!
(
node
.average_download_per_sec
()
<
MAX_BANDWIDTH
);
assert!
(
node
.average_upload_per_sec
()
<
MAX_BANDWIDTH
);
match
try_ready!
(
node
.poll
())
{
Some
(
ServiceEvent
::
OpenedCustomProtocol
{
..
})
=>
{
num_connecs
+=
1
;
assert!
(
num_connecs
<
NUM_NODES
);
if
num_connecs
==
NUM_NODES
-
1
{
return
Ok
(
Async
::
Ready
(
Some
(
()
)))
return
Ok
(
Async
::
Ready
(
Some
(
true
)))
}
}
Some
(
ServiceEvent
::
ClosedCustomProtocol
{
..
})
=>
{
// Only remove 1 if we haven't returned success yet, otherwise we
// will succeed the test multiple times.
if
num_connecs
<
NUM_NODES
-
1
{
num_connecs
-=
1
;
let
was_success
=
num_connecs
==
NUM_NODES
-
1
;
num_connecs
-=
1
;
if
was_success
&&
num_connecs
<
NUM_NODES
-
1
{
return
Ok
(
Async
::
Ready
(
Some
(
false
)))
}
}
_
=>
panic!
(),
...
...
@@ -166,7 +171,8 @@ fn many_nodes_connectivity() {
let
combined
=
future
::
poll_fn
(
move
||
->
io
::
Result
<
_
>
{
for
node
in
futures
.iter_mut
()
{
match
node
.poll
()
?
{
Async
::
Ready
(
Some
(
_
))
=>
successes
+=
1
,
Async
::
Ready
(
Some
(
true
))
=>
successes
+=
1
,
Async
::
Ready
(
Some
(
false
))
=>
successes
-=
1
,
Async
::
Ready
(
None
)
=>
unreachable!
(),
Async
::
NotReady
=>
()
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment