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
Merge requests
!216
Add end2end test for offences
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add end2end test for offences
bgallois/duniter-v2s:114-offences-testing
into
master
Overview
5
Commits
6
Pipelines
10
Changes
1
All threads resolved!
Hide all comments
Merged
Benjamin Gallois
requested to merge
bgallois/duniter-v2s:114-offences-testing
into
master
1 year ago
Overview
5
Commits
6
Pipelines
10
Changes
1
All threads resolved!
Hide all comments
Expand
Closes
#114 (closed)
0
0
Merge request reports
Viewing commit
d11deac8
Prev
Next
Show latest version
1 file
+
40
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Unverified
d11deac8
add end2end test babe offences
· d11deac8
bgallois
authored
1 year ago
runtime/gdev/tests/integration_tests.rs
+
40
−
0
Options
@@ -1392,3 +1392,43 @@ fn test_grandpa_offence() {
));
})
}
#[test]
fn
test_babe_offence
()
{
ExtBuilder
::
new
(
1
,
3
,
4
)
.build
()
.execute_with
(||
{
run_to_block
(
1
);
let
session_index
=
Session
::
current_index
();
let
current_validators
=
<
Runtime
as
pallet_im_online
::
Config
>
::
ValidatorSet
::
validators
();
// Construct an offence where all validators (member: 1) are offenders
let
mut
offenders
=
current_validators
.into_iter
()
.enumerate
()
.filter_map
(|(
_
,
id
)|
{
<
Runtime
as
pallet_session
::
historical
::
Config
>
::
FullIdentificationOf
::
convert
(
id
.clone
(),
)
.map
(|
full_id
|
(
id
,
full_id
))
})
.collect
::
<
Vec
<
IdentificationTuple
<
Runtime
>>>
();
let
keys
=
ImOnline
::
keys
();
let
validator_set_count
=
keys
.len
()
as
u32
;
let
offence
=
pallet_babe
::
EquivocationOffence
{
slot
:
0u64
.into
(),
session_index
,
validator_set_count
,
offender
:
offenders
.pop
()
.unwrap
()
.into
(),
};
let
_
=
Offences
::
report_offence
(
vec!
[],
offence
);
// An offence is deposited
System
::
assert_has_event
(
RuntimeEvent
::
Offences
(
pallet_offences
::
Event
::
Offence
{
kind
:
*
b"babe:equivocatio"
,
timeslot
:
vec!
[
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
],
}));
// Offenders are punished
System
::
assert_has_event
(
RuntimeEvent
::
AuthorityMembers
(
pallet_authority_members
::
Event
::
MemberGoOffline
{
member
:
1
},
));
System
::
assert_has_event
(
RuntimeEvent
::
AuthorityMembers
(
pallet_authority_members
::
Event
::
MemberAddedToBlacklist
{
member
:
1
},
));
})
}
Loading