1use sp_runtime::BuildStorage;
22pub use substrate_test_client::*;
24
25use node_cli::service::RuntimeExecutor;
27
28pub type Backend = sc_client_db::Backend<node_primitives::Block>;
30
31pub type Client = client::Client<
33 Backend,
34 client::LocalCallExecutor<node_primitives::Block, Backend, RuntimeExecutor>,
35 node_primitives::Block,
36 kitchensink_runtime::RuntimeApi,
37>;
38
39#[derive(Default)]
41pub struct GenesisParameters;
42
43impl substrate_test_client::GenesisInit for GenesisParameters {
44 fn genesis_storage(&self) -> Storage {
45 let mut storage = crate::genesis::config().build_storage().unwrap();
46 storage.top.insert(
47 sp_core::storage::well_known_keys::CODE.to_vec(),
48 kitchensink_runtime::wasm_binary_unwrap().into(),
49 );
50 storage
51 }
52}
53
54pub trait TestClientBuilderExt: Sized {
56 fn new() -> Self;
58
59 fn build(self) -> Client;
61}
62
63impl TestClientBuilderExt
64 for substrate_test_client::TestClientBuilder<
65 node_primitives::Block,
66 client::LocalCallExecutor<node_primitives::Block, Backend, RuntimeExecutor>,
67 Backend,
68 GenesisParameters,
69 >
70{
71 fn new() -> Self {
72 Self::default()
73 }
74 fn build(self) -> Client {
75 let executor = RuntimeExecutor::builder().build();
76 use sc_service::client::LocalCallExecutor;
77 use std::sync::Arc;
78 let executor = LocalCallExecutor::new(
79 self.backend().clone(),
80 executor.clone(),
81 Default::default(),
82 ExecutionExtensions::new(None, Arc::new(executor)),
83 )
84 .expect("Creates LocalCallExecutor");
85 self.build_with_executor(executor).0
86 }
87}