Skip to content
Snippets Groups Projects

Resolve "Reliability: remove all "unwrap()" and deny their use"

Merged dvermd requested to merge dvermd/duniter-rs:134-remove-all-unwrap into dev
Compare and
77 files
+ 812
605
Compare changes
  • Side-by-side
  • Inline

Files

+ 29
18
@@ -16,8 +16,14 @@
@@ -16,8 +16,14 @@
//! Dunitrust keys configuration module
//! Dunitrust keys configuration module
#![deny(
#![deny(
missing_docs, missing_debug_implementations, missing_copy_implementations, trivial_casts,
missing_docs,
trivial_numeric_casts, unsafe_code, unstable_features, unused_import_braces,
missing_debug_implementations,
 
missing_copy_implementations,
 
trivial_casts,
 
trivial_numeric_casts,
 
unsafe_code,
 
unstable_features,
 
unused_import_braces,
unused_qualifications
unused_qualifications
)]
)]
@@ -169,6 +175,8 @@ pub fn key_wizard(mut key_pairs: DuniterKeyPairs) -> Result<DuniterKeyPairs, Wiz
@@ -169,6 +175,8 @@ pub fn key_wizard(mut key_pairs: DuniterKeyPairs) -> Result<DuniterKeyPairs, Wiz
mod tests {
mod tests {
use super::*;
use super::*;
 
use unwrap::unwrap;
 
static BASE58_SEED_INIT: &'static str = "4iXXx5GgRkZ85BVPwn8vFXvztdXAAa5yB573ErcAnngA";
static BASE58_SEED_INIT: &'static str = "4iXXx5GgRkZ85BVPwn8vFXvztdXAAa5yB573ErcAnngA";
static BASE58_PUB_INIT: &'static str = "otDgSpKvKAPPmE1MUYxc3UQ3RtEnKYz4iGD3BmwKPzM";
static BASE58_PUB_INIT: &'static str = "otDgSpKvKAPPmE1MUYxc3UQ3RtEnKYz4iGD3BmwKPzM";
//static SALT_INIT: &'static str = "initsalt";
//static SALT_INIT: &'static str = "initsalt";
@@ -207,21 +215,21 @@ mod tests {
@@ -207,21 +215,21 @@ mod tests {
// We expect member key to update as intended
// We expect member key to update as intended
assert_eq!(
assert_eq!(
result_key_pairs
unwrap!(
.member_keypair
result_key_pairs.member_keypair.clone(),
.clone()
"conf: member_keypair must have a value"
.unwrap()
.public_key(),
PubKey::Ed25519(
ed25519::PublicKey::from_base58(BASE58_PUB_TEST)
.expect("Wrong data in BASE58_PUB_TEST")
)
)
 
.public_key(),
 
PubKey::Ed25519(unwrap!(
 
ed25519::PublicKey::from_base58(BASE58_PUB_TEST),
 
"Wrong data in BASE58_PUB_TEST"
 
))
);
);
assert_eq!(
assert_eq!(
result_key_pairs
result_key_pairs
.member_keypair
.member_keypair
.clone()
.clone()
.unwrap()
.expect("conf: member_keypair must have a value")
.seed()
.seed()
.clone(),
.clone(),
Seed32::from_base58(BASE58_SEED_TEST).expect("Wrong data in BASE58_SEED_TEST"),
Seed32::from_base58(BASE58_SEED_TEST).expect("Wrong data in BASE58_SEED_TEST"),
@@ -284,16 +292,19 @@ mod tests {
@@ -284,16 +292,19 @@ mod tests {
);
);
assert_ne!(
assert_ne!(
result_key_pairs.network_keypair.seed().clone(),
result_key_pairs.network_keypair.seed().clone(),
Seed32::from_base58(BASE58_SEED_INIT).expect("Wrong data in BASE58_SEED_TEST")
unwrap!(
 
Seed32::from_base58(BASE58_SEED_INIT),
 
"Wrong data in BASE58_SEED_TEST"
 
)
);
);
// We expect member key not to change
// We expect member key not to change
assert_eq!(
assert_eq!(
result_key_pairs
unwrap!(
.member_keypair
result_key_pairs.member_keypair.clone(),
.clone()
"conf: result_keypair must have a value"
.unwrap()
)
.public_key(),
.public_key(),
PubKey::Ed25519(
PubKey::Ed25519(
ed25519::PublicKey::from_base58(BASE58_PUB_INIT)
ed25519::PublicKey::from_base58(BASE58_PUB_INIT)
.expect("Wrong data in BASE58_PUB_TEST")
.expect("Wrong data in BASE58_PUB_TEST")
@@ -303,7 +314,7 @@ mod tests {
@@ -303,7 +314,7 @@ mod tests {
result_key_pairs
result_key_pairs
.member_keypair
.member_keypair
.clone()
.clone()
.unwrap()
.expect("conf: result_keypair must have a value")
.seed()
.seed()
.clone(),
.clone(),
Seed32::from_base58(BASE58_SEED_INIT).expect("Wrong data in BASE58_SEED_TEST")
Seed32::from_base58(BASE58_SEED_INIT).expect("Wrong data in BASE58_SEED_TEST")
Loading