Client::info() no longer returns a Result (#2776)

This commit is contained in:
Pierre Krieger
2019-06-04 16:09:46 +02:00
committed by Bastian Köcher
parent 53e8ad8728
commit 5df89a8a6f
33 changed files with 235 additions and 274 deletions
@@ -23,14 +23,14 @@ fn sr_api_benchmark(c: &mut Criterion) {
c.bench_function("add one with same runtime api", |b| {
let client = test_client::new();
let runtime_api = client.runtime_api();
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
let block_id = BlockId::Number(client.info().chain.best_number);
b.iter(|| runtime_api.benchmark_add_one(&block_id, &1))
});
c.bench_function("add one with recreating runtime api", |b| {
let client = test_client::new();
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
let block_id = BlockId::Number(client.info().chain.best_number);
b.iter(|| client.runtime_api().benchmark_add_one(&block_id, &1))
});
@@ -38,7 +38,7 @@ fn sr_api_benchmark(c: &mut Criterion) {
c.bench_function("vector add one with same runtime api", |b| {
let client = test_client::new();
let runtime_api = client.runtime_api();
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
let block_id = BlockId::Number(client.info().chain.best_number);
let data = vec![0; 1000];
b.iter_with_large_drop(|| runtime_api.benchmark_vector_add_one(&block_id, &data))
@@ -46,7 +46,7 @@ fn sr_api_benchmark(c: &mut Criterion) {
c.bench_function("vector add one with recreating runtime api", |b| {
let client = test_client::new();
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
let block_id = BlockId::Number(client.info().chain.best_number);
let data = vec![0; 1000];
b.iter_with_large_drop(|| client.runtime_api().benchmark_vector_add_one(&block_id, &data))
@@ -54,13 +54,13 @@ fn sr_api_benchmark(c: &mut Criterion) {
c.bench_function("calling function by function pointer in wasm", |b| {
let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm);
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
let block_id = BlockId::Number(client.info().chain.best_number);
b.iter(|| client.runtime_api().benchmark_indirect_call(&block_id).unwrap())
});
c.bench_function("calling function in wasm", |b| {
let client = test_client::new_with_execution_strategy(ExecutionStrategy::AlwaysWasm);
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
let block_id = BlockId::Number(client.info().chain.best_number);
b.iter(|| client.runtime_api().benchmark_direct_call(&block_id).unwrap())
});
}
@@ -34,7 +34,7 @@ use codec::Encode;
fn calling_function_with_strat(strat: ExecutionStrategy) {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert_eq!(runtime_api.benchmark_add_one(&block_id, &1).unwrap(), 2);
}
@@ -54,7 +54,7 @@ fn calling_wasm_runtime_function() {
fn calling_native_runtime_function_with_non_decodable_parameter() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
runtime_api.fail_convert_parameter(&block_id, DecodeFails::new()).unwrap();
}
@@ -63,7 +63,7 @@ fn calling_native_runtime_function_with_non_decodable_parameter() {
fn calling_native_runtime_function_with_non_decodable_return_value() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
runtime_api.fail_convert_return_value(&block_id).unwrap();
}
@@ -71,7 +71,7 @@ fn calling_native_runtime_function_with_non_decodable_return_value() {
fn calling_native_runtime_signature_changed_function() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert_eq!(runtime_api.function_signature_changed(&block_id).unwrap(), 1);
}
@@ -80,7 +80,7 @@ fn calling_native_runtime_signature_changed_function() {
fn calling_wasm_runtime_signature_changed_old_function() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
#[allow(deprecated)]
let res = runtime_api.function_signature_changed_before_version_2(&block_id).unwrap();
@@ -91,7 +91,7 @@ fn calling_wasm_runtime_signature_changed_old_function() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert!(runtime_api.fail_on_wasm(&block_id).is_err());
}
@@ -99,7 +99,7 @@ fn calling_with_both_strategy_and_fail_on_wasm_should_return_error() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert_eq!(runtime_api.fail_on_native(&block_id).unwrap(), 1);
}
@@ -108,7 +108,7 @@ fn calling_with_both_strategy_and_fail_on_native_should_work() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert_eq!(runtime_api.fail_on_wasm(&block_id).unwrap(), 1);
}
@@ -116,7 +116,7 @@ fn calling_with_native_else_wasm_and_faild_on_wasm_should_work() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert_eq!(runtime_api.fail_on_native(&block_id).unwrap(), 1);
}
@@ -124,7 +124,7 @@ fn calling_with_native_else_wasm_and_fail_on_native_should_work() {
fn use_trie_function() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert_eq!(runtime_api.use_trie(&block_id).unwrap(), 2);
}
@@ -132,7 +132,7 @@ fn use_trie_function() {
fn initialize_block_works() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert_eq!(runtime_api.get_block_number(&block_id).unwrap(), 1);
}
@@ -140,7 +140,7 @@ fn initialize_block_works() {
fn initialize_block_is_called_only_once() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert_eq!(runtime_api.take_block_number(&block_id).unwrap(), Some(1));
assert_eq!(runtime_api.take_block_number(&block_id).unwrap(), None);
}
@@ -149,7 +149,7 @@ fn initialize_block_is_called_only_once() {
fn initialize_block_is_skipped() {
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);
let block_id = BlockId::Number(client.info().chain.best_number);
assert!(runtime_api.without_initialize_block(&block_id).unwrap());
}
@@ -157,7 +157,7 @@ fn initialize_block_is_skipped() {
fn record_proof_works() {
let client = test_client::new_with_execution_strategy(ExecutionStrategy::Both);
let block_id = BlockId::Number(client.info().unwrap().chain.best_number);
let block_id = BlockId::Number(client.info().chain.best_number);
#[allow(deprecated)]
let storage_root = LongestChain::new(client.backend().clone(), client.import_lock())
.best_chain().unwrap().state_root().clone();