Skip to content

Commit

Permalink
fix clippy, bump wasm dependencies (#624)
Browse files Browse the repository at this point in the history
* fix clippy, bump wasm dependencies

* gate wasm test with cfg target
  • Loading branch information
biryukovmaxim authored Jan 23, 2025
1 parent 47c1059 commit b6b344e
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 52 deletions.
65 changes: 26 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ tonic = { version = "0.12.3", features = ["tls-webpki-roots", "gzip", "transport
tonic-build = { version = "0.12.3", features = ["prost"] }
triggered = "0.1.2"
uuid = { version = "1.5.0", features = ["v4", "fast-rng", "serde"] }
wasm-bindgen = { version = "0.2.93", features = ["serde-serialize"] }
wasm-bindgen = { version = "0.2.100", features = ["serde-serialize"] }
wasm-bindgen-futures = "0.4.43"
wasm-bindgen-test = "0.3.43"
wasm-bindgen-test = "0.3.50"
web-sys = "0.3.70"
xxhash-rust = { version = "0.8.7", features = ["xxh3"] }
zeroize = { version = "1.6.0", default-features = false, features = ["alloc"] }
Expand Down
2 changes: 1 addition & 1 deletion cli/src/modules/guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ impl Guide {

let mut paras = Vec::<String>::new();
let mut para = String::new();
let regex = Regex::new(r"\s+").unwrap();
for line in lines {
if line.trim().is_empty() {
if !para.is_empty() {
let regex = Regex::new(r"\s+").unwrap();
let text = regex.replace_all(para.trim(), " ");
paras.push(text.to_string());
para.clear();
Expand Down
8 changes: 8 additions & 0 deletions consensus/core/src/tx/script_public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ impl TryCastFromJs for ScriptPublicKey {
#[cfg(test)]
mod tests {
use super::*;
#[cfg(target_arch = "wasm32")]
use js_sys::Object;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::__rt::IntoJsResult;

#[test]
Expand Down Expand Up @@ -438,10 +440,14 @@ mod tests {
assert_eq!(spk, spk2);
}

#[cfg(target_arch = "wasm32")]
use wasm_bindgen::convert::IntoWasmAbi;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test;
#[cfg(target_arch = "wasm32")]
use workflow_wasm::serde::{from_value, to_value};

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen_test]
pub fn test_wasm_serde_constructor() {
let version = 0xc0de;
Expand All @@ -459,6 +465,7 @@ mod tests {
assert_eq!(JsValue::from_str("string"), spk_js.js_typeof());
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen_test]
pub fn test_wasm_serde_js_spk_object() {
let version = 0xc0de;
Expand All @@ -478,6 +485,7 @@ mod tests {
assert_eq!(spk, actual);
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen_test]
pub fn test_wasm_serde_spk_object() {
let version = 0xc0de;
Expand Down
7 changes: 7 additions & 0 deletions crypto/addresses/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,16 @@ mod tests {
// cspell:enable
}

#[cfg(target_arch = "wasm32")]
use js_sys::Object;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen::{JsValue, __rt::IntoJsResult};
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test;
#[cfg(target_arch = "wasm32")]
use workflow_wasm::{extensions::ObjectExtension, serde::from_value, serde::to_value};

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen_test]
pub fn test_wasm_serde_constructor() {
let str = "kaspa:qpauqsvk7yf9unexwmxsnmg547mhyga37csh0kj53q6xxgl24ydxjsgzthw5j";
Expand All @@ -654,6 +659,7 @@ mod tests {
assert_eq!(a, from_value(value).unwrap());
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen_test]
pub fn test_wasm_js_serde_object() {
let expected = Address::constructor("kaspa:qpauqsvk7yf9unexwmxsnmg547mhyga37csh0kj53q6xxgl24ydxjsgzthw5j");
Expand All @@ -678,6 +684,7 @@ mod tests {
assert_eq!(expected, actual);
}

#[cfg(target_arch = "wasm32")]
#[wasm_bindgen_test]
pub fn test_wasm_serde_object() {
use wasm_bindgen::convert::IntoWasmAbi;
Expand Down
5 changes: 1 addition & 4 deletions protocol/p2p/src/core/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,6 @@ fn match_for_io_error(err_status: &tonic::Status) -> Option<&std::io::Error> {
}
}

err = match err.source() {
Some(err) => err,
None => return None,
};
err = err.source()?;
}
}
5 changes: 1 addition & 4 deletions rpc/grpc/server/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,7 @@ fn match_for_io_error(err_status: &tonic::Status) -> Option<&std::io::Error> {
}
}

err = match err.source() {
Some(err) => err,
None => return None,
};
err = err.source()?;
}
}

Expand Down
2 changes: 1 addition & 1 deletion rpc/macros/src/wrpc/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl Parse for RpcSubscriptions {
impl ToTokens for RpcSubscriptions {
fn to_tokens(&self, tokens: &mut TokenStream) {
let mut targets = Vec::new();
let regex = Regex::new(r"^Notify").unwrap();

for handler in self.handlers.elems.iter() {
let (name, docs) = match handler {
Expand All @@ -146,7 +147,6 @@ impl ToTokens for RpcSubscriptions {
};

let name = format!("Notify{}", name.as_str());
let regex = Regex::new(r"^Notify").unwrap();
let blank = regex.replace(&name, "");
let subscribe = regex.replace(&name, "Subscribe");
let unsubscribe = regex.replace(&name, "Unsubscribe");
Expand Down
2 changes: 1 addition & 1 deletion wallet/bip32/src/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Prefix {
/// Validate that the given prefix string is well-formed.
// TODO(tarcieri): validate the string ends with `prv` or `pub`?
pub(crate) const fn validate_str(s: &str) -> crate::error::ResultConst<&str> {
if s.as_bytes().len() != Self::LENGTH {
if s.len() != Self::LENGTH {
return Err(crate::error::ErrorImpl::DecodeInvalidLength);
}

Expand Down

0 comments on commit b6b344e

Please sign in to comment.