Skip to content

Commit 0e4fb1d

Browse files
committed
add new test case
1 parent bf205e5 commit 0e4fb1d

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

cli/tests/execute_block.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,45 @@ async fn execute_block_works() {
121121
.status
122122
.success());
123123
})
124+
.await;
125+
126+
// Test passing --from and --to to execute a range of blocks.
127+
common::run_with_timeout(Duration::from_secs(120), async move {
128+
let ws_url = format!("ws://localhost:{}", port);
129+
let from = 3u64;
130+
let to = 5u64;
131+
132+
fn execute_block_range(ws_url: &str, from: u64, to: u64) -> tokio::process::Child {
133+
Command::new(cargo_bin("try-runtime"))
134+
.stdout(std::process::Stdio::piped())
135+
.stderr(std::process::Stdio::piped())
136+
.arg("--runtime=existing")
137+
.args(["execute-block"])
138+
.args([format!("--from={}", from), format!("--to={}", to)])
139+
.args(["live", format!("--uri={}", ws_url).as_str()])
140+
.kill_on_drop(true)
141+
.spawn()
142+
.unwrap()
143+
}
144+
145+
let mut block_execution = execute_block_range(&ws_url, from, to);
146+
147+
// Expect the last block in the range to be successfully executed.
148+
let expected_output = format!(r#".*Block #{} successfully executed"#, to);
149+
let re = Regex::new(expected_output.as_str()).unwrap();
150+
let matched =
151+
common::wait_for_stream_pattern_match(block_execution.stderr.take().unwrap(), re).await;
152+
153+
// Assert that all blocks in the range were executed.
154+
assert!(matched.is_ok());
155+
156+
// Assert that the block-execution exited successfully.
157+
assert!(block_execution
158+
.wait_with_output()
159+
.await
160+
.unwrap()
161+
.status
162+
.success());
163+
})
124164
.await
125165
}

0 commit comments

Comments
 (0)