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
a1cff7e3
Commit
a1cff7e3
authored
1 year ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
feat(
#173
): add SmithCertificationRemoved event
parent
515e5b8b
No related branches found
No related tags found
1 merge request
!228
Resolve "Améliorations pour smith-members"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pallets/smith-members/src/lib.rs
+11
-2
11 additions, 2 deletions
pallets/smith-members/src/lib.rs
pallets/smith-members/src/tests.rs
+48
-0
48 additions, 0 deletions
pallets/smith-members/src/tests.rs
runtime/gdev/tests/integration_tests.rs
+12
-0
12 additions, 0 deletions
runtime/gdev/tests/integration_tests.rs
with
71 additions
and
2 deletions
pallets/smith-members/src/lib.rs
+
11
−
2
View file @
a1cff7e3
...
@@ -140,6 +140,11 @@ pub mod pallet {
...
@@ -140,6 +140,11 @@ pub mod pallet {
idty_index
:
T
::
IdtyIndex
,
idty_index
:
T
::
IdtyIndex
,
issued_by
:
T
::
IdtyIndex
,
issued_by
:
T
::
IdtyIndex
,
},
},
/// Certification lost
SmithCertificationRemoved
{
idty_index
:
T
::
IdtyIndex
,
issued_by
:
T
::
IdtyIndex
,
},
/// A smith gathered enough certifications to become an authority (can call `go_online()`).
/// A smith gathered enough certifications to become an authority (can call `go_online()`).
PromotedToSmith
{
idty_index
:
T
::
IdtyIndex
},
PromotedToSmith
{
idty_index
:
T
::
IdtyIndex
},
/// A smith has been removed from the smiths set.
/// A smith has been removed from the smiths set.
...
@@ -493,11 +498,15 @@ impl<T: Config> Pallet<T> {
...
@@ -493,11 +498,15 @@ impl<T: Config> Pallet<T> {
}
}
});
});
// We remove the lost certs from their issuer's stock
// We remove the lost certs from their issuer's stock
for
lost_cert
in
lost_certs
{
for
lost_cert
_issuer
in
lost_certs
{
Smiths
::
<
T
>
::
mutate
(
lost_cert
,
|
maybe_smith_meta
|
{
Smiths
::
<
T
>
::
mutate
(
lost_cert
_issuer
,
|
maybe_smith_meta
|
{
if
let
Some
(
smith_meta
)
=
maybe_smith_meta
{
if
let
Some
(
smith_meta
)
=
maybe_smith_meta
{
if
let
Ok
(
index
)
=
smith_meta
.issued_certs
.binary_search
(
&
idty_index
)
{
if
let
Ok
(
index
)
=
smith_meta
.issued_certs
.binary_search
(
&
idty_index
)
{
smith_meta
.issued_certs
.remove
(
index
);
smith_meta
.issued_certs
.remove
(
index
);
Self
::
deposit_event
(
Event
::
<
T
>
::
SmithCertificationRemoved
{
idty_index
,
issued_by
:
lost_cert_issuer
,
});
}
}
}
}
});
});
...
...
This diff is collapsed.
Click to expand it.
pallets/smith-members/src/tests.rs
+
48
−
0
View file @
a1cff7e3
...
@@ -123,12 +123,60 @@ fn process_to_become_a_smith_and_lose_it() {
...
@@ -123,12 +123,60 @@ fn process_to_become_a_smith_and_lose_it() {
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithExcluded
{
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithExcluded
{
idty_index
:
1
,
idty_index
:
1
,
}));
}));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithCertificationRemoved
{
idty_index
:
1
,
issued_by
:
2
,
},
));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithCertificationRemoved
{
idty_index
:
1
,
issued_by
:
3
,
},
));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithCertificationRemoved
{
idty_index
:
1
,
issued_by
:
4
,
},
));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithExcluded
{
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithExcluded
{
idty_index
:
2
,
idty_index
:
2
,
}));
}));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithCertificationRemoved
{
idty_index
:
2
,
issued_by
:
3
,
},
));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithCertificationRemoved
{
idty_index
:
2
,
issued_by
:
4
,
},
));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithExcluded
{
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithExcluded
{
idty_index
:
5
,
idty_index
:
5
,
}));
}));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithCertificationRemoved
{
idty_index
:
1
,
issued_by
:
3
,
},
));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithCertificationRemoved
{
idty_index
:
5
,
issued_by
:
1
,
},
));
System
::
assert_has_event
(
RuntimeEvent
::
Smith
(
Event
::
<
Runtime
>
::
SmithCertificationRemoved
{
idty_index
:
5
,
issued_by
:
2
,
},
));
assert_eq!
(
assert_eq!
(
Smiths
::
<
Runtime
>
::
get
(
1
),
Smiths
::
<
Runtime
>
::
get
(
1
),
Some
(
SmithMeta
{
Some
(
SmithMeta
{
...
...
This diff is collapsed.
Click to expand it.
runtime/gdev/tests/integration_tests.rs
+
12
−
0
View file @
a1cff7e3
...
@@ -1542,6 +1542,18 @@ fn test_smith_member_can_revoke_its_idty() {
...
@@ -1542,6 +1542,18 @@ fn test_smith_member_can_revoke_its_idty() {
System
::
assert_has_event
(
RuntimeEvent
::
SmithMembers
(
System
::
assert_has_event
(
RuntimeEvent
::
SmithMembers
(
pallet_smith_members
::
Event
::
SmithExcluded
{
idty_index
:
3
},
pallet_smith_members
::
Event
::
SmithExcluded
{
idty_index
:
3
},
));
));
System
::
assert_has_event
(
RuntimeEvent
::
SmithMembers
(
pallet_smith_members
::
Event
::
SmithCertificationRemoved
{
idty_index
:
3
,
issued_by
:
1
,
},
));
System
::
assert_has_event
(
RuntimeEvent
::
SmithMembers
(
pallet_smith_members
::
Event
::
SmithCertificationRemoved
{
idty_index
:
3
,
issued_by
:
2
,
},
));
// Now Charlie is going out
// Now Charlie is going out
assert!
(
pallet_authority_members
::
OutgoingAuthorities
::
<
Runtime
>
::
get
()
.contains
(
&
3
));
assert!
(
pallet_authority_members
::
OutgoingAuthorities
::
<
Runtime
>
::
get
()
.contains
(
&
3
));
});
});
...
...
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