This commit is contained in:
Robert Habermeier
2018-11-03 17:08:47 +01:00
parent abfc4a24a9
commit ddd46db4d5
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -194,6 +194,11 @@ impl<V: 'static + Verifier<Block>, D> Peer<V, D> {
io.to_disconnect.clone()
}
fn with_io<'a, F, U>(&'a self, f: F) -> U where F: FnOnce(&mut TestIo<'a>) -> U {
let mut io = TestIo::new(&self.queue, None);
f(&mut io)
}
/// Produce the next pending message to send to another peer.
fn pending_message(&self) -> Option<TestPacket> {
self.flush();
+3 -1
View File
@@ -90,12 +90,14 @@ fn sync_after_fork_works() {
}
#[test]
#[ignore] // reinstate when import queue handlers dispatch announce messages.
fn own_blocks_are_announced() {
::env_logger::init().ok();
let mut net = TestNet::new(3);
net.sync(); // connect'em
net.peer(0).generate_blocks(1, BlockOrigin::Own, |builder| builder.bake().unwrap());
let header = net.peer(0).client().header(&BlockId::Number(1)).unwrap().unwrap();
net.peer(0).with_io(|io| net.peer(0).sync.on_block_imported(io, header.hash(), &header));
net.sync();
assert_eq!(net.peer(0).client.backend().blockchain().info().unwrap().best_number, 1);
assert_eq!(net.peer(1).client.backend().blockchain().info().unwrap().best_number, 1);