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
f34c95ff
Commit
f34c95ff
authored
1 year ago
by
Hugo Trentesaux
Committed by
Hugo Trentesaux
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
add comments
parent
341c2e8d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!193
add balance transfer tests
Pipeline
#34252
waiting for manual action
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/balance_tests.rs
+9
-21
9 additions, 21 deletions
runtime/gdev/tests/balance_tests.rs
with
9 additions
and
21 deletions
runtime/gdev/tests/balance_tests.rs
+
9
−
21
View file @
f34c95ff
...
...
@@ -25,6 +25,7 @@ use sp_keyring::AccountKeyring;
/// test currency transfer
/// (does not take fees into account because it's only calls, not extrinsics)
/// test final balance of Alice and Eve accounts
#[test]
fn
test_transfer
()
{
ExtBuilder
::
new
(
1
,
3
,
4
)
...
...
@@ -52,23 +53,7 @@ fn test_transfer() {
})
}
/// test balance transfer
#[test]
fn
test_transfer
()
{
ExtBuilder
::
new
(
1
,
3
,
4
)
.with_initial_balances
(
vec!
[(
AccountKeyring
::
Alice
.to_account_id
(),
600
)])
.build
()
.execute_with
(||
{
run_to_block
(
1
);
assert_ok!
(
Balances
::
transfer_allow_death
(
frame_system
::
RawOrigin
::
Signed
(
AccountKeyring
::
Alice
.to_account_id
())
.into
(),
AccountKeyring
::
Dave
.to_account_id
()
.into
(),
500
));
})
}
/// test balance transfer without enough balance (would prefer TokenError::BelowMinimum or NotExpendable)
/// test balance transfer without enough balance
#[test]
fn
test_transfer_not_enough
()
{
ExtBuilder
::
new
(
1
,
3
,
4
)
...
...
@@ -82,24 +67,26 @@ fn test_transfer_not_enough() {
AccountKeyring
::
Dave
.to_account_id
()
.into
(),
500
),
sp_runtime
::
TokenError
::
Frozen
sp_runtime
::
TokenError
::
Frozen
// frozen because trying to transfer more than liquid
);
})
}
/// test balance transfer without enough balance (would prefer TokenError::FundsUnavailable)
/// test balance transfer without enough balance
/// in this case, it is the total issuance which cause problem, hence the arithmetic underflow
#[test]
fn
test_transfer_underflow
()
{
ExtBuilder
::
new
(
1
,
3
,
4
)
.with_initial_balances
(
vec!
[(
AccountKeyring
::
Alice
.to_account_id
(),
4
99
)])
.with_initial_balances
(
vec!
[(
AccountKeyring
::
Alice
.to_account_id
(),
4
00
)])
.build
()
.execute_with
(||
{
run_to_block
(
1
);
assert_eq!
(
Balances
::
total_issuance
(),
400
);
assert_noop!
(
Balances
::
transfer_allow_death
(
frame_system
::
RawOrigin
::
Signed
(
AccountKeyring
::
Alice
.to_account_id
())
.into
(),
AccountKeyring
::
Dave
.to_account_id
()
.into
(),
500
500
// larger than total issuance
),
sp_runtime
::
ArithmeticError
::
Underflow
);
...
...
@@ -107,6 +94,7 @@ fn test_transfer_underflow() {
}
/// test balance transfer without enough balance
/// can not transfer 500 when only 499 available
#[test]
fn
test_transfer_funds_unavailable
()
{
ExtBuilder
::
new
(
1
,
3
,
4
)
...
...
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