Pass cli tests, remove compiler warnings
This commit is contained in:
parent
4e3f8bab10
commit
273d7c00c3
@ -506,6 +506,8 @@ mod tests {
|
|||||||
cmd_blocks: false,
|
cmd_blocks: false,
|
||||||
cmd_import: false,
|
cmd_import: false,
|
||||||
cmd_signer: false,
|
cmd_signer: false,
|
||||||
|
cmd_sign: false,
|
||||||
|
cmd_reject: false,
|
||||||
cmd_new_token: false,
|
cmd_new_token: false,
|
||||||
cmd_snapshot: false,
|
cmd_snapshot: false,
|
||||||
cmd_restore: false,
|
cmd_restore: false,
|
||||||
@ -516,6 +518,7 @@ mod tests {
|
|||||||
// Arguments
|
// Arguments
|
||||||
arg_pid_file: "".into(),
|
arg_pid_file: "".into(),
|
||||||
arg_file: None,
|
arg_file: None,
|
||||||
|
arg_id: None,
|
||||||
arg_path: vec![],
|
arg_path: vec![],
|
||||||
|
|
||||||
// -- Operating Options
|
// -- Operating Options
|
||||||
|
@ -16,10 +16,9 @@ use std::fs::File;
|
|||||||
use futures::Future;
|
use futures::Future;
|
||||||
|
|
||||||
fn sign_interactive(signer: &mut SignerRpc, pwd: &String, request: ConfirmationRequest)
|
fn sign_interactive(signer: &mut SignerRpc, pwd: &String, request: ConfirmationRequest)
|
||||||
-> Result<String, String>
|
|
||||||
{
|
{
|
||||||
print!("\n{}\nSign this transaction? (y)es/(N)o/(r)eject: ", request);
|
print!("\n{}\nSign this transaction? (y)es/(N)o/(r)eject: ", request);
|
||||||
stdout().flush();
|
let _ = stdout().flush();
|
||||||
match BufReader::new(stdin()).lines().next() {
|
match BufReader::new(stdin()).lines().next() {
|
||||||
Some(Ok(line)) => {
|
Some(Ok(line)) => {
|
||||||
match line.to_lowercase().chars().nth(0) {
|
match line.to_lowercase().chars().nth(0) {
|
||||||
@ -36,9 +35,8 @@ fn sign_interactive(signer: &mut SignerRpc, pwd: &String, request: ConfirmationR
|
|||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => return Err("Could not read from stdin".to_string())
|
_ => println!("Could not read from stdin")
|
||||||
}
|
}
|
||||||
Ok("Finished".to_string())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sign_transactions(signer: &mut SignerRpc, pwd: String) -> Result<String, String> {
|
fn sign_transactions(signer: &mut SignerRpc, pwd: String) -> Result<String, String> {
|
||||||
@ -49,7 +47,7 @@ fn sign_transactions(signer: &mut SignerRpc, pwd: String) -> Result<String, Stri
|
|||||||
Ok("No transactions in signing queue".to_string())
|
Ok("No transactions in signing queue".to_string())
|
||||||
} else {
|
} else {
|
||||||
for r in reqs {
|
for r in reqs {
|
||||||
sign_interactive(signer, &pwd, r);
|
sign_interactive(signer, &pwd, r)
|
||||||
}
|
}
|
||||||
Ok("".to_string())
|
Ok("".to_string())
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,6 @@ impl Handler for RpcHandler {
|
|||||||
match mem::replace(&mut self.complete, None) {
|
match mem::replace(&mut self.complete, None) {
|
||||||
Some(c) => c.complete(Ok(Rpc {
|
Some(c) => c.complete(Ok(Rpc {
|
||||||
out: mem::replace(&mut self.out, None).unwrap(),
|
out: mem::replace(&mut self.out, None).unwrap(),
|
||||||
auth_code: self.auth_code.clone(),
|
|
||||||
counter: AtomicUsize::new(0),
|
counter: AtomicUsize::new(0),
|
||||||
pending: self.pending.clone(),
|
pending: self.pending.clone(),
|
||||||
})),
|
})),
|
||||||
@ -138,7 +137,6 @@ pub struct Rpc {
|
|||||||
out: Sender,
|
out: Sender,
|
||||||
counter: AtomicUsize,
|
counter: AtomicUsize,
|
||||||
pending: Pending,
|
pending: Pending,
|
||||||
auth_code: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rpc {
|
impl Rpc {
|
||||||
|
@ -18,18 +18,18 @@ extern crate lazy_static;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate matches;
|
extern crate matches;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use url::Url;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use client::{Rpc, RpcError};
|
use client::{Rpc, RpcError};
|
||||||
|
|
||||||
use mock;
|
use mock::serve;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_connection_refused() {
|
fn test_connection_refused() {
|
||||||
let (srv, port, tmpdir, _) = mock::serve();
|
let (srv, port, tmpdir, _) = serve();
|
||||||
|
|
||||||
let mut path = PathBuf::from(tmpdir.path());
|
let mut path = PathBuf::from(tmpdir.path());
|
||||||
path.push("authcodes");
|
path.push("authcodes");
|
||||||
@ -44,7 +44,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_authcode_fail() {
|
fn test_authcode_fail() {
|
||||||
let (srv, port, _, _) = mock::serve();
|
let (srv, port, _, _) = serve();
|
||||||
let path = PathBuf::from("nonexist");
|
let path = PathBuf::from("nonexist");
|
||||||
|
|
||||||
let connect = Rpc::connect(&format!("ws://127.0.0.1:{}", port), &path);
|
let connect = Rpc::connect(&format!("ws://127.0.0.1:{}", port), &path);
|
||||||
@ -58,7 +58,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_authcode_correct() {
|
fn test_authcode_correct() {
|
||||||
let (srv, port, tmpdir, _) = mock::serve();
|
let (srv, port, tmpdir, _) = serve();
|
||||||
|
|
||||||
let mut path = PathBuf::from(tmpdir.path());
|
let mut path = PathBuf::from(tmpdir.path());
|
||||||
path.push("authcodes");
|
path.push("authcodes");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
use client::{Rpc, RpcError};
|
use client::{Rpc, RpcError};
|
||||||
use rpc::v1::types::{ConfirmationRequest,
|
use rpc::v1::types::{ConfirmationRequest,
|
||||||
ConfirmationPayload,
|
|
||||||
TransactionModification,
|
TransactionModification,
|
||||||
U256};
|
U256};
|
||||||
use serde_json::{Value as JsonValue, to_value};
|
use serde_json::{Value as JsonValue, to_value};
|
||||||
|
Loading…
Reference in New Issue
Block a user