Merge pull request #7433 from paritytech/td-strict-config
Strict config parsing
This commit is contained in:
commit
51319ebe3f
@ -28,7 +28,7 @@ extern crate memory_cache;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
#[macro_use]
|
||||
#[cfg_attr(feature = "evm-debug", macro_use)]
|
||||
extern crate log;
|
||||
|
||||
#[cfg(feature = "jit")]
|
||||
|
@ -994,6 +994,7 @@ struct Config {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Operating {
|
||||
mode: Option<String>,
|
||||
mode_timeout: Option<u64>,
|
||||
@ -1013,6 +1014,7 @@ struct Operating {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Account {
|
||||
unlock: Option<Vec<String>>,
|
||||
password: Option<Vec<String>>,
|
||||
@ -1023,6 +1025,7 @@ struct Account {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Ui {
|
||||
force: Option<bool>,
|
||||
disable: Option<bool>,
|
||||
@ -1033,6 +1036,7 @@ struct Ui {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Network {
|
||||
warp: Option<bool>,
|
||||
port: Option<u16>,
|
||||
@ -1052,6 +1056,7 @@ struct Network {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Rpc {
|
||||
disable: Option<bool>,
|
||||
port: Option<u16>,
|
||||
@ -1064,6 +1069,7 @@ struct Rpc {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Ws {
|
||||
disable: Option<bool>,
|
||||
port: Option<u16>,
|
||||
@ -1074,6 +1080,7 @@ struct Ws {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Ipc {
|
||||
disable: Option<bool>,
|
||||
path: Option<String>,
|
||||
@ -1081,6 +1088,7 @@ struct Ipc {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Dapps {
|
||||
disable: Option<bool>,
|
||||
port: Option<u16>,
|
||||
@ -1093,6 +1101,7 @@ struct Dapps {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct SecretStore {
|
||||
disable: Option<bool>,
|
||||
disable_http: Option<bool>,
|
||||
@ -1109,6 +1118,7 @@ struct SecretStore {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Ipfs {
|
||||
enable: Option<bool>,
|
||||
port: Option<u16>,
|
||||
@ -1118,6 +1128,7 @@ struct Ipfs {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Mining {
|
||||
author: Option<String>,
|
||||
engine_signer: Option<String>,
|
||||
@ -1150,6 +1161,7 @@ struct Mining {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Stratum {
|
||||
interface: Option<String>,
|
||||
port: Option<u16>,
|
||||
@ -1157,6 +1169,7 @@ struct Stratum {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Footprint {
|
||||
tracing: Option<String>,
|
||||
pruning: Option<String>,
|
||||
@ -1175,16 +1188,19 @@ struct Footprint {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Snapshots {
|
||||
disable_periodic: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct VM {
|
||||
jit: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Misc {
|
||||
ntp_servers: Option<Vec<String>>,
|
||||
logging: Option<String>,
|
||||
@ -1195,6 +1211,7 @@ struct Misc {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
struct Whisper {
|
||||
enabled: Option<bool>,
|
||||
pool_size: Option<usize>,
|
||||
@ -1642,11 +1659,17 @@ mod tests {
|
||||
let config1 = Args::parse_config(include_str!("./tests/config.invalid1.toml"));
|
||||
let config2 = Args::parse_config(include_str!("./tests/config.invalid2.toml"));
|
||||
let config3 = Args::parse_config(include_str!("./tests/config.invalid3.toml"));
|
||||
let config4 = Args::parse_config(include_str!("./tests/config.invalid4.toml"));
|
||||
|
||||
match (config1, config2, config3) {
|
||||
(Err(ArgsError::Decode(_)), Err(ArgsError::Decode(_)), Err(ArgsError::Decode(_))) => {},
|
||||
(a, b, c) => {
|
||||
assert!(false, "Got invalid error types: {:?}, {:?}, {:?}", a, b, c);
|
||||
match (config1, config2, config3, config4) {
|
||||
(
|
||||
Err(ArgsError::Decode(_)),
|
||||
Err(ArgsError::Decode(_)),
|
||||
Err(ArgsError::Decode(_)),
|
||||
Err(ArgsError::Decode(_)),
|
||||
) => {},
|
||||
(a, b, c, d) => {
|
||||
assert!(false, "Got invalid error types: {:?}, {:?}, {:?}, {:?}", a, b, c, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
parity/cli/tests/config.invalid4.toml
Normal file
2
parity/cli/tests/config.invalid4.toml
Normal file
@ -0,0 +1,2 @@
|
||||
[account]
|
||||
invalid = 5
|
Loading…
Reference in New Issue
Block a user