-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0cb462
commit 0c327c9
Showing
6 changed files
with
343 additions
and
269 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ rand = "0.8" | |
serde_json = "1.0" | ||
itertools = "0.11.0" | ||
exitcode = "1.1.2" | ||
pipe = "0.4.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,93 @@ | ||
// use crate::inputs::{request_inputs, Config}; | ||
// use frost::Error; | ||
// use frost_ed25519 as frost; | ||
|
||
// #[test] | ||
// fn check_valid_input_for_signers() { | ||
// let config = Config { | ||
// min_signers: 2, | ||
// max_signers: 3, | ||
// secret: Vec::new(), | ||
// }; | ||
|
||
// let mut valid_input = "2\n3\n\n".as_bytes(); | ||
// let expected = request_inputs(&mut valid_input); | ||
|
||
// assert_eq!(expected, Ok(config)); | ||
// } | ||
|
||
// #[test] | ||
// fn return_error_if_min_participant_greater_than_max_participant() { | ||
// let mut invalid_input = "4\n3\n\n".as_bytes(); | ||
// let expected = request_inputs(&mut invalid_input); | ||
|
||
// assert_eq!(expected, Err(Error::InvalidMinSigners)); | ||
// } | ||
|
||
// #[test] | ||
// fn return_error_if_min_participant_is_less_than_2() { | ||
// let mut invalid_input = "1\n3\n\n".as_bytes(); | ||
// let expected = request_inputs(&mut invalid_input); | ||
|
||
// assert_eq!(expected, Err(Error::InvalidMinSigners)); | ||
// } | ||
|
||
// #[test] | ||
// fn return_error_if_max_participant_is_less_than_2() { | ||
// let mut invalid_input = "2\n1\n\n".as_bytes(); | ||
// let expected = request_inputs(&mut invalid_input); | ||
|
||
// assert_eq!(expected, Err(Error::InvalidMaxSigners)); | ||
// } | ||
|
||
// // Testing inclusion of secret input | ||
|
||
// #[test] | ||
// fn check_valid_input_with_secret() { | ||
// let mut valid_input = | ||
// "3\n6\n7b1c33d3f5291d85de664833beb1ad469f7fb6025a0ec78b3a790c6e13a98304\n".as_bytes(); | ||
// let config = request_inputs(&mut valid_input).unwrap(); | ||
|
||
// let secret: Vec<u8> = vec![ | ||
// 123, 28, 51, 211, 245, 41, 29, 133, 222, 102, 72, 51, 190, 177, 173, 70, 159, 127, 182, 2, | ||
// 90, 14, 199, 139, 58, 121, 12, 110, 19, 169, 131, 4, | ||
// ]; | ||
// let expected = Config { | ||
// min_signers: 3, | ||
// max_signers: 6, | ||
// secret, | ||
// }; | ||
|
||
// assert_eq!(expected, config) | ||
// } | ||
|
||
// #[test] | ||
// fn return_error_if_invalid_min_signers_input() { | ||
// let mut invalid_input = "hello\n6\n\n".as_bytes(); | ||
// let expected = request_inputs(&mut invalid_input); | ||
|
||
// assert_eq!(expected, Err(Error::InvalidMinSigners)) | ||
// } | ||
|
||
// #[test] | ||
// fn return_error_if_invalid_max_signers_input() { | ||
// let mut invalid_input = "4\nworld\n\n".as_bytes(); | ||
// let expected = request_inputs(&mut invalid_input); | ||
|
||
// assert_eq!(expected, Err(Error::InvalidMaxSigners)) | ||
// } | ||
|
||
// #[test] | ||
// fn return_malformed_signing_key_error_if_secret_is_invalid() { | ||
// let mut secret_input = "4\n6\nasecret\n".as_bytes(); | ||
// let expected = request_inputs(&mut secret_input); | ||
|
||
// assert_eq!(expected, Err(Error::MalformedSigningKey)) | ||
// } | ||
use std::io::BufWriter; | ||
|
||
use crate::inputs::{request_inputs, Config}; | ||
use frost::Error; | ||
use frost_ed25519 as frost; | ||
|
||
#[test] | ||
fn check_valid_input_for_signers() { | ||
let config = Config { | ||
min_signers: 2, | ||
max_signers: 3, | ||
identifier: 1u16.try_into().unwrap(), | ||
}; | ||
|
||
let mut buf = BufWriter::new(Vec::new()); | ||
let mut valid_input = "2\n3\n1\n".as_bytes(); | ||
let expected = request_inputs(&mut valid_input, &mut buf).unwrap(); | ||
|
||
assert_eq!(expected, config); | ||
} | ||
|
||
#[test] | ||
fn return_error_if_min_participant_greater_than_max_participant() { | ||
let mut invalid_input = "4\n3\n1\n".as_bytes(); | ||
let mut buf = BufWriter::new(Vec::new()); | ||
let expected = request_inputs(&mut invalid_input, &mut buf).unwrap_err(); | ||
|
||
assert_eq!( | ||
*expected.downcast::<Error>().unwrap(), | ||
Error::InvalidMinSigners | ||
); | ||
} | ||
|
||
#[test] | ||
fn return_error_if_min_participant_is_less_than_2() { | ||
let mut invalid_input = "1\n3\n1\n".as_bytes(); | ||
let mut buf = BufWriter::new(Vec::new()); | ||
let expected = request_inputs(&mut invalid_input, &mut buf).unwrap_err(); | ||
|
||
assert_eq!( | ||
*expected.downcast::<Error>().unwrap(), | ||
Error::InvalidMinSigners | ||
); | ||
} | ||
|
||
#[test] | ||
fn return_error_if_max_participant_is_less_than_2() { | ||
let mut invalid_input = "2\n1\n1\n".as_bytes(); | ||
let mut buf = BufWriter::new(Vec::new()); | ||
let expected = request_inputs(&mut invalid_input, &mut buf).unwrap_err(); | ||
|
||
assert_eq!( | ||
*expected.downcast::<Error>().unwrap(), | ||
Error::InvalidMaxSigners | ||
); | ||
} | ||
|
||
#[test] | ||
fn return_error_if_invalid_min_signers_input() { | ||
let mut invalid_input = "hello\n6\n1\n".as_bytes(); | ||
let mut buf = BufWriter::new(Vec::new()); | ||
let expected = request_inputs(&mut invalid_input, &mut buf).unwrap_err(); | ||
|
||
assert_eq!( | ||
*expected.downcast::<Error>().unwrap(), | ||
Error::InvalidMinSigners | ||
); | ||
} | ||
|
||
#[test] | ||
fn return_error_if_invalid_max_signers_input() { | ||
let mut invalid_input = "4\nworld\n1\n".as_bytes(); | ||
let mut buf = BufWriter::new(Vec::new()); | ||
let expected = request_inputs(&mut invalid_input, &mut buf).unwrap_err(); | ||
|
||
assert_eq!( | ||
*expected.downcast::<Error>().unwrap(), | ||
Error::InvalidMaxSigners | ||
); | ||
} | ||
|
||
#[test] | ||
fn return_malformed_identifier_error_if_identifier_invalid() { | ||
let mut invalid_input = "4\n6\nasecret\n".as_bytes(); | ||
let mut buf = BufWriter::new(Vec::new()); | ||
let expected = request_inputs(&mut invalid_input, &mut buf).unwrap_err(); | ||
|
||
println!("{:?}", expected); | ||
assert_eq!( | ||
*expected.downcast::<Error>().unwrap(), | ||
Error::MalformedIdentifier | ||
); | ||
} |
Oops, something went wrong.