-
Notifications
You must be signed in to change notification settings - Fork 2.6k
client/finality-grandpa: Add regression test for observer polling network #4778
Conversation
Ensure `Future` implementation of `ObserverWork` is polling its `NetworkBridge`. Regression test for bug introduced in d4fbb89 and fixed in 7d58cee. When polled, `NetworkBridge` forwards reputation change requests from the `GossipValidator` to the underlying `dyn Network`. This test triggers a reputation change by calling `GossipValidator::validate` with an invalid gossip message. After polling the `ObserverWork` which should poll the `NetworkBridge`, the reputation change should be forwarded to the test network.
// validator to the test network. | ||
assert!(observer.now_or_never().is_none()); | ||
|
||
match tester.events.next().now_or_never() { |
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.
assert_matches!
would be a better choice here
|
||
use futures::executor::{self, ThreadPool}; | ||
|
||
#[test] |
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.
Please put bellow the comment.
); | ||
|
||
// Trigger a reputation change through the gossip validator. | ||
|
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.
let mut tester = executor::block_on(tester_fut); | ||
|
||
// Create an observer. | ||
|
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.
let thread_pool = ThreadPool::new().unwrap(); | ||
|
||
// Create a test network. | ||
|
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.
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, just couple of nits
@mxinden just needs the nits fixing before it can be merged... |
#4795 replaces this. |
…work (was #4778) (#4795) * client/finality-grandpa: Add regression test observer polling network Ensure `Future` implementation of `ObserverWork` is polling its `NetworkBridge`. Regression test for bug introduced in d4fbb89 and fixed in 7d58cee. When polled, `NetworkBridge` forwards reputation change requests from the `GossipValidator` to the underlying `dyn Network`. This test triggers a reputation change by calling `GossipValidator::validate` with an invalid gossip message. After polling the `ObserverWork` which should poll the `NetworkBridge`, the reputation change should be forwarded to the test network. * Nits Co-authored-by: Max Inden <[email protected]>
Ensure
Future
implementation ofObserverWork
is polling itsNetworkBridge
. Regression test for bug introduced in d4fbb89 andfixed in 7d58cee.
When polled,
NetworkBridge
forwards reputation change requests fromthe
GossipValidator
to the underlyingdyn Network
. This testtriggers a reputation change by calling
GossipValidator::validate
withan invalid gossip message. After polling the
ObserverWork
which shouldpoll the
NetworkBridge
, the reputation change should be forwarded tothe test network.
Thanks @NikVolf for pushing for this!