mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
rpc: Update jsonrpsee v0.15.1 (#11939)
* Bump jsonrpsee to v0.15.1 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc-servers: Adjust RpcMiddleware to WS and HTTP traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/author: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/chain: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/state: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/finality-grandpa: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/beefy: Use `SubscriptionSink` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client: Extract RPC string result from queries Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply rust-fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix warnings Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/tests: Remove trailing comma Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Use `SubscriptionResult` for implementations Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Remove comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Delegate middleware calls to `RpcMiddleware` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Remove comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert Cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update Cargo.lock with minimal changes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Update imports for `SubscriptionResult` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply cargo fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc/tests: Submit raw json requests to validate DenyUnsafe Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -12,7 +12,7 @@ homepage = "https://substrate.io"
|
||||
[dependencies]
|
||||
finality-grandpa = { version = "0.16.0", features = ["derive-codec"] }
|
||||
futures = "0.3.16"
|
||||
jsonrpsee = { version = "0.14.0", features = ["server", "macros"] }
|
||||
jsonrpsee = { version = "0.15.1", features = ["server", "macros"] }
|
||||
log = "0.4.8"
|
||||
parity-scale-codec = { version = "3.0.0", features = ["derive"] }
|
||||
serde = { version = "1.0.105", features = ["derive"] }
|
||||
|
||||
@@ -26,7 +26,8 @@ use std::sync::Arc;
|
||||
use jsonrpsee::{
|
||||
core::{async_trait, RpcResult},
|
||||
proc_macros::rpc,
|
||||
PendingSubscription,
|
||||
types::SubscriptionResult,
|
||||
SubscriptionSink,
|
||||
};
|
||||
|
||||
mod error;
|
||||
@@ -102,7 +103,7 @@ where
|
||||
ReportedRoundStates::from(&self.authority_set, &self.voter_state).map_err(Into::into)
|
||||
}
|
||||
|
||||
fn subscribe_justifications(&self, pending: PendingSubscription) {
|
||||
fn subscribe_justifications(&self, mut sink: SubscriptionSink) -> SubscriptionResult {
|
||||
let stream = self.justification_stream.subscribe().map(
|
||||
|x: sc_finality_grandpa::GrandpaJustification<Block>| {
|
||||
JustificationNotification::from(x)
|
||||
@@ -110,12 +111,11 @@ where
|
||||
);
|
||||
|
||||
let fut = async move {
|
||||
if let Some(mut sink) = pending.accept() {
|
||||
sink.pipe_from_stream(stream).await;
|
||||
}
|
||||
sink.pipe_from_stream(stream).await;
|
||||
};
|
||||
|
||||
self.executor.spawn("substrate-rpc-subscription", Some("rpc"), fut.boxed());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn prove_finality(
|
||||
@@ -283,9 +283,9 @@ mod tests {
|
||||
let (rpc, _) = setup_io_handler(EmptyVoterState);
|
||||
let expected_response = r#"{"jsonrpc":"2.0","error":{"code":1,"message":"GRANDPA RPC endpoint not ready"},"id":0}"#.to_string();
|
||||
let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#;
|
||||
let (result, _) = rpc.raw_json_request(&request).await.unwrap();
|
||||
let (response, _) = rpc.raw_json_request(&request).await.unwrap();
|
||||
|
||||
assert_eq!(expected_response, result,);
|
||||
assert_eq!(expected_response, response.result);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -306,8 +306,8 @@ mod tests {
|
||||
},\"id\":0}".to_string();
|
||||
|
||||
let request = r#"{"jsonrpc":"2.0","method":"grandpa_roundState","params":[],"id":0}"#;
|
||||
let (result, _) = rpc.raw_json_request(&request).await.unwrap();
|
||||
assert_eq!(expected_response, result);
|
||||
let (response, _) = rpc.raw_json_request(&request).await.unwrap();
|
||||
assert_eq!(expected_response, response.result);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
@@ -328,7 +328,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let expected = r#"{"jsonrpc":"2.0","result":false,"id":1}"#;
|
||||
|
||||
assert_eq!(response, expected);
|
||||
assert_eq!(response.result, expected);
|
||||
}
|
||||
|
||||
fn create_justification() -> GrandpaJustification<Block> {
|
||||
|
||||
Reference in New Issue
Block a user