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
2aa18ec5
Commit
2aa18ec5
authored
4 months ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
reveal that expires_on is non null
issue
#243
parent
a46e1971
No related branches found
No related tags found
1 merge request
!303
Resolve "OutgoingAuthorities event is triggered too many times."
Pipeline
#39479
passed
4 months ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
1
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
runtime/gdev/tests/integration_tests.rs
+90
-0
90 additions, 0 deletions
runtime/gdev/tests/integration_tests.rs
with
90 additions
and
0 deletions
runtime/gdev/tests/integration_tests.rs
+
90
−
0
View file @
2aa18ec5
...
@@ -25,6 +25,7 @@ use frame_support::{
...
@@ -25,6 +25,7 @@ use frame_support::{
use
gdev_runtime
::
*
;
use
gdev_runtime
::
*
;
use
pallet_identity
::{
RevocationPayload
,
REVOCATION_PAYLOAD_PREFIX
};
use
pallet_identity
::{
RevocationPayload
,
REVOCATION_PAYLOAD_PREFIX
};
use
pallet_membership
::
MembershipRemovalReason
;
use
pallet_membership
::
MembershipRemovalReason
;
use
pallet_session
::
historical
::
SessionManager
;
use
pallet_smith_members
::{
SmithMeta
,
SmithStatus
};
use
pallet_smith_members
::{
SmithMeta
,
SmithStatus
};
use
scale_info
::
prelude
::
num
::
NonZeroU16
;
use
scale_info
::
prelude
::
num
::
NonZeroU16
;
use
sp_core
::{
Encode
,
Pair
};
use
sp_core
::{
Encode
,
Pair
};
...
@@ -1020,6 +1021,95 @@ fn test_smith_process() {
...
@@ -1020,6 +1021,95 @@ fn test_smith_process() {
})
})
}
}
// reveal bug from #243
#[test]
fn
test_expired_smith_with_null_expires_on
()
{
// initial_authorities_len = 2 → Alice and Bob are online
// initial_smiths_len = 3 → Charlie is offline Smith
// initial_identities_len = 4 → Dave is member but not smith
ExtBuilder
::
new
(
2
,
3
,
4
)
.build
()
.execute_with
(||
{
run_to_block
(
1
);
// Bob is smith
assert_eq!
(
SmithMembers
::
smiths
(
2
),
Some
(
pallet_smith_members
::
SmithMeta
{
status
:
SmithStatus
::
Smith
,
expires_on
:
None
,
// because online
issued_certs
:
vec!
[
1
,
3
],
received_certs
:
vec!
[
1
,
3
],
})
);
// force Bob to leave by expiring his main WoT membership
Membership
::
do_remove_membership
(
2
,
MembershipRemovalReason
::
System
);
// check events
// membership removal
System
::
assert_has_event
(
RuntimeEvent
::
Membership
(
pallet_membership
::
Event
::
MembershipRemoved
{
member
:
2
,
reason
:
MembershipRemovalReason
::
System
,
},
));
// smith membership removal
System
::
assert_has_event
(
RuntimeEvent
::
SmithMembers
(
pallet_smith_members
::
Event
::
SmithMembershipRemoved
{
idty_index
:
2
},
));
System
::
assert_has_event
(
RuntimeEvent
::
AuthorityMembers
(
pallet_authority_members
::
Event
::
MemberRemoved
{
member
:
2
},
));
// also events for certifications
// check state
// Bob is not Smith anymore
assert_eq!
(
SmithMembers
::
smiths
(
2
),
Some
(
pallet_smith_members
::
SmithMeta
{
status
:
SmithStatus
::
Excluded
,
// automatically excluded
expires_on
:
None
,
// because excluded, no expiry is scheduled
issued_certs
:
vec!
[
1
,
3
],
received_certs
:
vec!
[],
// received certs are deleted
})
);
// Alice smith cert to Bob has been deleted
assert_eq!
(
SmithMembers
::
smiths
(
1
),
Some
(
pallet_smith_members
::
SmithMeta
{
status
:
SmithStatus
::
Smith
,
expires_on
:
None
,
// because online
issued_certs
:
vec!
[
3
],
// cert to Bob has been deleted
received_certs
:
vec!
[
2
,
3
],
})
);
// run to next block
run_to_block
(
2
);
// simulate new session
AuthorityMembers
::
new_session
(
2
);
// check event
System
::
assert_has_event
(
RuntimeEvent
::
AuthorityMembers
(
pallet_authority_members
::
Event
::
OutgoingAuthorities
{
members
:
vec!
[
2
]
},
));
// show that expires_on is non null
// this is issue #243
// Bob is not Smith anymore
assert_eq!
(
SmithMembers
::
smiths
(
2
),
Some
(
pallet_smith_members
::
SmithMeta
{
status
:
SmithStatus
::
Excluded
,
// still excluded
expires_on
:
Some
(
48
),
// should be still None !!
issued_certs
:
vec!
[
1
,
3
],
received_certs
:
vec!
[],
})
);
// println!("{:#?}", System::events()); // with -- --nocapture
})
}
/// test new account creation
/// test new account creation
#[test]
#[test]
fn
test_create_new_account
()
{
fn
test_create_new_account
()
{
...
...
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