Skip to content

Commit

Permalink
refactor Unsupported error to take rpc & arg
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed Jul 19, 2023
1 parent e51c69c commit 671a78f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ pub trait RpcApi: Sized {
if self.version()? < 210000 {
// note: we allow Some(false) since it's the default behavior
if let Some(true) = descriptors {
return Err(Error::Unsupported);
return Err(Error::UnsupportedArgument("createwallet", "descriptors"));
}
// no descriptors argument yet
let mut args = [
Expand Down
8 changes: 4 additions & 4 deletions client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub enum Error {
UnexpectedStructure,
/// The daemon returned an error string.
ReturnedError(String),
/// Feature not supported by the connected bitcoin version.
Unsupported,
/// The {0} RPC does not support the {1} argument on the connected bitcoin version.
UnsupportedArgument(&'static str, &'static str),
}

impl From<jsonrpc::error::Error> for Error {
Expand Down Expand Up @@ -90,8 +90,8 @@ impl fmt::Display for Error {
Error::InvalidCookieFile => write!(f, "invalid cookie file"),
Error::UnexpectedStructure => write!(f, "the JSON result had an unexpected structure"),
Error::ReturnedError(ref s) => write!(f, "the daemon returned an error string: {}", s),
Error::Unsupported => {
write!(f, "the daemon version does not support the accessed feature")
Error::UnsupportedArgument(rpc, arg) => {
write!(f, "the daemon version does not support the {} argument for {}", arg, rpc)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ fn test_getblocktemplate(cl: &Client) {
}

fn test_unloadwallet(cl: &Client) {
cl.create_wallet("testunloadwallet", None, None, None, None).unwrap();
cl.create_wallet("testunloadwallet", None, None, None, None, None).unwrap();

let res = new_wallet_client("testunloadwallet")
.unload_wallet(None)
Expand All @@ -1303,7 +1303,7 @@ fn test_loadwallet(_: &Client) {
let wallet_client = new_wallet_client(wallet_name);

assert!(wallet_client.load_wallet(wallet_name).is_err());
wallet_client.create_wallet(wallet_name, None, None, None, None).unwrap();
wallet_client.create_wallet(wallet_name, None, None, None, None, None).unwrap();
assert!(wallet_client.load_wallet(wallet_name).is_err());
wallet_client.unload_wallet(None).unwrap();

Expand All @@ -1318,7 +1318,7 @@ fn test_backupwallet(_: &Client) {

assert!(wallet_client.backup_wallet(None).is_err());
assert!(wallet_client.backup_wallet(Some(&backup_path)).is_err());
wallet_client.create_wallet("testbackupwallet", None, None, None, None).unwrap();
wallet_client.create_wallet("testbackupwallet", None, None, None, None, None).unwrap();
assert!(wallet_client.backup_wallet(None).is_err());
assert!(wallet_client.backup_wallet(Some(&backup_path)).is_ok());
}
Expand Down

0 comments on commit 671a78f

Please sign in to comment.