Skip to content

Commit

Permalink
rust reference impl: replace test vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra authored and roconnor-blockstream committed Mar 16, 2023
1 parent 0083f4d commit f5bc232
Showing 1 changed file with 53 additions and 47 deletions.
100 changes: 53 additions & 47 deletions reference/rust-codex32/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,22 +570,26 @@ mod tests {
#[test]
fn bip_invalid_bad_checksums() {
let bad_checksums = [
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxmazxdp4sx5q",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxq70v3y94304t",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxg4m2aylswft",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxght46zhq0x4",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxl8jqrdhvqkc4",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxepvjkxnc9wu",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxcakee32853f",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxx4nknfgj6u67a",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3n5n5gyweuvq3",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxjqllfg3pf3fv4",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxn0c66xf2j0kjn",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx63m45uj8ss4x8",
"ms10fauxsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxy4r708q7kg65x",
];
for chk in bad_checksums {
if let Err(Error::InvalidChecksum { .. }) = Codex32String::from_string(chk.into()) {
Expand All @@ -599,16 +603,16 @@ mod tests {
}

let wrong_checksums = [
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxx372x3mkc5m8sa0q",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxx82zvxjc02rt0vnl",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyc57nnpvpcnhggt",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxf9e2wxsusjgmlws",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxdpu39xl2lkru3g4",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxqelpaxwk0jz4e",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxncdn5kjxq7grt",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhq00y08vc7gjg",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcwm4re8fs78vn",
];
for chk in wrong_checksums {
let err = Codex32String::from_string(chk.into());
Expand All @@ -628,20 +632,20 @@ mod tests {
#[test]
fn bip_invalid_improper_length() {
let bad_length = [
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxx8ty2gx0n6rnaa",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxus2h522w7u6vq",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxc8d60uanwukvn",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxwaaaq5yk0vfeg",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxu9cfgk0a4muxaam",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzu2kdncfaew65ae",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxpsx45vtf9n2uk5h",
"ms12testxxxxxxxxxxxxxxxxxxxxxxxxxtn5jkk94ayuqc",
"ms12testxxxxxxxxxxxxxxxxxxxxxxxxxxvspjygypsrrkl",
"ms12testxxxxxxxxxxxxxxxxxxxxxxxxxxxxqmufxffdkzfac",
"ms12testxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmgr4z3c807ml7",
"ms12testxxxxxxxxxxxxxxxxxx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xarja5kqukdhy9",
"ms12fauxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxky0ua3ha84qk8",
"ms12fauxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx9eheesxadh2n2n9",
"ms12fauxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx9llwmgesfulcj2z",
"ms12fauxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx02ev7caq6n9fgkf",
];
for chk in bad_length {
let err = Codex32String::from_string(chk.into());
Expand All @@ -661,15 +665,15 @@ mod tests {
#[test]
fn bip_invalid_misc() {
if let Err(Error::InvalidShareIndex(..)) =
Codex32String::from_string("ms10testxxxxxxxxxxxxxxxxxxxxxxxxxxxx3wq9mzgrwag9".into())
Codex32String::from_string("ms10fauxxxxxxxxxxxxxxxxxxxxxxxxxxxx0z26tfn0ulw3p".into())
{
// ok
} else {
panic!("bad error, expected 'invalid share index'");
}

if let Err(Error::InvalidThreshold(..)) =
Codex32String::from_string("ms1testxxxxxxxxxxxxxxxxxxxxxxxxxxxxs9lz3we7s9wh4".into())
Codex32String::from_string("ms1fauxxxxxxxxxxxxxxxxxxxxxxxxxxxxxda3kr3s0s2swg".into())
{
// ok
} else {
Expand All @@ -683,11 +687,13 @@ mod tests {
#[test]
fn bip_invalid_case() {
let bad_case = [
"MS10testsxxxxxxxxxxxxxxxxxxxxxxxxxx4nzvca9cmczlw",
"ms10TESTsxxxxxxxxxxxxxxxxxxxxxxxxxx4nzvca9cmczlw",
"ms10testSxxxxxxxxxxxxxxxxxxxxxxxxxx4nzvca9cmczlw",
"ms10testsXXXXXXXXXXXXXXXXXXXXXXXXXX4nzvca9cmczlw",
"ms10testsxxxxxxxxxxxxxxxxxxxxxxxxxx4NZVCA9CMCZLW",
"Ms10fauxsxxxxxxxxxxxxxxxxxxxxxxxxxxuqxkk05lyf3x2",
"mS10fauxsxxxxxxxxxxxxxxxxxxxxxxxxxxuqxkk05lyf3x2",
"MS10fauxsxxxxxxxxxxxxxxxxxxxxxxxxxxuqxkk05lyf3x2",
"ms10FAUXsxxxxxxxxxxxxxxxxxxxxxxxxxxuqxkk05lyf3x2",
"ms10fauxSxxxxxxxxxxxxxxxxxxxxxxxxxxuqxkk05lyf3x2",
"ms10fauxsXXXXXXXXXXXXXXXXXXXXXXXXXXuqxkk05lyf3x2",
"ms10fauxsxxxxxxxxxxxxxxxxxxxxxxxxxxUQXKK05LYF3X2",
];
for chk in bad_case {
let err = Codex32String::from_string(chk.into());
Expand Down

0 comments on commit f5bc232

Please sign in to comment.