I have some code in a Substrate client that needs to call one of my runtime apis. I'd like an easy way to mock the client and custom runtime api functions to check that they're called.
Is there an easy way to mock both? I was trying out substrate-test-runtime but don't see a proper way to get it working, and am wondering if there's something better.
Here's a simplified example of a function that I would like to test looks like:
fn example_call<B, C>(
client: Arc<C>,
)
where
B: BlockT,
C: ProvideRuntimeApi<B> + HeaderBackend<B>,
C::Api: ConstructExtrinsicApi<B>,
{
let best_hash = client.info().best_hash;
client.runtime_api()
.my_arbitrary_runtime_api_fn(&generic::BlockId::Hash(best_hash));
}
mock_impl_runtime_apis
docs.rs/sp-api-proc-macro/latest/sp_api_proc_macro/…