Adding share_num field to errors.

This commit is contained in:
Frederic Jacobs
2016-12-20 23:10:47 +01:00
committed by GitHub
parent f5ab309dd6
commit ef4d525703
8 changed files with 250 additions and 119 deletions

View File

@ -3,14 +3,21 @@ extern crate rusty_secrets;
use rusty_secrets::recover_secret;
#[test]
#[should_panic(expected = "Not enough shares provided!")]
fn test_recover_sellibitze_no_shares() {
#[should_panic(expected = "No shares were provided.")]
fn test_recover_no_shares() {
let shares = vec![];
recover_secret(shares, false).unwrap();
}
#[test]
#[should_panic(expected = "Share parse error: Expected 3 parts separated by a minus sign")]
#[should_panic(expected = "No shares were provided.")]
fn test_recover_no_shares_signed() {
let shares = vec![];
recover_secret(shares, true).unwrap();
}
#[test]
#[should_panic(expected = "This share is incorrectly formatted.")]
fn test_recover_2_parts_share() {
let share1 = "2-1-CgmKQZHMO+5n5pU".to_string();
let share2 = "2-2".to_string();
@ -32,7 +39,7 @@ fn test_recover_incorrect_share_num() {
}
#[test]
#[should_panic(expected = "Share parse error: Illegal K,N parameters")]
#[should_panic(expected = "This share is incorrectly formatted.")]
fn test_recover_0_share_num() {
let share1 = "2-0-1YAYwmOHqZ69jA".to_string();
let share2 = "2-1-YJZQDGm22Y77Gw".to_string();
@ -43,7 +50,7 @@ fn test_recover_0_share_num() {
}
#[test]
#[should_panic(expected = "Share parse error: Base64 decoding of data block failed")]
#[should_panic(expected = "This share is incorrectly formatted.")]
fn test_recover_invalid_b64() {
let share1 = "2-1-CgnlCxRNtnkzENE".to_string();
let share2 = "2-1-YJZQDG((((m22Y)))77Gw".to_string();
@ -54,7 +61,7 @@ fn test_recover_invalid_b64() {
}
#[test]
#[should_panic(expected = "Duplicate Share Number")]
#[should_panic(expected = "This share number has already been used by a previous share.")]
fn test_recover_duplicate_shares_number() {
let share1 = "2-1-CgnlCxRNtnkzENE".to_string();
let share2 = "2-1-CgkAnUgP3lfwjyM".to_string();
@ -65,7 +72,7 @@ fn test_recover_duplicate_shares_number() {
}
#[test]
#[should_panic(expected = "Duplicate Share Data")]
#[should_panic(expected = "The data encoded in this share is the same as the one found in a previous share.")]
fn test_recover_duplicate_shares_data() {
let share1 = "2-1-CgnlCxRNtnkzENE".to_string();
let share2 = "2-2-CgnlCxRNtnkzENE".to_string();
@ -76,7 +83,7 @@ fn test_recover_duplicate_shares_data() {
}
#[test]
#[should_panic(expected = "Not enough shares provided!")]
#[should_panic(expected = "The number of shares provided is insufficient to recover the secret.")]
fn test_recover_too_few_shares() {
let share1 = "3-1-ChbcCdSZOaMn6DM1jFca2P6/0WRlP7AK".to_string();
let share2 = "3-2-ChbG46L1zRszs0PPn63XnnupmZTcgYJ3".to_string();