Skip to content

Commit 9c580cc

Browse files
committed
split unit tests
1 parent 4f312aa commit 9c580cc

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/rpc/tungstenite_client/client.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,15 @@ mod tests {
235235
let address = "ws://127.0.0.1";
236236
let client = TungsteniteRpcClient::new_with_port(address, port, 1).unwrap();
237237

238-
let client2 = TungsteniteRpcClient::with_default_url(1);
238+
let expected_url = Url::parse("ws://127.0.0.1:9944").unwrap();
239+
assert_eq!(client.url, expected_url);
240+
}
241+
242+
#[test]
243+
fn client_with_default_url() {
244+
let expected_url = Url::parse("ws://127.0.0.1:9944").unwrap();
245+
let client = TungsteniteRpcClient::with_default_url(1);
239246

240-
assert_eq!(client.url, client2.url);
247+
assert_eq!(client.url, expected_url);
241248
}
242249
}

src/rpc/ws_client/client.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl WsRpcClient {
4040
/// Create a new client with the given url string.
4141
/// Example url input: "ws://127.0.0.1:9944"
4242
pub fn new(url: &str) -> Result<Self> {
43-
let url: Url = Url::parse(url)?;
43+
let url = Url::parse(url)?;
4444
Ok(Self { url })
4545
}
4646

@@ -152,8 +152,15 @@ mod tests {
152152
let address = "ws://127.0.0.1";
153153
let client = WsRpcClient::new_with_port(address, port).unwrap();
154154

155-
let client2 = WsRpcClient::with_default_url();
155+
let expected_url = Url::parse("ws://127.0.0.1:9944").unwrap();
156+
assert_eq!(client.url, expected_url);
157+
}
158+
159+
#[test]
160+
fn client_with_default_url() {
161+
let expected_url = Url::parse("ws://127.0.0.1:9944").unwrap();
162+
let client = WsRpcClient::with_default_url();
156163

157-
assert_eq!(client.url, client2.url);
164+
assert_eq!(client.url, expected_url);
158165
}
159166
}

0 commit comments

Comments
 (0)