Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
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
Monitor
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
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
b5630b24
Commit
b5630b24
authored
5 months ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
Resolve "smithMembers.expiresOn is only growing" (
!305
)
* fix bug from
#276
* reveal bug from
#276
* fix an uncaught bug
parent
cc1f03f7
No related branches found
No related tags found
1 merge request
!305
Resolve "smithMembers.expiresOn is only growing"
Pipeline
#39516
passed
5 months ago
Stage: build
Stage: tests
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pallets/smith-members/src/lib.rs
+8
-5
8 additions, 5 deletions
pallets/smith-members/src/lib.rs
pallets/smith-members/src/tests.rs
+42
-0
42 additions, 0 deletions
pallets/smith-members/src/tests.rs
with
50 additions
and
5 deletions
pallets/smith-members/src/lib.rs
+
8
−
5
View file @
b5630b24
...
...
@@ -240,11 +240,14 @@ pub mod pallet {
received_certs
:
issuers_
,
},
);
// if smith is offline, schedule expire
if
!*
is_online
{
ExpiresOn
::
<
T
>
::
append
(
CurrentSession
::
<
T
>
::
get
()
+
T
::
SmithInactivityMaxDuration
::
get
(),
receiver
,
);
}
}
for
(
issuer
,
issued_certs
)
in
cert_meta_by_issuer
{
// Write CertsByIssuer
...
...
@@ -516,7 +519,7 @@ impl<T: Config> Pallet<T> {
/// Handle the removal of Smiths whose expiration time has been reached at a given session index.
fn
on_exclude_expired_smiths
(
at
:
SessionIndex
)
{
if
let
Some
(
smiths_to_remove
)
=
ExpiresOn
::
<
T
>
::
get
(
at
)
{
if
let
Some
(
smiths_to_remove
)
=
ExpiresOn
::
<
T
>
::
take
(
at
)
{
for
smith
in
smiths_to_remove
{
if
let
Some
(
smith_meta
)
=
Smiths
::
<
T
>
::
get
(
smith
)
{
if
let
Some
(
expires_on
)
=
smith_meta
.expires_on
{
...
...
This diff is collapsed.
Click to expand it.
pallets/smith-members/src/tests.rs
+
42
−
0
View file @
b5630b24
...
...
@@ -628,6 +628,48 @@ fn certifying_an_online_smith() {
});
}
/// Test that scheduled expiration is removed after session
#[test]
fn
expires_on_cleans_up
()
{
new_test_ext
(
GenesisConfig
{
initial_smiths
:
btreemap!
[
1
=>
(
true
,
vec!
[
2
,
3
]),
2
=>
(
true
,
vec!
[
1
,
3
]),
3
=>
(
true
,
vec!
[
1
,
2
]),
],
})
.execute_with
(||
{
// Alice goes offline, and is set to expire
Pallet
::
<
Runtime
>
::
on_smith_goes_offline
(
1
);
// The expiration block is present in smith data
assert_eq!
(
Smiths
::
<
Runtime
>
::
get
(
1
),
Some
(
SmithMeta
{
status
:
Smith
,
expires_on
:
Some
(
5
),
issued_certs
:
vec!
[
2
,
3
],
received_certs
:
vec!
[
2
,
3
]
})
);
// It is also present in ExpiresOn schedule
assert_eq!
(
ExpiresOn
::
<
Runtime
>
::
get
(
5
),
Some
(
vec!
[
1
]));
// Go to expiration session
Pallet
::
<
Runtime
>
::
on_new_session
(
5
);
// Alice is expired
assert_eq!
(
Smiths
::
<
Runtime
>
::
get
(
1
),
Some
(
SmithMeta
{
status
:
Excluded
,
expires_on
:
None
,
issued_certs
:
vec!
[
2
,
3
],
received_certs
:
vec!
[]
})
);
// ExpiresOn is clean
assert_eq!
(
ExpiresOn
::
<
Runtime
>
::
get
(
5
),
None
);
});
}
#[test]
fn
invitation_on_non_wot_member
()
{
new_test_ext
(
GenesisConfig
{
...
...
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