Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
eca9f39
Fix test runner
dvdplm Aug 30, 2021
717d384
Impl Default for SubscriptionTaskExecutor
dvdplm Aug 30, 2021
a0caf97
Keep the minimul amount of code needed to compile tests
dvdplm Aug 30, 2021
7e96a5a
Re-instate `RpcSession` (for now)
dvdplm Aug 30, 2021
b980cc6
cleanup
dvdplm Aug 30, 2021
52b9c17
Port over RPC tests
dvdplm Aug 30, 2021
b995567
Add tokio
dvdplm Aug 30, 2021
d8fa4f0
No need to map CallError to CallError
dvdplm Aug 30, 2021
11b26f1
Port over system_ rpc tests
dvdplm Sep 6, 2021
3cc43c2
Make it compile
dvdplm Sep 6, 2021
5f66746
Use prost 0.8
dvdplm Sep 6, 2021
6d6c1ff
Use prost 0.8
dvdplm Sep 6, 2021
ca95c8b
Make it compile
dvdplm Sep 6, 2021
dc56989
Merge branch 'dp-jsonrpsee-integration-2' into dp-rpc-testing
dvdplm Sep 6, 2021
c45bff5
Ignore more failing tests
dvdplm Sep 6, 2021
dc8a2d0
Comment out WIP tests
dvdplm Sep 6, 2021
174cbdd
Update lockfile
dvdplm Sep 6, 2021
b1ff6a7
No more juggling tokio versions
dvdplm Sep 6, 2021
1a74a64
No more wait_for_stop ?
dvdplm Sep 6, 2021
0eda45a
Remove browser-testing
dvdplm Sep 6, 2021
cb1f907
Arguments must be arrays
dvdplm Sep 6, 2021
d65a931
Use same argument names
dvdplm Sep 6, 2021
391d547
Resolve todo: no wait_for_stop for WS server
dvdplm Sep 6, 2021
f58eedb
fmt
dvdplm Sep 6, 2021
a88917f
log
dvdplm Sep 7, 2021
f96f0b5
One test passes
dvdplm Sep 8, 2021
ea0ea2c
Merge branch 'dp-jsonrpsee-integration-2' into dp-rpc-testing
dvdplm Sep 20, 2021
3c88421
Comment out more tests that aren't ported
dvdplm Sep 21, 2021
e15e945
Comment out more tests
dvdplm Sep 21, 2021
4997ede
Merge branch 'dp-jsonrpsee-integration-2' into dp-rpc-testing
dvdplm Sep 21, 2021
91c14b4
Fix tests after merge
dvdplm Sep 21, 2021
4f2b2cd
Subscription test
dvdplm Sep 21, 2021
46a637f
Invalid nonce test
dvdplm Sep 21, 2021
2278968
Pending exts
dvdplm Sep 21, 2021
4856d37
WIP removeExtrinsic test
dvdplm Sep 21, 2021
d4c6a4d
Test remove_extrinsic
dvdplm Sep 22, 2021
b7a78c9
Make state test: should_return_storage work
jsdw Sep 22, 2021
832ce62
Merge branch 'dp-rpc-testing' of github.com:paritytech/substrate into…
jsdw Sep 22, 2021
075e613
Uncomment/fix the other non-subscription related state tests
jsdw Sep 22, 2021
19f39f6
test: author_insertKey
dvdplm Sep 22, 2021
27a789d
test: author_rotateKeys
dvdplm Sep 22, 2021
f30a8be
Get rest of state tests passing
jsdw Sep 22, 2021
3116aa1
Merge branch 'dp-rpc-testing' of github.com:paritytech/substrate into…
jsdw Sep 22, 2021
947750c
asyncify a little more
jsdw Sep 22, 2021
3759645
Add todo to note #msg change
jsdw Sep 22, 2021
06cb6f5
Crashing test for has_session_keys
dvdplm Sep 23, 2021
966f0db
Fix error conversion to avoid stack overflows
dvdplm Sep 23, 2021
a34a590
test author_hasKey
dvdplm Sep 23, 2021
1abd83f
Add two missing tests
dvdplm Sep 24, 2021
bacbf42
offchain rpc tests
dvdplm Sep 24, 2021
3030956
Address todos
dvdplm Sep 24, 2021
58c8808
fmt
dvdplm Sep 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Keep the minimul amount of code needed to compile tests
  • Loading branch information
dvdplm committed Aug 30, 2021
commit a0caf97fb5ec87eede819f5bcdfc5ba22e79400c
121 changes: 72 additions & 49 deletions test-utils/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ use std::{
pin::Pin,
sync::Arc,
};
use sc_service::RpcSession;
use serde::Deserialize;
use serde_json::Value;

/// Test client light database backend.
pub type LightBackend<Block> =
Expand Down Expand Up @@ -297,41 +300,38 @@ impl<Block: BlockT, D, Backend, G: GenesisInit>
}
}

