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
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
only block once on futures in test
  • Loading branch information
rphmeier committed Jan 15, 2020
commit 142ec783c6a20eab41ea059684b01eb616f2ab72
20 changes: 11 additions & 9 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ mod tests {
use sc_service::AbstractService;
use crate::service::{new_full, new_light};
use sp_runtime::traits::IdentifyAccount;
use futures::prelude::*;

type AccountPublic = <Signature as Verify>::Signer;

Expand Down Expand Up @@ -535,15 +536,16 @@ mod tests {

digest.push(<DigestItem as CompatibleDigestItem>::babe_pre_digest(babe_pre_digest));

let mut proposer = futures::executor::block_on(
proposer_factory.init(&parent_header)
).unwrap();
let new_block = futures::executor::block_on(proposer.propose(
inherent_data,
digest,
std::time::Duration::from_secs(1),
RecordProof::Yes,
)).expect("Error making test block").block;
let proposing = proposer_factory.init(&parent_header)
.and_then(|mut proposer| proposer.propose(
inherent_data,
digest,
std::time::Duration::from_secs(1),
RecordProof::Yes,
));

let new_block = futures::executor::block_on(proposing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest something like this instead?

Suggested change
let new_block = futures::executor::block_on(proposing)
let new_block = futures::executor::block_on(async move {
let proposer = proposer_factory.init(&parent_header).await;
proposer.propose(
inherent_data,
digest,
std::time::Duration::from_secs(1),
RecordProof::Yes,
).await
});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need to get the async/await into my bloodstream :)

.expect("Error making test block").block;

let (new_header, new_body) = new_block.deconstruct();
let pre_hash = new_header.hash();
Expand Down