mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 06:57:58 +00:00
Adds new execution strategy nativeElseWasm (#1546)
* fix: adds new execution strategy nativeElseWasm and replace nativeWhenPossible with it * feat: adds cmd line params for execution strategies * fix: uses of cmd line execution strategies * chore: remove white spaces * chore: remove println * chore: remove whitespace * fix: generating functions with context * feat: add function to generate with_context declarations * fix: add implementation for with_context function calls * fix: add execution context to call_api_at function * fix: making use of context to select strategy for block_builder * chore: cleaning up * fix: merging issues * fix tests * add wasm files * chore: small doc for context fields * chore: delete redundant docs * fix: use full path for ExecutionContext * fix: add context functions from inside fold_item_impl * chore: remove clone * fix: moving generative function to utils, remove unused imports * fix: add missing full path for ExecutionContext * fix: merge issues * update wasm files * fix: update to keep up with changes in master * chore: remove unused functions, clean up * fix test * fix grumbles * fix: add more tests * fix: some refactorings * feat: add execution strategy to call * chore: small improvements * fix: add message to panic * fix tests
This commit is contained in:
@@ -24,7 +24,7 @@ use runtime_primitives::{generic::BlockId, traits::ProvideRuntimeApi};
|
||||
use state_machine::ExecutionStrategy;
|
||||
|
||||
fn calling_function_with_strat(strat: ExecutionStrategy) {
|
||||
let client = test_client::new_with_api_execution_strat(strat);
|
||||
let client = test_client::new_with_execution_strategy(strat);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
|
||||
@@ -44,7 +44,7 @@ fn calling_wasm_runtime_function() {
|
||||
#[test]
|
||||
#[should_panic(expected = "Could not convert parameter `param` between node and runtime!")]
|
||||
fn calling_native_runtime_function_with_non_decodable_parameter() {
|
||||
let client = test_client::new_with_api_execution_strat(ExecutionStrategy::NativeWhenPossible);
|
||||
let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
runtime_api.fail_convert_parameter(&block_id, DecodeFails::new()).unwrap();
|
||||
@@ -53,7 +53,7 @@ fn calling_native_runtime_function_with_non_decodable_parameter() {
|
||||
#[test]
|
||||
#[should_panic(expected = "Could not convert return value from runtime to node!")]
|
||||
fn calling_native_runtime_function_with_non_decodable_return_value() {
|
||||
let client = test_client::new_with_api_execution_strat(ExecutionStrategy::NativeWhenPossible);
|
||||
let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
runtime_api.fail_convert_return_value(&block_id).unwrap();
|
||||
@@ -61,7 +61,7 @@ fn calling_native_runtime_function_with_non_decodable_return_value() {
|
||||
|
||||
#[test]
|
||||
fn calling_native_runtime_signature_changed_function() {
|
||||
let client = test_client::new_with_api_execution_strat(ExecutionStrategy::NativeWhenPossible);
|
||||
let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeWhenPossible);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
|
||||
@@ -70,7 +70,7 @@ fn calling_native_runtime_signature_changed_function() {
|
||||
|
||||
#[test]
|
||||
fn calling_wasm_runtime_signature_changed_old_function() {
|
||||
let client = test_client::new_with_api_execution_strat(ExecutionStrategy::AlwaysWasm);
|
||||
let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
|
||||
@@ -78,3 +78,36 @@ fn calling_wasm_runtime_signature_changed_old_function() {
|
||||
let res = runtime_api.function_signature_changed_before_version_2(&block_id).unwrap();
|
||||
assert_eq!(&res, &[1, 2]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calling_with_both_strategy_and_fail_on_wasm_should_return_error() {
|
||||
let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
assert!(runtime_api.fail_on_wasm(&block_id).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calling_with_both_strategy_and_fail_on_native_should_work() {
|
||||
let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
assert_eq!(runtime_api.fail_on_native(&block_id).unwrap(), 1);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn calling_with_native_else_wasm_and_faild_on_wasm_should_work() {
|
||||
let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeElseWasm);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
assert_eq!(runtime_api.fail_on_wasm(&block_id).unwrap(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn calling_with_native_else_wasm_and_fail_on_native_should_work() {
|
||||
let client = test_client::new_with_execution_strategy(ExecutionStrategy::NativeElseWasm);
|
||||
let runtime_api = client.runtime_api();
|
||||
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
|
||||
assert_eq!(runtime_api.fail_on_native(&block_id).unwrap(), 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user