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
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
9d64657f
Commit
9d64657f
authored
7 years ago
by
nanocryk
Browse files
Options
Downloads
Patches
Plain Diff
[enh] replace mut ref wots by a generator closure
parent
41cbf9db
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!26
Resolve "Improve WoT generic test by providing a generator function instead of multiple `&mut T: WebOfTrust`"
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
Cargo.lock
+1
-1
1 addition, 1 deletion
Cargo.lock
wotb/Cargo.toml
+1
-1
1 addition, 1 deletion
wotb/Cargo.toml
wotb/legacy.rs
+1
-28
1 addition, 28 deletions
wotb/legacy.rs
wotb/lib.rs
+8
-1
8 additions, 1 deletion
wotb/lib.rs
wotb/rusty.rs
+1
-3
1 addition, 3 deletions
wotb/rusty.rs
with
12 additions
and
34 deletions
Cargo.lock
+
1
−
1
View file @
9d64657f
...
@@ -107,7 +107,7 @@ dependencies = [
...
@@ -107,7 +107,7 @@ dependencies = [
[[package]]
[[package]]
name = "duniter-wotb"
name = "duniter-wotb"
version = "0.6.
1
"
version = "0.6.
2
"
dependencies = [
dependencies = [
"bincode 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
...
...
This diff is collapsed.
Click to expand it.
wotb/Cargo.toml
+
1
−
1
View file @
9d64657f
[package]
[package]
name
=
"duniter-wotb"
name
=
"duniter-wotb"
version
=
"0.6.
1
"
version
=
"0.6.
2
"
authors
=
[
"nanocryk <nanocryk@duniter.org>"
,
"elois <elois@duniter.org>"
]
authors
=
[
"nanocryk <nanocryk@duniter.org>"
,
"elois <elois@duniter.org>"
]
description
=
"Makes Web of Trust computations for the Duniter project."
description
=
"Makes Web of Trust computations for the Duniter project."
repository
=
"https://git.duniter.org/nodes/rust/duniter-rs"
repository
=
"https://git.duniter.org/nodes/rust/duniter-rs"
...
...
This diff is collapsed.
Click to expand it.
wotb/legacy.rs
+
1
−
28
View file @
9d64657f
...
@@ -553,33 +553,6 @@ mod tests {
...
@@ -553,33 +553,6 @@ mod tests {
/// This test is a translation of https://github.com/duniter/wotb/blob/master/tests/test.js
/// This test is a translation of https://github.com/duniter/wotb/blob/master/tests/test.js
#[test]
#[test]
fn
wot_tests
()
{
fn
wot_tests
()
{
let
mut
wot
=
LegacyWebOfTrust
::
new
(
3
);
generic_wot_test
(
LegacyWebOfTrust
::
new
);
let
mut
wot2
=
LegacyWebOfTrust
::
new
(
3
);
generic_wot_test
(
&
mut
wot
,
&
mut
wot2
);
// should be able to make a mem copy
{
let
wot2
=
wot
.clone
();
assert_eq!
(
wot
.size
(),
wot2
.size
());
assert_eq!
(
wot
.get_non_sentries
(
1
)
.len
(),
wot2
.get_non_sentries
(
1
)
.len
()
);
}
// serialization
assert_eq!
(
wot
.legacy_to_file
(
"test.wot"
),
true
);
// deserialization
{
let
wot2
=
LegacyWebOfTrust
::
legacy_from_file
(
"test.wot"
)
.unwrap
();
assert_eq!
(
wot
.size
(),
wot2
.size
());
assert_eq!
(
wot
.get_non_sentries
(
1
)
.len
(),
wot2
.get_non_sentries
(
1
)
.len
()
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
wotb/lib.rs
+
8
−
1
View file @
9d64657f
...
@@ -387,7 +387,12 @@ mod tests {
...
@@ -387,7 +387,12 @@ mod tests {
///
///
/// Clone and file tests are not included in this generic test and should be done in
/// Clone and file tests are not included in this generic test and should be done in
/// the implementation test.
/// the implementation test.
pub
fn
generic_wot_test
<
T
:
WebOfTrust
>
(
wot
:
&
mut
T
,
wot2
:
&
mut
T
)
{
pub
fn
generic_wot_test
<
T
:
WebOfTrust
,
F
>
(
generator
:
F
)
where
F
:
Fn
(
usize
)
->
T
,
{
let
mut
wot
=
generator
(
3
);
// should have an initial size of 0
// should have an initial size of 0
assert_eq!
(
wot
.size
(),
0
);
assert_eq!
(
wot
.size
(),
0
);
...
@@ -764,6 +769,8 @@ mod tests {
...
@@ -764,6 +769,8 @@ mod tests {
()
()
);
);
let
mut
wot2
=
generator
(
3
);
// Read wot from file
// Read wot from file
{
{
assert_eq!
(
assert_eq!
(
...
...
This diff is collapsed.
Click to expand it.
wotb/rusty.rs
+
1
−
3
View file @
9d64657f
...
@@ -316,8 +316,6 @@ mod tests {
...
@@ -316,8 +316,6 @@ mod tests {
#[test]
#[test]
fn
wot_tests
()
{
fn
wot_tests
()
{
let
mut
wot1
=
RustyWebOfTrust
::
new
(
3
);
generic_wot_test
(
RustyWebOfTrust
::
new
);
let
mut
wot2
=
RustyWebOfTrust
::
new
(
3
);
generic_wot_test
(
&
mut
wot1
,
&
mut
wot2
);
}
}
}
}
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