companion for #12212 (#6162)

* companion for #12212

* cargo fmt

* fix build

* update Cargo.lock

* update Cargo.lock
This commit is contained in:
Niklas Adolfsson
2022-10-18 20:09:37 +02:00
committed by GitHub
parent 9e690fe1b6
commit 400ee474a5
4 changed files with 207 additions and 189 deletions
+195 -182
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -22,7 +22,7 @@ assert_cmd = "2.0.4"
nix = "0.24.1"
tempfile = "3.2.0"
tokio = "1.19.2"
remote-externalities = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-rpc-client = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-core-primitives = { path = "core-primitives" }
[workspace]
+4 -4
View File
@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use polkadot_core_primitives::Block;
use remote_externalities::rpc_api::RpcService;
use polkadot_core_primitives::{Block, Hash, Header};
use std::{
io::{BufRead, BufReader, Read},
process::{Child, ExitStatus},
thread,
time::Duration,
};
use substrate_rpc_client::{ws_client, ChainApi};
use tokio::time::timeout;
/// Wait for the given `child` the given amount of `secs`.
@@ -56,12 +56,12 @@ async fn wait_n_finalized_blocks_from(n: usize, url: &str) {
let mut interval = tokio::time::interval(Duration::from_secs(6));
loop {
let rpc_service = match RpcService::new(url, false).await {
let rpc = match ws_client(url).await {
Ok(rpc_service) => rpc_service,
Err(_) => continue,
};
if let Ok(block) = rpc_service.get_finalized_head::<Block>().await {
if let Ok(block) = ChainApi::<(), Hash, Header, Block>::finalized_head(&rpc).await {
built_blocks.insert(block);
if built_blocks.len() > n {
break
+7 -2
View File
@@ -295,11 +295,16 @@ frame_support::parameter_types! {
/// Build the Ext at hash with all the data of `ElectionProviderMultiPhase` and any additional
/// pallets.
async fn create_election_ext<T: EPM::Config, B: BlockT + DeserializeOwned>(
async fn create_election_ext<T, B>(
client: SharedRpcClient,
at: Option<B::Hash>,
additional: Vec<String>,
) -> Result<Ext, Error<T>> {
) -> Result<Ext, Error<T>>
where
T: EPM::Config,
B: BlockT,
B::Header: DeserializeOwned,
{
use frame_support::{storage::generator::StorageMap, traits::PalletInfo};
use sp_core::hashing::twox_128;