mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 21:21:11 +00:00
Remove sp_tasks::spawn API and related code + host functions (#12639)
* Remove `sp_tasks::spawn` API and related code
* Remove `RuntimeTasks::{spawn, join}` host functions
* remove unused
* Remove a few more tests that I forgot to remove
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -19,7 +19,6 @@ sp-io = { version = "6.0.0", default-features = false, features = ["improved_pan
|
||||
sp-runtime = { version = "6.0.0", default-features = false, path = "../../../primitives/runtime" }
|
||||
sp-sandbox = { version = "0.10.0-dev", default-features = false, path = "../../../primitives/sandbox" }
|
||||
sp-std = { version = "4.0.0", default-features = false, path = "../../../primitives/std" }
|
||||
sp-tasks = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/tasks" }
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
|
||||
@@ -32,5 +31,4 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-sandbox/std",
|
||||
"sp-std/std",
|
||||
"sp-tasks/std",
|
||||
]
|
||||
|
||||
@@ -318,24 +318,6 @@ sp_core::wasm_export_functions! {
|
||||
message_slice.copy_from_slice(test_message);
|
||||
}
|
||||
|
||||
fn test_spawn() {
|
||||
let data = vec![1u8, 2u8];
|
||||
let data_new = sp_tasks::spawn(tasks::incrementer, data).join();
|
||||
|
||||
assert_eq!(data_new, vec![2u8, 3u8]);
|
||||
}
|
||||
|
||||
fn test_nested_spawn() {
|
||||
let data = vec![7u8, 13u8];
|
||||
let data_new = sp_tasks::spawn(tasks::parallel_incrementer, data).join();
|
||||
|
||||
assert_eq!(data_new, vec![10u8, 16u8]);
|
||||
}
|
||||
|
||||
fn test_panic_in_spawned() {
|
||||
sp_tasks::spawn(tasks::panicker, vec![]).join();
|
||||
}
|
||||
|
||||
fn test_return_i8() -> i8 {
|
||||
-66
|
||||
}
|
||||
@@ -358,25 +340,6 @@ sp_core::wasm_export_functions! {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
mod tasks {
|
||||
use sp_std::prelude::*;
|
||||
|
||||
pub fn incrementer(data: Vec<u8>) -> Vec<u8> {
|
||||
data.into_iter().map(|v| v + 1).collect()
|
||||
}
|
||||
|
||||
pub fn panicker(_: Vec<u8>) -> Vec<u8> {
|
||||
panic!()
|
||||
}
|
||||
|
||||
pub fn parallel_incrementer(data: Vec<u8>) -> Vec<u8> {
|
||||
let first = data.into_iter().map(|v| v + 2).collect::<Vec<_>>();
|
||||
let second = sp_tasks::spawn(incrementer, first).join();
|
||||
second
|
||||
}
|
||||
}
|
||||
|
||||
/// A macro to define a test entrypoint for each available sandbox executor.
|
||||
macro_rules! wasm_export_sandbox_test_functions {
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user