Validate inputs (#283)
This commit is contained in:
parent
5d4f19b0ed
commit
f179ff8421
|
@ -3,3 +3,5 @@
|
|||
A CLI demo for running trusted dealer key generation with FROST
|
||||
|
||||
This demo uses ed25519
|
||||
|
||||
https://crates.io/crates/frost-ed25519
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
use crate::inputs::{validate_inputs, Config};
|
||||
|
||||
#[test]
|
||||
fn check_valid_input_for_signers() {
|
||||
let config = Config {
|
||||
min_signers: 2,
|
||||
max_signers: 3,
|
||||
};
|
||||
|
||||
let expected = validate_inputs(&config);
|
||||
|
||||
assert_eq!(expected, Ok(config));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn return_error_if_min_participant_greater_than_max_participant() {
|
||||
let config = Config {
|
||||
min_signers: 4,
|
||||
max_signers: 3,
|
||||
};
|
||||
|
||||
let expected = validate_inputs(&config);
|
||||
|
||||
assert_eq!(expected, Err(frost_ed25519::Error::InvalidMinSigners));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn return_error_if_min_participant_is_less_than_2() {
|
||||
let config = Config {
|
||||
min_signers: 1,
|
||||
max_signers: 3,
|
||||
};
|
||||
|
||||
let expected = validate_inputs(&config);
|
||||
|
||||
assert_eq!(expected, Err(frost_ed25519::Error::InvalidMinSigners));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn return_error_if_max_participant_is_less_than_2() {
|
||||
let config = Config {
|
||||
min_signers: 2,
|
||||
max_signers: 1,
|
||||
};
|
||||
|
||||
let expected = validate_inputs(&config);
|
||||
|
||||
assert_eq!(expected, Err(frost_ed25519::Error::InvalidMaxSigners));
|
||||
}
|
Loading…
Reference in New Issue