Skip to content

Commit 98b1b3f

Browse files
committed
chore: minor changes from code review
1 parent a29ff42 commit 98b1b3f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

testnet/stacks-node/src/event_dispatcher.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ fn handle_net_error(e: NetError, msg: &str) -> io::Error {
332332
}
333333

334334
/// Send an HTTP request to the given host:port. Returns the decoded response.
335-
/// Interanlly, this creates a socket, connects it, sends the HTTP request, and decodes the HTTP
335+
/// Internally, this creates a socket, connects it, sends the HTTP request, and decodes the HTTP
336336
/// response. It is a blocking operation.
337337
///
338338
/// If the request encounters a network error, then return an error. Don't retry.
@@ -425,7 +425,7 @@ pub fn send_request(
425425
})?;
426426

427427
// Step 3: load up the request with the message we're gonna send, and iteratively dump its
428-
// bytes from the handle into the socket (the connection does internall buffering and
428+
// bytes from the handle into the socket (the connection does internal buffering and
429429
// bookkeeping to deal with the cases where we fail to fill the socket buffer, or we can't send
430430
// anymore because the socket buffer is currently full).
431431
request
@@ -480,7 +480,7 @@ pub fn send_request(
480480
debug!("send_request(receiving data): drain inbox");
481481
connection.drain_inbox();
482482

483-
// see of we got a message that was fulfilled in our handle
483+
// see if we got a message that was fulfilled in our handle
484484
debug!("send_request(receiving data): try receive response");
485485
let rh = match request_handle.try_recv() {
486486
Ok(resp) => {
@@ -1928,15 +1928,14 @@ mod test {
19281928
}
19291929
}
19301930

1931-
fn start_mock_server(response: &str, client_done_signal: Receiver<()>) -> String {
1931+
fn start_mock_server(response: String, client_done_signal: Receiver<()>) -> String {
19321932
// Bind to an available port on localhost
19331933
let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind server");
19341934
let addr = listener.local_addr().unwrap();
19351935

19361936
debug!("Mock server listening on {}", addr);
19371937

19381938
// Start the server in a new thread
1939-
let response = response.to_string();
19401939
thread::spawn(move || {
19411940
for stream in listener.incoming() {
19421941
debug!("Mock server accepted connection");
@@ -1993,13 +1992,12 @@ mod test {
19931992

19941993
// Create a channel to signal when the client is done reading
19951994
let (tx_client_done, rx_client_done) = channel();
1996-
let server_addr = start_mock_server(mock_response, rx_client_done);
1995+
let server_addr = start_mock_server(mock_response.to_string(), rx_client_done);
19971996
let timeout_duration = Duration::from_secs(5);
19981997

1999-
let host = server_addr.split(':').collect::<Vec<&str>>()[0]; // Host part
2000-
let port = server_addr.split(':').collect::<Vec<&str>>()[1]
2001-
.parse()
2002-
.unwrap(); // Port part
1998+
let parts = server_addr.split(':').collect::<Vec<&str>>();
1999+
let host = parts[0];
2000+
let port = parts[1].parse().unwrap();
20032001

20042002
// Attempt to send a request to the mock server
20052003
let result = send_request(

0 commit comments

Comments
 (0)