Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b21d51c
Switch GrandPa to new futures
tomaka Aug 5, 2019
a25be8e
Merge remote-tracking branch 'upstream/master' into HEAD
tomaka Oct 24, 2019
513704d
Merge remote-tracking branch 'upstream/master' into HEAD
tomaka Oct 28, 2019
6007c2b
Work on making tests work
tomaka Oct 28, 2019
46f3728
until_imported tests working again
tomaka Oct 28, 2019
6f6849a
Work on switching tests to stable futures
tomaka Oct 28, 2019
7c4f79b
Merge remote-tracking branch 'parity/master' into HEAD
expenses Jan 10, 2020
c1dd9e5
Modifications
expenses Jan 13, 2020
6737632
Merge remote-tracking branch 'parity/master' into ashley-grandpa-futures
expenses Jan 13, 2020
46a6822
Re-add test as #[ignore]
expenses Jan 13, 2020
f05c301
Don't ignore
expenses Jan 13, 2020
53fb151
Add manual unpins
expenses Jan 13, 2020
6fdc0b8
Remove Header import
expenses Jan 14, 2020
a52f255
Merge remote-tracking branch 'parity/master' into ashley-grandpa-futures
expenses Jan 14, 2020
14d8afb
Return concrete Sink type
expenses Jan 15, 2020
b1264db
Switch to crates.io finality-grandpa version
expenses Jan 16, 2020
5afd086
Merge remote-tracking branch 'parity/master' into ashley-grandpa-futures
expenses Jan 16, 2020
ba62dd5
Remove use statement that slipped in
expenses Jan 16, 2020
daf41a3
Fix some nitpicks
expenses Jan 16, 2020
828af5e
Remove unpin from i
expenses Jan 16, 2020
c7d2b24
Fixed typo
expenses Jan 16, 2020
e1a89d7
Merge remote-tracking branch 'parity/master' into ashley-grandpa-futures
expenses Jan 17, 2020
7fcf87b
Move futures01 to dev-deps
expenses Jan 17, 2020
65724be
Merge remote-tracking branch 'parity/master' into ashley-grandpa-futures
expenses Jan 20, 2020
8589985
Merge remote-tracking branch 'parity/master' into ashley-grandpa-futures
expenses Jan 22, 2020
6053e88
Merge remote-tracking branch 'parity/master' into ashley-grandpa-futures
expenses Jan 23, 2020
a6097b3
Fix nitpicks
expenses Jan 23, 2020
6226ed4
Update client/finality-grandpa/src/communication/mod.rs
expenses Jan 23, 2020
d6b89c4
nitpicking
expenses Jan 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
until_imported tests working again
  • Loading branch information
tomaka committed Oct 28, 2019
commit 46f372861c5a22347aae8624db0f02f93e0481ba
45 changes: 21 additions & 24 deletions core/finality-grandpa/src/until_imported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ pub(crate) type UntilGlobalMessageBlocksImported<Block, BlockStatus, BlockSyncRe
BlockGlobalMessage<Block>,
>;

#[cfg(testttt)] // TODO: restore
#[cfg(test)]
mod tests {
use super::*;
use crate::{CatchUp, CompactCommit};
Expand Down Expand Up @@ -591,15 +591,15 @@ mod tests {
import_notifications,
TestBlockSyncRequester::default(),
block_status,
global_rx.map_err(|_| panic!("should never error")),
global_rx.map_err(|()| panic!("should never error")),
"global",
);

global_tx.unbounded_send(msg).unwrap();
global_tx.unbounded_send(Ok(msg)).unwrap();

let work = until_imported.into_future();

futures::executor::block_on(work).map_err(|(e, _)| e).unwrap().0.unwrap()
futures::executor::block_on(work).0.unwrap().unwrap()
}

fn blocking_message_on_dependencies<F>(
Expand All @@ -617,30 +617,27 @@ mod tests {
import_notifications,
TestBlockSyncRequester::default(),
block_status,
global_rx.map_err(|_| panic!("should never error")),
global_rx.map_err(|()| panic!("should never error")),
"global",
);

global_tx.unbounded_send(msg).unwrap();
global_tx.unbounded_send(Ok(msg)).unwrap();

// NOTE: needs to be cloned otherwise it is moved to the stream and
// dropped too early.
let inner_chain_state = chain_state.clone();
let work = until_imported
.into_future()
.select2(Delay::new(Instant::now() + Duration::from_millis(100)))
let work = future::select(until_imported.into_future(), Delay::new(Duration::from_millis(100)))
.then(move |res| match res {
Err(_) => panic!("neither should have had error"),
Ok(Either::A(_)) => panic!("timeout should have fired first"),
Ok(Either::B((_, until_imported))) => {
Either::Left(_) => panic!("timeout should have fired first"),
Either::Right((_, until_imported)) => {
// timeout fired. push in the headers.
enact_dependencies(&inner_chain_state);

until_imported
}
});

futures::executor::block_on(work).map_err(|(e, _)| e).unwrap().0.unwrap()
futures::executor::block_on(work).0.unwrap().unwrap()
}

#[test]
Expand Down Expand Up @@ -874,7 +871,7 @@ mod tests {
import_notifications,
block_sync_requester.clone(),
block_status,
global_rx.map_err(|_| panic!("should never error")),
global_rx.map_err(|()| panic!("should never error")),
"global",
);

Expand Down Expand Up @@ -907,13 +904,13 @@ mod tests {
);

// we send the commit message and spawn the until_imported stream
global_tx.unbounded_send(unknown_commit()).unwrap();
global_tx.unbounded_send(Ok(unknown_commit())).unwrap();

let mut threads_pool = futures::executor::ThreadPool::new().unwrap();
threads_pool.spawn_ok(until_imported.into_future().map(|_| ()).map_err(|_| ()));
let threads_pool = futures::executor::ThreadPool::new().unwrap();
threads_pool.spawn_ok(until_imported.into_future().map(|_| ()));

// assert that we will make sync requests
let assert = futures::future::poll_fn::<(), (), _>(|| {
let assert = futures::future::poll_fn(|_| {
let block_sync_requests = block_sync_requester.requests.lock();

// we request blocks targeted by the precommits that aren't imported
Expand All @@ -928,12 +925,12 @@ mod tests {

// the `until_imported` stream doesn't request the blocks immediately,
// but it should request them after a small timeout
let timeout = Delay::new(Instant::now() + Duration::from_secs(60));
let test = assert.select2(timeout).map(|res| match res {
Either::A(_) => {},
Either::B(_) => panic!("timed out waiting for block sync request"),
}).map_err(|_| ());
let timeout = Delay::new(Duration::from_secs(60));
let test = future::select(assert, timeout).map(|res| match res {
Either::Left(_) => {},
Either::Right(_) => panic!("timed out waiting for block sync request"),
});

futures::executor::block_on(test).unwrap();
futures::executor::block_on(test);
}
}