mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
[RPC] Move runtime version from chain to state (#1243)
* Move runtimeVersion to state, add rudimentary test for subscription. * Bump to latest jsonrpc.
This commit is contained in:
committed by
Robert Habermeier
parent
6299b42a4d
commit
d28fda3d84
@@ -178,3 +178,39 @@ fn should_query_storage() {
|
||||
});
|
||||
assert_eq!(result.unwrap(), expected);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn should_return_runtime_version() {
|
||||
let core = ::tokio::runtime::Runtime::new().unwrap();
|
||||
|
||||
let client = Arc::new(test_client::new());
|
||||
let api = State::new(client.clone(), Subscriptions::new(core.executor()));
|
||||
|
||||
assert_matches!(
|
||||
api.runtime_version(None.into()),
|
||||
Ok(ref ver) if ver == &runtime::VERSION
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_notify_on_runtime_version_initially() {
|
||||
let mut core = ::tokio::runtime::Runtime::new().unwrap();
|
||||
let (subscriber, id, transport) = pubsub::Subscriber::new_test("test");
|
||||
|
||||
{
|
||||
let client = Arc::new(test_client::new());
|
||||
let api = State::new(client.clone(), Subscriptions::new(core.executor()));
|
||||
|
||||
api.subscribe_runtime_version(Default::default(), subscriber);
|
||||
|
||||
// assert id assigned
|
||||
assert_eq!(core.block_on(id), Ok(Ok(SubscriptionId::Number(1))));
|
||||
}
|
||||
|
||||
// assert initial version sent.
|
||||
let (notification, next) = core.block_on(transport.into_future()).unwrap();
|
||||
assert!(notification.is_some());
|
||||
// no more notifications on this channel
|
||||
assert_eq!(core.block_on(next.into_future()).unwrap().0, None);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user