// TODO: (dp) This is **not** dead code; used in polkadot and cumulus for testing. See https://github.com/paritytech/substrate/pull/9264
// We need a solution for this.

// /// The output of an RPC transaction.
// pub struct RpcTransactionOutput {
// /// The output string of the transaction if any.
// pub result: Option<String>,
// /// The session object.
// pub session: RpcSession,
// /// An async receiver if data will be returned via a callback.
// pub receiver: futures::channel::mpsc::UnboundedReceiver<String>,
// }

// impl std::fmt::Debug for RpcTransactionOutput {
// fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
// write!(f, "RpcTransactionOutput {{ result: {:?}, session, receiver }}", self.result)
// }
// }
// TODO: (dp) I don't think we actually need this but leaving for now.
/// The output of an RPC transaction.
pub struct RpcTransactionOutput {
/// The output string of the transaction if any.
pub result: Option<String>,
/// The session object.
pub session: RpcSession,
/// An async receiver if data will be returned via a callback.
pub receiver: futures::channel::mpsc::UnboundedReceiver<String>,
}

// /// An error for when the RPC call fails.
// #[derive(Deserialize, Debug)]
// pub struct RpcTransactionError {
// /// A Number that indicates the error type that occurred.
// pub code: i64,
// /// A String providing a short description of the error.
// pub message: String,
// /// A Primitive or Structured value that contains additional information about the error.
// pub data: Option<serde_json::Value>,
// }
impl std::fmt::Debug for RpcTransactionOutput {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "RpcTransactionOutput {{ result: {:?}, session, receiver }}", self.result)
}
}
/// An error for when the RPC call fails.
#[derive(Deserialize, Debug)]
pub struct RpcTransactionError {
/// A Number that indicates the error type that occurred.
pub code: i64,
/// A String providing a short description of the error.
pub message: String,
/// A Primitive or Structured value that contains additional information about the error.
pub data: Option<serde_json::Value>,
}

// impl std::fmt::Display for RpcTransactionError {
// fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
// std::fmt::Debug::fmt(self, f)
// }
// }
impl std::fmt::Display for RpcTransactionError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
std::fmt::Debug::fmt(self, f)
}
}

// /// An extension trait for `RpcHandlers`.
// pub trait RpcHandlersExt {
Expand Down Expand Up @@ -367,25 +367,48 @@ impl<Block: BlockT, D, Backend, G: GenesisInit>
// }
// }

// pub(crate) fn parse_rpc_result(
// result: Option<String>,
// session: RpcSession,
// receiver: futures::channel::mpsc::UnboundedReceiver<String>,
// ) -> Result<RpcTransactionOutput, RpcTransactionError> {
// if let Some(ref result) = result {
// let json: serde_json::Value =
// serde_json::from_str(result).expect("the result can only be a JSONRPC string; qed");
// let error = json.as_object().expect("JSON result is always an object; qed").get("error");

// if let Some(error) = error {
// return Err(serde_json::from_value(error.clone())
// .expect("the JSONRPC result's error is always valid; qed"))
// }
// /// The output of an RPC transaction.
// pub struct RpcTransactionOutput {
// /// The output string of the transaction if any.
// pub result: Option<String>,
// /// The session object.
// pub session: RpcSession,
// /// An async receiver if data will be returned via a callback.
// pub receiver: futures::channel::mpsc::UnboundedReceiver<String>,
// }
// impl std::fmt::Debug for RpcTransactionOutput {
// fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
// write!(f, "RpcTransactionOutput {{ result: {:?}, session, receiver }}", self.result)
// }
// }

// Ok(RpcTransactionOutput { result, session, receiver })
// /// bla bla
// #[derive(Deserialize, Debug)]
// pub struct RpcTransactionError {
// pub code: i64,
// pub message: String,
// pub data: Option<Value>,
// }

pub(crate) fn parse_rpc_result(
result: Option<String>,
session: RpcSession,
receiver: futures::channel::mpsc::UnboundedReceiver<String>,
) -> Result<RpcTransactionOutput, RpcTransactionError> {
if let Some(ref result) = result {
let json: serde_json::Value =
serde_json::from_str(result).expect("the result can only be a JSONRPC string; qed");
let error = json.as_object().expect("JSON result is always an object; qed").get("error");

if let Some(error) = error {
return Err(serde_json::from_value(error.clone())
.expect("the JSONRPC result's error is always valid; qed"))
}
}

Ok(RpcTransactionOutput { result, session, receiver })
}

/// An extension trait for `BlockchainEvents`.
pub trait BlockchainEventsExt<C, B>
where
Expand Down Expand Up @@ -433,7 +456,7 @@ mod tests {

(mem, rx)
}

// TODO: (dp) This test is testing the testing code. Seems pretty pointless to me.
#[test]
fn parses_error_properly() {
let (mem, rx) = create_session_and_receiver();
Expand Down