mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 06:08:03 +00:00
Use Subscription Manager from jsonrpc-pubsub (#6208)
* Bump jsonrpc pubsub, core, http, and ws Right now these are the packages which _need_ to be updated so I can just the latest `jsonrpc-pubsub` code. Once a release it cut upstream the rest of the dependencies should be updated as well. * Use jsonrpc-pubsub's SubscriptionManager This places sc-rpc-api::Subscriptions * Bump jsonrpc-core outside of sc-rpc-* * Update client/rpc tests Right now one of the `author` tests is failing, I need to think a bit about how best to fix it. * Remove Subscriptions manager There's no need for this implementation since we're using the one from `jsonrpc-pubsub` now * Fix author RPC test This test used to check for a numerial subscription ID, whereas now it uses a string based ID which is the default provided by `jsonrpc-pubsub`'s subscription manager. * Remove unused NumericIdProvider * Add missing bracket Removed one too many with that last one, lol * Bump `jsonrpc` to v14.2 There's an exception though. `jsonrpc-derive` cannot be bumped past v14.0.5 just yet since it has a dependency on `quote` pinned to v1.0.1. This means that at the moment it won't build on Substrate since it's using v1.0.3. * Track `jsonrpc-derive` master branch * Bump `quote` version to v1.0.6 * Bump `jsonrpc-derive` to v14.2.1 This includes support for `quote` v1.0.6
This commit is contained in:
@@ -55,7 +55,7 @@ fn should_return_storage() {
|
||||
.add_extra_child_storage(&child_info, KEY.to_vec(), CHILD_VALUE.to_vec())
|
||||
.build();
|
||||
let genesis_hash = client.genesis_hash();
|
||||
let (client, child) = new_full(Arc::new(client), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let (client, child) = new_full(Arc::new(client), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
let key = StorageKey(KEY.to_vec());
|
||||
|
||||
assert_eq!(
|
||||
@@ -90,7 +90,7 @@ fn should_return_child_storage() {
|
||||
.add_child_storage(&child_info, "key", vec![42_u8])
|
||||
.build());
|
||||
let genesis_hash = client.genesis_hash();
|
||||
let (_client, child) = new_full(client, Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let (_client, child) = new_full(client, SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
let child_key = prefixed_storage_key();
|
||||
let key = StorageKey(b"key".to_vec());
|
||||
|
||||
@@ -125,7 +125,7 @@ fn should_return_child_storage() {
|
||||
fn should_call_contract() {
|
||||
let client = Arc::new(substrate_test_runtime_client::new());
|
||||
let genesis_hash = client.genesis_hash();
|
||||
let (client, _child) = new_full(client, Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let (client, _child) = new_full(client, SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
assert_matches!(
|
||||
client.call("balanceOf".into(), Bytes(vec![1,2,3]), Some(genesis_hash).into()).wait(),
|
||||
@@ -139,12 +139,15 @@ fn should_notify_about_storage_changes() {
|
||||
|
||||
{
|
||||
let mut client = Arc::new(substrate_test_runtime_client::new());
|
||||
let (api, _child) = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let (api, _child) = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
api.subscribe_storage(Default::default(), subscriber, None.into());
|
||||
|
||||
// assert id assigned
|
||||
assert_eq!(executor::block_on(id.compat()), Ok(Ok(SubscriptionId::Number(1))));
|
||||
assert!(matches!(
|
||||
executor::block_on(id.compat()),
|
||||
Ok(Ok(SubscriptionId::String(_)))
|
||||
));
|
||||
|
||||
let mut builder = client.new_block(Default::default()).unwrap();
|
||||
builder.push_transfer(runtime::Transfer {
|
||||
@@ -170,7 +173,7 @@ fn should_send_initial_storage_changes_and_notifications() {
|
||||
|
||||
{
|
||||
let mut client = Arc::new(substrate_test_runtime_client::new());
|
||||
let (api, _child) = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let (api, _child) = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
let alice_balance_key = blake2_256(&runtime::system::balance_of_key(AccountKeyring::Alice.into()));
|
||||
|
||||
@@ -179,7 +182,10 @@ fn should_send_initial_storage_changes_and_notifications() {
|
||||
]).into());
|
||||
|
||||
// assert id assigned
|
||||
assert_eq!(executor::block_on(id.compat()), Ok(Ok(SubscriptionId::Number(1))));
|
||||
assert!(matches!(
|
||||
executor::block_on(id.compat()),
|
||||
Ok(Ok(SubscriptionId::String(_)))
|
||||
));
|
||||
|
||||
let mut builder = client.new_block(Default::default()).unwrap();
|
||||
builder.push_transfer(runtime::Transfer {
|
||||
@@ -205,7 +211,7 @@ fn should_send_initial_storage_changes_and_notifications() {
|
||||
#[test]
|
||||
fn should_query_storage() {
|
||||
fn run_tests(mut client: Arc<TestClient>, has_changes_trie_config: bool) {
|
||||
let (api, _child) = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let (api, _child) = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
let mut add_block = |nonce| {
|
||||
let mut builder = client.new_block(Default::default()).unwrap();
|
||||
@@ -422,7 +428,7 @@ fn should_split_ranges() {
|
||||
#[test]
|
||||
fn should_return_runtime_version() {
|
||||
let client = Arc::new(substrate_test_runtime_client::new());
|
||||
let (api, _child) = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let (api, _child) = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
let result = "{\"specName\":\"test\",\"implName\":\"parity-test\",\"authoringVersion\":1,\
|
||||
\"specVersion\":2,\"implVersion\":2,\"apis\":[[\"0xdf6acb689907609b\",3],\
|
||||
@@ -445,12 +451,16 @@ fn should_notify_on_runtime_version_initially() {
|
||||
|
||||
{
|
||||
let client = Arc::new(substrate_test_runtime_client::new());
|
||||
let (api, _child) = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let (api, _child) = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
api.subscribe_runtime_version(Default::default(), subscriber);
|
||||
|
||||
// assert id assigned
|
||||
assert_eq!(executor::block_on(id.compat()), Ok(Ok(SubscriptionId::Number(1))));
|
||||
assert!(matches!(
|
||||
executor::block_on(id.compat()),
|
||||
Ok(Ok(SubscriptionId::String(_)))
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
// assert initial version sent.
|
||||
|
||||
Reference in New Issue
Block a user