|
|
|
@ -19,7 +19,7 @@ where
|
|
|
|
|
let args = RawArguments::from_clap(&matches);
|
|
|
|
|
|
|
|
|
|
let json = args.json;
|
|
|
|
|
let timestamp = args.timestamp;
|
|
|
|
|
let disable_timestamp = args.disable_timestamp;
|
|
|
|
|
let testnet = args.testnet;
|
|
|
|
|
let config = args.config;
|
|
|
|
|
let command: RawCommand = args.cmd;
|
|
|
|
@ -28,7 +28,7 @@ where
|
|
|
|
|
RawCommand::Start { resume_only } => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::Start { resume_only },
|
|
|
|
@ -36,7 +36,7 @@ where
|
|
|
|
|
RawCommand::History => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::History,
|
|
|
|
@ -44,7 +44,7 @@ where
|
|
|
|
|
RawCommand::WithdrawBtc { amount, address } => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::WithdrawBtc {
|
|
|
|
@ -55,7 +55,7 @@ where
|
|
|
|
|
RawCommand::Balance => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::Balance,
|
|
|
|
@ -66,7 +66,7 @@ where
|
|
|
|
|
}) => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::Redeem {
|
|
|
|
@ -80,7 +80,7 @@ where
|
|
|
|
|
}) => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::Cancel { swap_id },
|
|
|
|
@ -90,7 +90,7 @@ where
|
|
|
|
|
}) => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::Refund { swap_id },
|
|
|
|
@ -100,7 +100,7 @@ where
|
|
|
|
|
}) => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::Punish { swap_id },
|
|
|
|
@ -108,7 +108,7 @@ where
|
|
|
|
|
RawCommand::ManualRecovery(ManualRecovery::SafelyAbort { swap_id }) => Arguments {
|
|
|
|
|
testnet,
|
|
|
|
|
json,
|
|
|
|
|
timestamp,
|
|
|
|
|
disable_timestamp,
|
|
|
|
|
config_path: config_path(config, testnet)?,
|
|
|
|
|
env_config: env_config(testnet),
|
|
|
|
|
cmd: Command::SafelyAbort { swap_id },
|
|
|
|
@ -168,7 +168,7 @@ pub struct BitcoinAddressNetworkMismatch {
|
|
|
|
|
pub struct Arguments {
|
|
|
|
|
pub testnet: bool,
|
|
|
|
|
pub json: bool,
|
|
|
|
|
pub timestamp: bool,
|
|
|
|
|
pub disable_timestamp: bool,
|
|
|
|
|
pub config_path: PathBuf,
|
|
|
|
|
pub env_config: env::Config,
|
|
|
|
|
pub cmd: Command,
|
|
|
|
@ -223,10 +223,10 @@ pub struct RawArguments {
|
|
|
|
|
|
|
|
|
|
#[structopt(
|
|
|
|
|
short,
|
|
|
|
|
long = "timestamp",
|
|
|
|
|
help = "Adds a timestamp to the log messages"
|
|
|
|
|
long = "disable-timestamp",
|
|
|
|
|
help = "Disable timestamping of log messages"
|
|
|
|
|
)]
|
|
|
|
|
pub timestamp: bool,
|
|
|
|
|
pub disable_timestamp: bool,
|
|
|
|
|
|
|
|
|
|
#[structopt(
|
|
|
|
|
long = "config",
|
|
|
|
@ -344,7 +344,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::Start { resume_only: false },
|
|
|
|
@ -362,7 +362,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::History,
|
|
|
|
@ -380,7 +380,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::Balance,
|
|
|
|
@ -402,7 +402,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::WithdrawBtc {
|
|
|
|
@ -429,7 +429,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::Cancel {
|
|
|
|
@ -455,7 +455,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::Refund {
|
|
|
|
@ -481,7 +481,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::Punish {
|
|
|
|
@ -507,7 +507,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::SafelyAbort {
|
|
|
|
@ -527,7 +527,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: true,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_testnet_conf_path,
|
|
|
|
|
env_config: testnet_env_config,
|
|
|
|
|
cmd: Command::Start { resume_only: false },
|
|
|
|
@ -545,7 +545,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: true,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_testnet_conf_path,
|
|
|
|
|
env_config: testnet_env_config,
|
|
|
|
|
cmd: Command::History,
|
|
|
|
@ -563,7 +563,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: true,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_testnet_conf_path,
|
|
|
|
|
env_config: testnet_env_config,
|
|
|
|
|
cmd: Command::Balance,
|
|
|
|
@ -587,7 +587,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: true,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_testnet_conf_path,
|
|
|
|
|
env_config: testnet_env_config,
|
|
|
|
|
cmd: Command::WithdrawBtc {
|
|
|
|
@ -614,7 +614,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: true,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_testnet_conf_path,
|
|
|
|
|
env_config: testnet_env_config,
|
|
|
|
|
cmd: Command::Cancel {
|
|
|
|
@ -641,7 +641,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: true,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_testnet_conf_path,
|
|
|
|
|
env_config: testnet_env_config,
|
|
|
|
|
cmd: Command::Refund {
|
|
|
|
@ -668,7 +668,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: true,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_testnet_conf_path,
|
|
|
|
|
env_config: testnet_env_config,
|
|
|
|
|
cmd: Command::Punish {
|
|
|
|
@ -695,7 +695,7 @@ mod tests {
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: true,
|
|
|
|
|
json: false,
|
|
|
|
|
timestamp: false,
|
|
|
|
|
disable_timestamp: false,
|
|
|
|
|
config_path: default_testnet_conf_path,
|
|
|
|
|
env_config: testnet_env_config,
|
|
|
|
|
cmd: Command::SafelyAbort {
|
|
|
|
@ -706,6 +706,24 @@ mod tests {
|
|
|
|
|
assert_eq!(expected_args, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn ensure_disable_timestamp_mapping() {
|
|
|
|
|
let default_mainnet_conf_path = env::Mainnet::getConfigFileDefaults().unwrap().config_path;
|
|
|
|
|
let mainnet_env_config = env::Mainnet::get_config();
|
|
|
|
|
|
|
|
|
|
let raw_ars = vec![BINARY_NAME, "--disable-timestamp", "start"];
|
|
|
|
|
let expected_args = Arguments {
|
|
|
|
|
testnet: false,
|
|
|
|
|
json: false,
|
|
|
|
|
disable_timestamp: true,
|
|
|
|
|
config_path: default_mainnet_conf_path,
|
|
|
|
|
env_config: mainnet_env_config,
|
|
|
|
|
cmd: Command::Start { resume_only: false },
|
|
|
|
|
};
|
|
|
|
|
let args = parse_args(raw_ars).unwrap();
|
|
|
|
|
assert_eq!(expected_args, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn given_user_provides_config_path_then_no_default_config_path_returned() {
|
|
|
|
|
let cp = PathBuf::from_str("/some/config/path").unwrap();
|
|
|
|
|