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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
cb99b8f6
Commit
cb99b8f6
authored
1 year ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
distance pallet unit test stub
parent
72cc4e73
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pallets/distance/src/lib.rs
+2
-0
2 additions, 0 deletions
pallets/distance/src/lib.rs
pallets/distance/src/mock.rs
+12
-1
12 additions, 1 deletion
pallets/distance/src/mock.rs
pallets/distance/src/tests.rs
+41
-0
41 additions, 0 deletions
pallets/distance/src/tests.rs
with
55 additions
and
1 deletion
pallets/distance/src/lib.rs
+
2
−
0
View file @
cb99b8f6
...
...
@@ -26,6 +26,8 @@ pub mod benchmarking;
#[cfg(test)]
mod
mock
;
#[cfg(test)]
mod
tests
;
pub
use
pallet
::
*
;
pub
use
traits
::
*
;
...
...
This diff is collapsed.
Click to expand it.
pallets/distance/src/mock.rs
+
12
−
1
View file @
cb99b8f6
...
...
@@ -19,7 +19,7 @@ use crate::{self as pallet_distance};
use
core
::
marker
::
PhantomData
;
use
frame_support
::{
parameter_types
,
traits
::{
Everything
,
GenesisBuild
},
traits
::{
Everything
,
GenesisBuild
,
OnFinalize
,
OnInitialize
},
};
use
frame_system
as
system
;
use
pallet_balances
::
AccountData
;
...
...
@@ -291,3 +291,14 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
sp_io
::
TestExternalities
::
new
(
t
)
}
pub
fn
run_to_block
(
n
:
u64
)
{
while
System
::
block_number
()
<
n
{
Session
::
on_finalize
(
System
::
block_number
());
System
::
on_finalize
(
System
::
block_number
());
System
::
reset_events
();
System
::
set_block_number
(
System
::
block_number
()
+
1
);
System
::
on_initialize
(
System
::
block_number
());
Session
::
on_initialize
(
System
::
block_number
());
}
}
This diff is collapsed.
Click to expand it.
pallets/distance/src/tests.rs
0 → 100644
+
41
−
0
View file @
cb99b8f6
// Copyright 2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
use
crate
::
mock
::
*
;
use
crate
::
*
;
use
frame_support
::
assert_ok
;
use
frame_support
::
traits
::
Currency
;
#[test]
fn
test_request_distance_evaluation
()
{
new_test_ext
()
.execute_with
(||
{
run_to_block
(
1
);
// give enough for reserve
Balances
::
make_free_balance_be
(
&
1
,
10_000
);
// call request
assert_ok!
(
Distance
::
request_distance_evaluation
(
RuntimeOrigin
::
signed
(
1
)
));
System
::
assert_has_event
(
RuntimeEvent
::
Distance
(
Event
::
EvaluationRequested
{
idty_index
:
1
,
who
:
1
,
}));
// currency was reserved
assert_eq!
(
Balances
::
reserved_balance
(
1
),
1000
);
});
}
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