Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tests and cleanup
  • Loading branch information
Will committed Nov 2, 2018
commit e20b64a1c4d2eee4d9d9a5ddfb781a62b846885c
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion subkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ rand = "0.4"
clap = { version = "~2.32", features = ["yaml"] }
num_cpus = "1.8.0"
pbr = "1.0.1"
ctrlc = "3.1.1"

[features]
bench = []
2 changes: 1 addition & 1 deletion subkey/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A key generation utility with vanity address support.
FLAGS:
-c, --case-sensitive Whether the patten case is important or not
-h, --help Prints help information
-p, --paranoiac Sacrifice speed for better randomness (\~7% slower)
-p, --paranoiac Sacrifice speed for better randomness
-V, --version Prints version information

OPTIONS:
Expand Down
1 change: 0 additions & 1 deletion subkey/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ extern crate test;
extern crate substrate_primitives;
extern crate rand;
extern crate num_cpus;
extern crate ctrlc;

#[macro_use]
extern crate clap;
Expand Down
30 changes: 22 additions & 8 deletions subkey/src/vanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,39 +216,39 @@ mod tests {
minscore: 75.0,
};

let score = calculate_score(&specs, "5jolkadotwHY5k9GpdTgpqs9xjuNvtv8EcwCFpEeyEf3KHim");
let score = calculate_score(&specs, "5jubstratewHY5k9GpdTgpqs9xjuNvtv8EcwCFpEeyEf3KHim");
assert!(score >= 100.0);
}

#[test]
fn test_score_100() {
let specs = KeySpecs {
desired_pattern: String::from("j"),
desired_pattern: String::from("Substrate"),
case_sensitive: true,
paranoiac: false,
minscore: 75.0,
};
let score = calculate_score(&specs, "5PolkadotwHY5k9GpdTgpqs9xjuNvtv8EcwCFpEeyEf3KHim");
let score = calculate_score(&specs, "5SubstratewHY5k9GpdTgpqs9xjuNvtv8EcwCFpEeyEf3KHim");
assert!(score >= 100.0);
}

#[test]
fn test_score_50() {
let specs = KeySpecs {
desired_pattern: String::from("Polkadot"),
desired_pattern: String::from("Substrate"),
case_sensitive: true,
paranoiac: false,
minscore: 75.0,
};

// ~50% for the position + ~50% for the size
assert!(calculate_score(&specs, "5PolkXXXXwHY5k9GpdTgpqs9xjuNvtv8EcwCFpEeyEf3KHim") >= 50.0);
assert!(calculate_score(&specs, "5SubstXXXwHY5k9GpdTgpqs9xjuNvtv8EcwCFpEeyEf3KHim") >= 50.0);
}

#[test]
fn test_score_0() {
let specs = KeySpecs {
desired_pattern: String::from("Polkadot"),
desired_pattern: String::from("Substrate"),
case_sensitive: true,
paranoiac: false,
minscore: 75.0,
Expand All @@ -260,16 +260,30 @@ mod tests {
#[cfg(feature = "bench")]
#[bench]
fn bench_paranoiac(b: &mut Bencher) {
let specs = KeySpecs {
desired_pattern: String::from("oo7"),
case_sensitive: false,
paranoiac: true,
minscore: 75.0,
};

b.iter(|| {
generate_key("abc", false, true, 75.0)
generate_key(&specs)
});
}

#[cfg(feature = "bench")]
#[bench]
fn bench_not_paranoiac(b: &mut Bencher) {
let specs = KeySpecs {
desired_pattern: String::from("oo7"),
case_sensitive: false,
paranoiac: false,
minscore: 75.0,
};

b.iter(|| {
generate_key("abc", false, false, 75.0)
generate_key(&specs)
});
}
}