Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Remove more instances of futures01 (#4633)
Browse files Browse the repository at this point in the history
* Start removing last few instances of futures01

* Use to_poll on wasm

* Revert "Use to_poll on wasm"

This reverts commit 1c61728.

* Fix fg test

* Upgrade network test futures

* Update offchain hyper version

* Update service test

* bump tokio to 0.2.10

* Removed some unneeded tokios

* fixes

* fix run_until_all_full

* Make service test debuggable

* Update client/offchain/src/api/http.rs

Co-Authored-By: Demi Obenour <48690212+DemiMarie-parity@users.noreply.github.com>

* Add service_test to test-int output

* nitpicking

* Finally fix test

* Give up and revert client/serviec/test

* Revert gitlab ci too

Co-authored-by: Demi Obenour <demi@parity.io>
  • Loading branch information
expenses and Demi-Marie authored Feb 28, 2020
1 parent b5ec7d4 commit 29cee59
Show file tree
Hide file tree
Showing 16 changed files with 367 additions and 436 deletions.
211 changes: 102 additions & 109 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,5 @@ sc-network = { version = "0.8.0-alpha.2", path = "../../network" }
sc-network-test = { version = "0.8.0-dev", path = "../../network/test" }
sc-service = { version = "0.8.0-alpha.2", path = "../../service" }
substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../test-utils/runtime/client" }
tokio = "0.1.22"
env_logger = "0.7.0"
tempfile = "3.1.0"
futures01 = { package = "futures", version = "0.1" }
30 changes: 14 additions & 16 deletions client/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,10 @@ mod tests {
use sp_runtime::traits::{Block as BlockT, DigestFor};
use sc_network::config::ProtocolConfig;
use parking_lot::Mutex;
use tokio::runtime::current_thread;
use sp_keyring::sr25519::Keyring;
use sc_client::BlockchainEvents;
use sp_consensus_aura::sr25519::AuthorityPair;
use std::task::Poll;

type Error = sp_blockchain::Error;

Expand Down Expand Up @@ -950,8 +950,8 @@ mod tests {

let net = Arc::new(Mutex::new(net));
let mut import_notifications = Vec::new();
let mut aura_futures = Vec::new();

let mut runtime = current_thread::Runtime::new().unwrap();
let mut keystore_paths = Vec::new();
for (peer_id, key) in peers {
let mut net = net.lock();
Expand Down Expand Up @@ -979,7 +979,7 @@ mod tests {
&inherent_data_providers, slot_duration.get()
).expect("Registers aura inherent data provider");

let aura = start_aura::<_, _, _, _, _, AuthorityPair, _, _, _>(
aura_futures.push(start_aura::<_, _, _, _, _, AuthorityPair, _, _, _>(
slot_duration,
client.clone(),
select_chain,
Expand All @@ -990,21 +990,19 @@ mod tests {
false,
keystore,
sp_consensus::AlwaysCanAuthor,
)
.expect("Starts aura")
.unit_error()
.compat();

runtime.spawn(aura);
).expect("Starts aura"));
}

runtime.spawn(futures01::future::poll_fn(move || {
net.lock().poll();
Ok::<_, ()>(futures01::Async::NotReady::<()>)
}));

runtime.block_on(future::join_all(import_notifications)
.unit_error().compat()).unwrap();
futures::executor::block_on(future::select(
future::poll_fn(move |cx| {
net.lock().poll(cx);
Poll::<()>::Pending
}),
future::select(
future::join_all(aura_futures),
future::join_all(import_notifications)
)
));
}

#[test]
Expand Down
2 changes: 0 additions & 2 deletions client/consensus/babe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ sc-network-test = { version = "0.8.0-dev", path = "../../network/test" }
sc-service = { version = "0.8.0-alpha.2", path = "../../service" }
substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../../test-utils/runtime/client" }
sc-block-builder = { version = "0.8.0-alpha.2", path = "../../block-builder" }
tokio = "0.1.22"
env_logger = "0.7.0"
tempfile = "3.1.0"
futures01 = { package = "futures", version = "0.1" }

[features]
test-helpers = []
2 changes: 1 addition & 1 deletion client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ pub struct BabeParams<B: BlockT, C, E, I, SO, SC, CAW> {
pub can_author_with: CAW,
}

/// Start the babe worker. The returned future should be run in a tokio runtime.
/// Start the babe worker.
pub fn start_babe<B, C, SC, E, I, SO, CAW, Error>(BabeParams {
keystore,
client,
Expand Down
35 changes: 17 additions & 18 deletions client/consensus/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ use sc_network_test::*;
use sc_network_test::{Block as TestBlock, PeersClient};
use sc_network::config::{BoxFinalityProofRequestBuilder, ProtocolConfig};
use sp_runtime::{generic::DigestItem, traits::{Block as BlockT, DigestFor}};
use tokio::runtime::current_thread;
use sc_client_api::{BlockchainEvents, backend::TransactionFor};
use log::debug;
use std::{time::Duration, cell::RefCell};
use std::{time::Duration, cell::RefCell, task::Poll};

type Item = DigestItem<Hash>;

Expand Down Expand Up @@ -354,7 +353,7 @@ fn run_one_test(

let net = Arc::new(Mutex::new(net));
let mut import_notifications = Vec::new();
let mut runtime = current_thread::Runtime::new().unwrap();
let mut babe_futures = Vec::new();
let mut keystore_paths = Vec::new();

for (peer_id, seed) in peers {
Expand Down Expand Up @@ -399,7 +398,7 @@ fn run_one_test(
);


runtime.spawn(start_babe(BabeParams {
babe_futures.push(start_babe(BabeParams {
block_import: data.block_import.lock().take().expect("import set up during init"),
select_chain,
client,
Expand All @@ -410,23 +409,23 @@ fn run_one_test(
babe_link: data.link.clone(),
keystore,
can_author_with: sp_consensus::AlwaysCanAuthor,
}).expect("Starts babe").unit_error().compat());
}).expect("Starts babe"));
}

runtime.spawn(futures01::future::poll_fn(move || {
let mut net = net.lock();
net.poll();
for p in net.peers() {
for (h, e) in p.failed_verifications() {
panic!("Verification failed for {:?}: {}", h, e);
futures::executor::block_on(future::select(
futures::future::poll_fn(move |cx| {
let mut net = net.lock();
net.poll(cx);
for p in net.peers() {
for (h, e) in p.failed_verifications() {
panic!("Verification failed for {:?}: {}", h, e);
}
}
}

Ok::<_, ()>(futures01::Async::NotReady::<()>)
}));

runtime.block_on(future::join_all(import_notifications)
.unit_error().compat()).unwrap();

Poll::<()>::Pending
}),
future::select(future::join_all(import_notifications), future::join_all(babe_futures))
));
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions client/finality-grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ substrate-test-runtime-client = { version = "2.0.0-dev", path = "../../test-uti
sp-consensus-babe = { version = "0.8.0-alpha.2", path = "../../primitives/consensus/babe" }
sp-state-machine = { version = "0.8.0-alpha.2", path = "../../primitives/state-machine" }
env_logger = "0.7.0"
tokio = "0.1.22"
tokio = { version = "0.2", features = ["rt-core"] }
tempfile = "3.1.0"
sp-api = { version = "2.0.0-alpha.2", path = "../../primitives/api" }
futures01 = { package = "futures", version = "0.1.29" }
Loading

0 comments on commit 29cee59

Please sign in to comment.