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
31343727
Commit
31343727
authored
1 year ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
wip: feat: distance blockchain events
parent
d7c408f1
No related branches found
No related tags found
No related merge requests found
Pipeline
#32559
waiting for manual action
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pallets/distance/src/lib.rs
+7
-2
7 additions, 2 deletions
pallets/distance/src/lib.rs
pallets/distance/src/tests.rs
+12
-1
12 additions, 1 deletion
pallets/distance/src/tests.rs
with
19 additions
and
3 deletions
pallets/distance/src/lib.rs
+
7
−
2
View file @
31343727
...
...
@@ -146,8 +146,9 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super)
fn
deposit_event)]
pub
enum
Event
<
T
:
Config
<
I
>
,
I
:
'static
=
()
>
{
/// TODO: define
EvalutionSuccess
,
EvaluationSuccess
(
IdtyIndex
),
EvaluationFailure
(
IdtyIndex
),
EvaluationNotProcessed
(
IdtyIndex
),
}
// ERRORS //
...
...
@@ -294,6 +295,7 @@ pub mod pallet {
.try_push
((
idty_index
,
median
::
MedianAcc
::
new
()))
.map_err
(|
_
|
Error
::
<
T
,
I
>
::
QueueFull
)
?
;
// TODO: never raised because of preceding ensure!()?
IdentitiesDistanceStatus
::
<
T
,
I
>
::
insert
(
idty_index
,
DistanceStatus
::
Pending
);
Ok
(())
},
)
...
...
@@ -373,16 +375,19 @@ pub mod pallet {
&
account_id
,
<
T
as
Config
<
I
>>
::
EvaluationPrice
::
get
(),
);
Self
::
deposit_event
(
Event
::
EvaluationSuccess
(
idty
));
}
else
{
IdentitiesDistanceStatus
::
<
T
,
I
>
::
remove
(
idty
);
<
T
as
Config
<
I
>>
::
Currency
::
slash_reserved
(
&
account_id
,
<
T
as
Config
<
I
>>
::
EvaluationPrice
::
get
(),
);
Self
::
deposit_event
(
Event
::
EvaluationFailure
(
idty
));
}
}
else
{
IdentitiesDistanceStatus
::
<
T
,
I
>
::
remove
(
idty
);
T
::
Currency
::
unreserve
(
&
account_id
,
<
T
as
Config
<
I
>>
::
EvaluationPrice
::
get
());
Self
::
deposit_event
(
Event
::
EvaluationNotProcessed
(
idty
));
}
}
Weight
::
zero
()
...
...
This diff is collapsed.
Click to expand it.
pallets/distance/src/tests.rs
+
12
−
1
View file @
31343727
...
...
@@ -65,6 +65,11 @@ fn basic_single_distance() {
// Other pools have never been used
assert_eq!
(
pallet
::
EvaluationPool0
::
<
Test
>
::
get
()
.0
.len
(),
0
);
assert_eq!
(
pallet
::
EvaluationPool1
::
<
Test
>
::
get
()
.0
.len
(),
0
);
run_to_block
(
SESSION_3_START
);
System
::
assert_has_event
(
RuntimeEvent
::
Distance
(
pallet
::
Event
::
EvaluationSuccess
{
0
:
*
IDTY_0
,
}));
});
}
...
...
@@ -165,6 +170,9 @@ fn multiple_authors() {
pallet
::
IdentitiesDistanceStatus
::
<
Test
>
::
get
(
IDTY_0
),
Some
(
Valid
)
);
// now valid!
System
::
assert_has_event
(
RuntimeEvent
::
Distance
(
pallet
::
Event
::
EvaluationSuccess
{
0
:
*
IDTY_0
,
}));
});
}
...
...
@@ -198,8 +206,11 @@ fn distance_failure() {
// Finally session 4
run_to_block
(
SESSION_3_START
);
assert_eq!
(
pallet
::
IdentitiesDistanceStatus
::
<
Test
>
::
get
(
IDTY_0
),
None
);
// distance failure
assert_eq!
(
pallet
::
IdentitiesDistanceStatus
::
<
Test
>
::
get
(
IDTY_0
),
None
);
System
::
assert_has_event
(
RuntimeEvent
::
Distance
(
pallet
::
Event
::
EvaluationFailure
{
0
:
*
IDTY_0
,
}));
// TODO: test: variant Two
});
}
...
...
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