Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
93160d60
Commit
93160d60
authored
5 years ago
by
dvermd
Browse files
Options
Downloads
Patches
Plain Diff
[fix] conf:
#134
remove unwrap and deny its use
parent
1fc6292c
No related branches found
No related tags found
1 merge request
!244
Resolve "Reliability: remove all "unwrap()" and deny their use"
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.lock
+1
-0
1 addition, 0 deletions
Cargo.lock
lib/core/conf/Cargo.toml
+1
-0
1 addition, 0 deletions
lib/core/conf/Cargo.toml
lib/core/conf/src/keys.rs
+29
-18
29 additions, 18 deletions
lib/core/conf/src/keys.rs
lib/core/conf/src/lib.rs
+2
-0
2 additions, 0 deletions
lib/core/conf/src/lib.rs
with
33 additions
and
18 deletions
Cargo.lock
+
1
−
0
View file @
93160d60
...
@@ -1023,6 +1023,7 @@ dependencies = [
...
@@ -1023,6 +1023,7 @@ dependencies = [
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"unwrap 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
]
[[package]]
[[package]]
...
...
This diff is collapsed.
Click to expand it.
lib/core/conf/Cargo.toml
+
1
−
0
View file @
93160d60
...
@@ -22,5 +22,6 @@ rpassword = "4.0.3"
...
@@ -22,5 +22,6 @@ rpassword = "4.0.3"
serde
=
"1.0.*"
serde
=
"1.0.*"
serde_derive
=
"1.0.*"
serde_derive
=
"1.0.*"
serde_json
=
"1.0.*"
serde_json
=
"1.0.*"
unwrap
=
"1.2.1"
[features]
[features]
This diff is collapsed.
Click to expand it.
lib/core/conf/src/keys.rs
+
29
−
18
View file @
93160d60
...
@@ -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,15 +292,18 @@ mod tests {
...
@@ -284,15 +292,18 @@ 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
)
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
lib/core/conf/src/lib.rs
+
2
−
0
View file @
93160d60
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
//! Dunitrust configuration files properties module
//! Dunitrust configuration files properties module
#![deny(
#![deny(
clippy::option_unwrap_used,
clippy::result_unwrap_used,
missing_docs,
missing_docs,
missing_debug_implementations,
missing_debug_implementations,
missing_copy_implementations,
missing_copy_implementations,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment