Unverified Commit 136f97e1 authored by Niklas Adolfsson's avatar Niklas Adolfsson
Browse files

Merge remote-tracking branch 'origin/master' into na-middleware

parents 7c296ca3 610f635a
Pipeline #200287 passed with stages
in 4 minutes and 40 seconds
......@@ -105,17 +105,14 @@ jobs:
toolchain: stable
override: true
- name: Install cargo-nextest
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-nextest
version: 0.9
- name: Rust Cache
uses: Swatinem/rust-cache@v1.4.0
- name: Cargo nextest
run: cargo nextest run --workspace
- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --workspace
tests_macos:
name: Run tests macos
......@@ -131,17 +128,14 @@ jobs:
toolchain: stable
override: true
- name: Install cargo-nextest
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-nextest
version: 0.9
- name: Rust Cache
uses: Swatinem/rust-cache@v1.4.0
- name: Cargo nextest
run: cargo nextest run --workspace
- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --workspace
tests_windows:
name: Run tests Windows
......@@ -157,17 +151,14 @@ jobs:
toolchain: stable
override: true
- name: Install cargo-nextest
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-nextest
version: 0.9
- name: Rust Cache
uses: Swatinem/rust-cache@v1.4.0
- name: Cargo nextest
run: cargo nextest run --workspace
- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --workspace
wasm_tests:
name: Test wasm
......
......@@ -20,7 +20,7 @@ serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
tokio = { version = "1.16", features = ["time"] }
tracing = "0.1"
tracing = "0.1.34"
tracing-futures = "0.2.5"
[dev-dependencies]
......
......@@ -12,7 +12,7 @@ documentation = "https://docs.rs/jsonrpsee-ws-client"
[dependencies]
jsonrpsee-types = { path = "../../types", version = "0.14.0", optional = true }
jsonrpsee-core = { path = "../../core", version = "0.14.0", features = ["client"] }
tracing = "0.1"
tracing = "0.1.34"
# optional
thiserror = { version = "1", optional = true }
......
......@@ -16,7 +16,7 @@ thiserror = "1"
serde = { version = "1.0", default-features = false, features = ["derive"] }
serde_json = { version = "1", features = ["raw_value"] }
http = "0.2.7"
tracing = "0.1"
tracing = "0.1.34"
# optional deps
arrayvec = { version = "0.7.1", optional = true }
......
......@@ -10,7 +10,7 @@ publish = false
anyhow = "1"
futures = "0.3"
jsonrpsee = { path = "../jsonrpsee", features = ["full"] }
tracing = "0.1"
tracing = "0.1.34"
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }
tokio = { version = "1.16", features = ["full"] }
tokio-stream = { version = "0.1", features = ["sync"] }
......
......@@ -15,7 +15,7 @@ futures-channel = "0.3.14"
futures-util = { version = "0.3.14", default-features = false }
jsonrpsee-types = { path = "../types", version = "0.14.0" }
jsonrpsee-core = { path = "../core", version = "0.14.0", features = ["server", "http-helpers"] }
tracing = "0.1"
tracing = "0.1.34"
tracing-futures = "0.2.5"
serde_json = { version = "1.0", features = ["raw_value"] }
serde = "1"
......
......@@ -352,12 +352,23 @@ async fn invalid_request_object() {
let (addr, _handle) = server().with_default_timeout().await.unwrap();
let uri = to_http_uri(addr);
let req = r#"{"jsonrpc":"2.0","method":"bar","id":1,"is_not_request_object":1}"#;
let req = r#"{"method":"bar","id":1}"#;
let response = http_request(req.into(), uri).with_default_timeout().await.unwrap().unwrap();
assert_eq!(response.status, StatusCode::OK);
assert_eq!(response.body, invalid_request(Id::Num(1)));
}
#[tokio::test]
async fn unknown_field_is_ok() {
let (addr, _handle) = server().with_default_timeout().await.unwrap();
let uri = to_http_uri(addr);
let req = r#"{"jsonrpc":"2.0","method":"say_hello","id":1,"is_not_request_object":1}"#;
let response = http_request(req.into(), uri).with_default_timeout().await.unwrap().unwrap();
assert_eq!(response.status, StatusCode::OK);
assert_eq!(response.body, ok_response(JsonValue::String("lo".to_owned()), Id::Num(1)));
}
#[tokio::test]
async fn notif_works() {
let (addr, _handle) = server().with_default_timeout().await.unwrap();
......
......@@ -21,7 +21,7 @@ jsonrpsee-ws-server = { path = "../ws-server", version = "0.14.0", optional = tr
jsonrpsee-proc-macros = { path = "../proc-macros", version = "0.14.0", optional = true }
jsonrpsee-core = { path = "../core", version = "0.14.0", optional = true }
jsonrpsee-types = { path = "../types", version = "0.14.0", optional = true }
tracing = { version = "0.1", optional = true }
tracing = { version = "0.1.34", optional = true }
[features]
client-ws-transport = ["jsonrpsee-client-transport/ws", "jsonrpsee-client-transport/tls"]
......
......@@ -156,6 +156,7 @@ impl RpcDescription {
});
match param_kind {
ParamKind::Map => {
let jsonrpsee = self.jsonrpsee_client_path.as_ref().unwrap();
// Extract parameter names.
let param_names = extract_param_names(&signature.sig);
// Combine parameter names and values into tuples.
......@@ -165,7 +166,7 @@ impl RpcDescription {
quote! { (#param, #value) }
});
quote! {
Some(types::ParamsSer::Map(
Some(#jsonrpsee::types::ParamsSer::Map(
std::collections::BTreeMap::<&str, #serde_json::Value>::from(
[#(#params),*]
)
......
......@@ -12,7 +12,7 @@ anyhow = "1"
futures-channel = "0.3.14"
futures-util = "0.3.14"
hyper = { version = "0.14.10", features = ["full"] }
tracing = "0.1"
tracing = "0.1.34"
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = "1"
soketto = { version = "0.7.1", features = ["http"] }
......
......@@ -12,7 +12,7 @@ beef = { version = "0.5.1", features = ["impl_serde"] }
futures = { version = "0.3.14", default-features = false, features = ["std"] }
jsonrpsee = { path = "../jsonrpsee", features = ["full"] }
tokio = { version = "1.16", features = ["full"] }
tracing = "0.1"
tracing = "0.1.34"
serde = "1"
serde_json = "1"
hyper = { version = "0.14", features = ["http1", "client"] }
......
......@@ -12,7 +12,7 @@ documentation = "https://docs.rs/jsonrpsee-types"
[dependencies]
anyhow = "1"
beef = { version = "0.5.1", features = ["impl_serde"] }
tracing = { version = "0.1", default-features = false }
tracing = { version = "0.1.34", default-features = false }
serde = { version = "1", default-features = false, features = ["derive"] }
serde_json = { version = "1", default-features = false, features = ["alloc", "raw_value", "std"] }
thiserror = "1.0"
......@@ -34,7 +34,6 @@ use serde_json::value::RawValue;
/// JSON-RPC request object as defined in the [spec](https://www.jsonrpc.org/specification#request-object).
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct Request<'a> {
/// JSON-RPC version.
pub jsonrpc: TwoPointZero,
......@@ -67,7 +66,6 @@ pub struct InvalidRequest<'a> {
/// JSON-RPC notification (a request object without a request ID) as defined in the
/// [spec](https://www.jsonrpc.org/specification#request-object).
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct Notification<'a, T> {
/// JSON-RPC version.
pub jsonrpc: TwoPointZero,
......
......@@ -34,7 +34,6 @@ use serde::{Deserialize, Serialize};
/// JSON-RPC successful response object as defined in the [spec](https://www.jsonrpc.org/specification#response_object).
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct Response<'a, T> {
/// JSON-RPC version.
pub jsonrpc: TwoPointZero,
......
......@@ -14,7 +14,7 @@ futures-channel = "0.3.14"
futures-util = { version = "0.3.14", default-features = false, features = ["io", "async-await-macro"] }
jsonrpsee-types = { path = "../types", version = "0.14.0" }
jsonrpsee-core = { path = "../core", version = "0.14.0", features = ["server", "soketto"] }
tracing = "0.1"
tracing = "0.1.34"
serde_json = { version = "1", features = ["raw_value"] }
soketto = "0.7.1"
tokio = { version = "1.16", features = ["net", "rt-multi-thread", "macros", "time"] }
......
......@@ -499,11 +499,21 @@ async fn invalid_request_object() {
let addr = server().await;
let mut client = WebSocketTestClient::new(addr).with_default_timeout().await.unwrap().unwrap();
let req = r#"{"jsonrpc":"2.0","method":"bar","id":1,"is_not_request_object":1}"#;
let req = r#"{"method":"bar","id":1}"#;
let response = client.send_request_text(req).with_default_timeout().await.unwrap().unwrap();
assert_eq!(response, invalid_request(Id::Num(1)));
}
#[tokio::test]
async fn unknown_field_is_ok() {
let addr = server().await;
let mut client = WebSocketTestClient::new(addr).with_default_timeout().await.unwrap().unwrap();
let req = r#"{"jsonrpc":"2.0","method":"say_hello","id":1,"is_not_request_object":1}"#;
let response = client.send_request_text(req).with_default_timeout().await.unwrap().unwrap();
assert_eq!(response, ok_response(JsonValue::String("hello".to_owned()), Id::Num(1)));
}
#[tokio::test]
async fn register_methods_works() {
let mut module = RpcModule::new(());
......@@ -548,7 +558,7 @@ async fn invalid_request_should_not_close_connection() {
let addr = server().await;
let mut client = WebSocketTestClient::new(addr).with_default_timeout().await.unwrap().unwrap();
let req = r#"{"jsonrpc":"2.0","method":"bar","id":1,"is_not_request_object":1}"#;
let req = r#"{"method":"bar","id":1}"#;
let response = client.send_request_text(req).with_default_timeout().await.unwrap().unwrap();
assert_eq!(response, invalid_request(Id::Num(1)));
let request = r#"{"jsonrpc":"2.0","method":"say_hello","id":33}"#;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment