mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Use Subscription Manager from jsonrpc-pubsub: The Sequel (#6254)
* 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 * Use exact version for jsonrpc crates Doing this to make sure any updates in jsonrpc don't accidently trickle down to Polkadot. Co-authored-by: André Silva <andre.beat@gmail.com>
This commit is contained in:
@@ -31,7 +31,7 @@ use crate::testing::TaskExecutor;
|
||||
#[test]
|
||||
fn should_return_header() {
|
||||
let client = Arc::new(substrate_test_runtime_client::new());
|
||||
let api = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let api = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
assert_matches!(
|
||||
api.header(Some(client.genesis_hash()).into()).wait(),
|
||||
@@ -63,7 +63,7 @@ fn should_return_header() {
|
||||
#[test]
|
||||
fn should_return_a_block() {
|
||||
let mut client = Arc::new(substrate_test_runtime_client::new());
|
||||
let api = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let api = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
let block = client.new_block(Default::default()).unwrap().build().unwrap().block;
|
||||
let block_hash = block.hash();
|
||||
@@ -114,7 +114,7 @@ fn should_return_a_block() {
|
||||
#[test]
|
||||
fn should_return_block_hash() {
|
||||
let mut client = Arc::new(substrate_test_runtime_client::new());
|
||||
let api = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let api = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
assert_matches!(
|
||||
api.block_hash(None.into()),
|
||||
@@ -158,7 +158,7 @@ fn should_return_block_hash() {
|
||||
#[test]
|
||||
fn should_return_finalized_hash() {
|
||||
let mut client = Arc::new(substrate_test_runtime_client::new());
|
||||
let api = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let api = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
assert_matches!(
|
||||
api.finalized_head(),
|
||||
@@ -188,12 +188,15 @@ fn should_notify_about_latest_block() {
|
||||
|
||||
{
|
||||
let mut client = Arc::new(substrate_test_runtime_client::new());
|
||||
let api = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let api = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
api.subscribe_all_heads(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(_)))
|
||||
));
|
||||
|
||||
let block = client.new_block(Default::default()).unwrap().build().unwrap().block;
|
||||
client.import(BlockOrigin::Own, block).unwrap();
|
||||
@@ -215,12 +218,15 @@ fn should_notify_about_best_block() {
|
||||
|
||||
{
|
||||
let mut client = Arc::new(substrate_test_runtime_client::new());
|
||||
let api = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let api = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
api.subscribe_new_heads(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(_)))
|
||||
));
|
||||
|
||||
let block = client.new_block(Default::default()).unwrap().build().unwrap().block;
|
||||
client.import(BlockOrigin::Own, block).unwrap();
|
||||
@@ -242,12 +248,15 @@ fn should_notify_about_finalized_block() {
|
||||
|
||||
{
|
||||
let mut client = Arc::new(substrate_test_runtime_client::new());
|
||||
let api = new_full(client.clone(), Subscriptions::new(Arc::new(TaskExecutor)));
|
||||
let api = new_full(client.clone(), SubscriptionManager::new(Arc::new(TaskExecutor)));
|
||||
|
||||
api.subscribe_finalized_heads(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(_)))
|
||||
));
|
||||
|
||||
let block = client.new_block(Default::default()).unwrap().build().unwrap().block;
|
||||
client.import(BlockOrigin::Own, block).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user