Skip to content

Commit 27b8ea4

Browse files
committed
Fix bootstrapping functional test failure on Windows
1 parent 375e5bd commit 27b8ea4

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

chainstate/src/rpc/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,13 @@ trait ChainstateRpc {
198198
#[method(name = "export_bootstrap_file")]
199199
async fn export_bootstrap_file(
200200
&self,
201-
file_path: &std::path::Path,
201+
file_path: std::path::PathBuf,
202202
include_stale_blocks: bool,
203203
) -> RpcResult<()>;
204204

205205
/// Imports a bootstrap file's blocks to this node
206206
#[method(name = "import_bootstrap_file")]
207-
async fn import_bootstrap_file(&self, file_path: &std::path::Path) -> RpcResult<()>;
207+
async fn import_bootstrap_file(&self, file_path: std::path::PathBuf) -> RpcResult<()>;
208208

209209
/// Return generic information about the chain, including the current best block, best block height and more.
210210
#[method(name = "info")]
@@ -516,18 +516,16 @@ impl ChainstateRpcServer for super::ChainstateHandle {
516516

517517
async fn export_bootstrap_file(
518518
&self,
519-
file_path: &std::path::Path,
519+
file_path: std::path::PathBuf,
520520
include_stale_blocks: bool,
521521
) -> RpcResult<()> {
522-
let file_path = file_path.to_owned();
523522
rpc::handle_result(
524523
self.call(move |this| export_bootstrap_file(this, &file_path, include_stale_blocks))
525524
.await,
526525
)
527526
}
528527

529-
async fn import_bootstrap_file(&self, file_path: &std::path::Path) -> RpcResult<()> {
530-
let file_path = file_path.to_owned();
528+
async fn import_bootstrap_file(&self, file_path: std::path::PathBuf) -> RpcResult<()> {
531529
rpc::handle_result(self.call_mut(move |this| import_bootstrap_file(this, &file_path)).await)
532530
}
533531

rpc/description/src/value_hint.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,13 @@ impl_value_hint!({
181181
NonZeroIsize => VH::NONZERO_NUMBER;
182182
NonZeroUsize => VH::NONZERO_NUMBER;
183183
String => VH::STRING;
184-
std::path::Path => VH::STRING;
184+
// Note: we implement `HasValueHint` for `PathBuf` but not for `Path`, because the latter
185+
// won't work if used as a parameter and a native Windows path is passed to it, producing
186+
// weird errors like:
187+
// jsonrpsee_core::proc_macros_support: Failed to parse JSON-RPC params as object: ErrorObject
188+
// { code: InvalidParams, message: "Invalid params", data: Some(RawValue("invalid type: string
189+
// \"C:\\\\aaa\\\\bbb\\\\file.txt\", expected a borrowed path at line 1 column xxx")) }
190+
std::path::PathBuf => VH::STRING;
185191
std::net::SocketAddr => VH::STRING;
186192
std::net::IpAddr => VH::STRING;
187193
std::net::Ipv4Addr => VH::STRING;

0 commit comments

Comments
 (0)