This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix try-runtime fast-forward
when run from the substrate cli and add test
#13888
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8566c87
fix fast_forward when used with substrate binary
liamaharon 176d66c
test that fast forward runs and logs expected output
liamaharon ea4c92b
update start_node to use node-template
liamaharon 1166f9b
Update utils/frame/try-runtime/cli/tests/fast_forward.rs
liamaharon baced25
Update utils/frame/try-runtime/cli/tests/fast_forward.rs
liamaharon 730e1e6
increase follow_chain test timeout
liamaharon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,10 +61,10 @@ use tokio::io::{AsyncBufReadExt, AsyncRead}; | |
/// | ||
/// [`Child`]: std::process::Child | ||
pub fn start_node() -> Child { | ||
Command::new(cargo_bin("substrate")) | ||
Command::new(cargo_bin("node-template")) | ||
.stdout(process::Stdio::piped()) | ||
.stderr(process::Stdio::piped()) | ||
.args(&["--dev", "--tmp", "--ws-port=45789", "--no-hardware-benchmarks"]) | ||
.args(&["--dev", "--ws-port=45789"]) | ||
.spawn() | ||
.unwrap() | ||
Comment on lines
-64
to
69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to make things simpler.
Let me know if I'm missing something though. |
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
#![cfg(unix)] | ||
|
||
#[cfg(feature = "try-runtime")] | ||
mod tests { | ||
use assert_cmd::cargo::cargo_bin; | ||
use regex::Regex; | ||
use std::{ | ||
process, | ||
str::from_utf8, | ||
time::Duration, | ||
}; | ||
use substrate_cli_test_utils as common; | ||
use tokio::process::Command; | ||
|
||
#[tokio::test] | ||
async fn follow_chain_works() { | ||
// Build substrate so binaries used in the test use the latest code. | ||
common::build_substrate(&["--features=try-runtime"]); | ||
|
||
let n_blocks = 10; | ||
common::run_with_timeout(Duration::from_secs(10 * 60), async move { | ||
let run_fast_forward = |ws_url: String| async move { | ||
Command::new(cargo_bin("substrate")) | ||
.stdout(process::Stdio::piped()) | ||
.stderr(process::Stdio::piped()) | ||
.args(&["try-runtime", "--runtime=existing"]) | ||
.args(&[ | ||
"fast-forward", | ||
format!("--n-blocks={}", n_blocks).as_str(), | ||
"live", | ||
format!("--uri={}", ws_url).as_str(), | ||
]) | ||
.kill_on_drop(true) | ||
.output() | ||
.await | ||
.unwrap() | ||
}; | ||
|
||
// Start a node and wait for it to begin finalizing blocks | ||
let mut node = common::KillChildOnDrop(common::start_node()); | ||
let ws_url = common::extract_info_from_output(node.stderr.take().unwrap()).0.ws_url; | ||
common::wait_n_finalized_blocks(1, &ws_url).await; | ||
|
||
// Make sure fast_forward logged "Executed the new block" the expected number of times | ||
// and exited successfully | ||
let fast_forward = run_fast_forward(ws_url).await; | ||
let re = Regex::new( | ||
format!(r#"(?:(?s).*Executed the new block.*\s*){}"#, n_blocks).as_str(), | ||
) | ||
.unwrap(); | ||
assert!(re.is_match(from_utf8(&fast_forward.stderr).unwrap())); | ||
assert!(fast_forward.status.success()); | ||
}) | ||
.await; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally always prefer using the full path where needed, or doing the import more locally, rather than feature gated imports, but up to you.