Skip to content

Commit

Permalink
feat: upgrade clarinet to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
leahjlou committed Oct 1, 2024
1 parent 2b90547 commit eb4a51a
Showing 1 changed file with 29 additions and 51 deletions.
80 changes: 29 additions & 51 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,79 +561,57 @@ impl StacksDevnetApiK8sManager {
) -> Result<StacksV2InfoResponse, DevNetError> {
let client = HttpClient::new();
let url = get_service_url(namespace, StacksDevnetService::StacksBlockchain);
let port =
get_service_port(StacksDevnetService::StacksBlockchain, ServicePort::RPC).unwrap();
let port = get_service_port(StacksDevnetService::StacksBlockchain, ServicePort::RPC).unwrap();
let url = format!("http://{}:{}/v2/info", url, port);

let context = format!("NAMESPACE: {}", namespace);
self.ctx.try_log(|logger: &hiro_system_kit::Logger| {
slog::info!(
logger,
"requesting /v2/info route of stacks node {}",
context
)
slog::info!(logger, "requesting /v2/info route of stacks node {}", context)
});

match Uri::from_str(&url) {
Ok(uri) => match client.get(uri).await {
Ok(response) => match hyper::body::to_bytes(response.into_body()).await {
Ok(body) => match serde_json::from_slice::<StacksV2InfoResponse>(&body) {
Ok(config) => {
self.ctx.try_log(|logger: &hiro_system_kit::Logger| {
slog::info!(
logger,
"successfully requested /v2/info route of stacks node {}",
context
)
});
Ok(config)
}
Err(e) => {
let msg = format!(
"failed to parse response: {}, ERROR: {}",
context,
e.to_string()
);
self.ctx.try_log(|logger| slog::error!(logger, "{}", msg));
Err(DevNetError {
message: msg,
code: 500,
})
Ok(body) => {
let body_str = String::from_utf8_lossy(&body); // Log raw response body
self.ctx.try_log(|logger: &hiro_system_kit::Logger| {
slog::info!(logger, "Raw response body: {}", body_str);

Check warning on line 578 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L577-L578

Added lines #L577 - L578 were not covered by tests
});

match serde_json::from_slice::<StacksV2InfoResponse>(&body) {
Ok(config) => {
self.ctx.try_log(|logger: &hiro_system_kit::Logger| {
slog::info!(logger, "successfully requested /v2/info route of stacks node {}", context)

Check warning on line 584 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L581-L584

Added lines #L581 - L584 were not covered by tests
});
Ok(config)

Check warning on line 586 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L586

Added line #L586 was not covered by tests
}
Err(e) => {
let msg = format!("failed to parse response: {}, ERROR: {}", context, e.to_string());

Check warning on line 589 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L588-L589

Added lines #L588 - L589 were not covered by tests
self.ctx.try_log(|logger| slog::error!(logger, "{}", msg));
Err(DevNetError { message: msg, code: 500 })
}
}
},
}
Err(e) => {
let msg = format!(
"failed to parse response: {}, ERROR: {}",
context,
e.to_string()
);
let msg = format!("failed to parse response: {}, ERROR: {}", context, e.to_string());

Check warning on line 596 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L596

Added line #L596 was not covered by tests
self.ctx.try_log(|logger| slog::error!(logger, "{}", msg));
Err(DevNetError {
message: msg,
code: 500,
})
Err(DevNetError { message: msg, code: 500 })

Check warning on line 598 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L598

Added line #L598 was not covered by tests
}
},
Err(e) => {
let msg = format!(
"failed to query stacks node: {}, ERROR: {}",
context,
e.to_string()
);
let msg = format!("failed to query stacks node: {}, ERROR: {}", context, e.to_string());
self.ctx.try_log(|logger| slog::warn!(logger, "{}", msg));
Ok(StacksV2InfoResponse::default())
Ok(StacksV2InfoResponse::default()) // Default response on failure
}
},
Err(e) => {
let msg = format!("failed to parse url: {} ERROR: {}", context, e.to_string());
self.ctx.try_log(|logger| slog::error!(logger, "{}", msg));
Err(DevNetError {
message: msg,
code: 500,
})
Err(DevNetError { message: msg, code: 500 })

Check warning on line 610 in src/lib.rs

View check run for this annotation

Codecov / codecov/patch

src/lib.rs#L610

Added line #L610 was not covered by tests
}
}
}


pub async fn get_devnet_info(
&self,
Expand Down

0 comments on commit eb4a51a

Please sign in to comment.