mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +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:
@@ -30,8 +30,8 @@ use futures::{task::SpawnError, FutureExt, StreamExt};
|
||||
use jsonrpsee::{
|
||||
core::{async_trait, Error as JsonRpseeError, RpcResult},
|
||||
proc_macros::rpc,
|
||||
types::{error::CallError, ErrorObject},
|
||||
PendingSubscription,
|
||||
types::{error::CallError, ErrorObject, SubscriptionResult},
|
||||
SubscriptionSink,
|
||||
};
|
||||
use log::warn;
|
||||
|
||||
@@ -135,19 +135,18 @@ impl<Block> BeefyApiServer<notification::EncodedSignedCommitment, Block::Hash> f
|
||||
where
|
||||
Block: BlockT,
|
||||
{
|
||||
fn subscribe_justifications(&self, pending: PendingSubscription) {
|
||||
fn subscribe_justifications(&self, mut sink: SubscriptionSink) -> SubscriptionResult {
|
||||
let stream = self
|
||||
.signed_commitment_stream
|
||||
.subscribe()
|
||||
.map(|sc| notification::EncodedSignedCommitment::new::<Block>(sc));
|
||||
|
||||
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 latest_finalized(&self) -> RpcResult<Block::Hash> {
|
||||
@@ -197,9 +196,9 @@ mod tests {
|
||||
let (rpc, _) = setup_io_handler();
|
||||
let request = r#"{"jsonrpc":"2.0","method":"beefy_getFinalizedHead","params":[],"id":1}"#;
|
||||
let expected_response = r#"{"jsonrpc":"2.0","error":{"code":1,"message":"BEEFY RPC endpoint not ready"},"id":1}"#.to_string();
|
||||
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]
|
||||
@@ -229,8 +228,8 @@ mod tests {
|
||||
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(2);
|
||||
while std::time::Instant::now() < deadline {
|
||||
let (response, _) = io.raw_json_request(request).await.expect("RPC requests work");
|
||||
if response != not_ready {
|
||||
assert_eq!(response, expected);
|
||||
if response.result != not_ready {
|
||||
assert_eq!(response.result, expected);
|
||||
// Success
|
||||
return
|
||||
}
|
||||
@@ -260,7 +259,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_commitment() -> BeefySignedCommitment<Block> {
|
||||
|
||||
Reference in New Issue
Block a user