mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Better handling of stable-only build (#6569)
* Better handling of stable-only build * Fix node template build * Fix wasm builder node-template version mismatch * Fix load_spec error * Add , in parameter * Add descrptive panic messages in tests * Add descriptive tests in node/executor benches * Fix missing compact_code_unwrap * Add missing wasm_binary_unwrap function for executor integration test * Only define import_sp_io in no_std * Small Cargo.toml styling fix * Bump wasm-builder to 2.0.0 * Fix all `with_wasm_builder_from_crates` version in Substrate * Use `with_wasm_builder_from_crates` for node-template Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
@@ -22,8 +22,8 @@
|
||||
|
||||
use sp_runtime_interface::*;
|
||||
|
||||
use sp_runtime_interface_test_wasm::{WASM_BINARY, test_api::HostFunctions};
|
||||
use sp_runtime_interface_test_wasm_deprecated::WASM_BINARY as WASM_BINARY_DEPRECATED;
|
||||
use sp_runtime_interface_test_wasm::{wasm_binary_unwrap, test_api::HostFunctions};
|
||||
use sp_runtime_interface_test_wasm_deprecated::wasm_binary_unwrap as wasm_binary_deprecated_unwrap;
|
||||
|
||||
use sp_wasm_interface::HostFunctions as HostFunctionsT;
|
||||
use sc_executor::CallInWasm;
|
||||
@@ -64,17 +64,17 @@ fn call_wasm_method<HF: HostFunctionsT>(binary: &[u8], method: &str) -> TestExte
|
||||
|
||||
#[test]
|
||||
fn test_return_data() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_return_data");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_return_data");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_option_data() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_return_option_data");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_return_option_data");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_set_storage() {
|
||||
let mut ext = call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_set_storage");
|
||||
let mut ext = call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_set_storage");
|
||||
|
||||
let expected = "world";
|
||||
assert_eq!(expected.as_bytes(), &ext.ext().storage("hello".as_bytes()).unwrap()[..]);
|
||||
@@ -82,27 +82,27 @@ fn test_set_storage() {
|
||||
|
||||
#[test]
|
||||
fn test_return_value_into_mutable_reference() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_return_value_into_mutable_reference");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_return_value_into_mutable_reference");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_and_return_array() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_get_and_return_array");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_get_and_return_array");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_array_as_mutable_reference() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_array_as_mutable_reference");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_array_as_mutable_reference");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_return_input_public_key() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_return_input_public_key");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_return_input_public_key");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_function_not_found() {
|
||||
let err = call_wasm_method_with_result::<()>(&WASM_BINARY[..], "test_return_data").unwrap_err();
|
||||
let err = call_wasm_method_with_result::<()>(&wasm_binary_unwrap()[..], "test_return_data").unwrap_err();
|
||||
|
||||
assert!(err.contains("Instantiation: Export "));
|
||||
assert!(err.contains(" not found"));
|
||||
@@ -111,46 +111,46 @@ fn host_function_not_found() {
|
||||
#[test]
|
||||
#[should_panic(expected = "Invalid utf8 data provided")]
|
||||
fn test_invalid_utf8_data_should_return_an_error() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_invalid_utf8_data_should_return_an_error");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_invalid_utf8_data_should_return_an_error");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_overwrite_native_function_implementation() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_overwrite_native_function_implementation");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_overwrite_native_function_implementation");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_u128_i128_as_parameter_and_return_value() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_u128_i128_as_parameter_and_return_value");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_u128_i128_as_parameter_and_return_value");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vec_return_value_memory_is_freed() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_vec_return_value_memory_is_freed");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_vec_return_value_memory_is_freed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_encoded_return_value_memory_is_freed() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_encoded_return_value_memory_is_freed");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_encoded_return_value_memory_is_freed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_array_return_value_memory_is_freed() {
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_array_return_value_memory_is_freed");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_array_return_value_memory_is_freed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_versionining_with_new_host_works() {
|
||||
// We call to the new wasm binary with new host function.
|
||||
call_wasm_method::<HostFunctions>(
|
||||
&WASM_BINARY[..],
|
||||
&wasm_binary_unwrap()[..],
|
||||
"test_versionning_works",
|
||||
);
|
||||
|
||||
// we call to the old wasm binary with a new host functions
|
||||
// old versions of host functions should be called and test should be ok!
|
||||
call_wasm_method::<HostFunctions>(
|
||||
&WASM_BINARY_DEPRECATED[..],
|
||||
&wasm_binary_deprecated_unwrap()[..],
|
||||
"test_versionning_works",
|
||||
);
|
||||
}
|
||||
@@ -192,7 +192,7 @@ fn test_tracing() {
|
||||
let _guard = tracing::subscriber::set_default(subscriber.clone());
|
||||
|
||||
// Call some method to generate a trace
|
||||
call_wasm_method::<HostFunctions>(&WASM_BINARY[..], "test_return_data");
|
||||
call_wasm_method::<HostFunctions>(&wasm_binary_unwrap()[..], "test_return_data");
|
||||
|
||||
let inner = subscriber.0.lock().unwrap();
|
||||
assert!(inner.spans.contains("return_input_version_1"));
|
||||
|
||||
Reference in New Issue
Block a user