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
bbbcd3b4
Commit
bbbcd3b4
authored
3 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
rustfmt
parent
493d93b3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
integration-tests/tests/common/balances.rs
+5
-7
5 additions, 7 deletions
integration-tests/tests/common/balances.rs
integration-tests/tests/cucumber_tests.rs
+45
-26
45 additions, 26 deletions
integration-tests/tests/cucumber_tests.rs
with
50 additions
and
33 deletions
integration-tests/tests/common/balances.rs
+
5
−
7
View file @
bbbcd3b4
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU Affero General Public License
// You should have received a copy of the GNU Affero General Public License
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
// along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>.
use
super
::
*
;
use
super
::
node_runtime
::
runtime_types
::
gdev_runtime
;
use
super
::
node_runtime
::
runtime_types
::
gdev_runtime
;
use
super
::
node_runtime
::
runtime_types
::
pallet_balances
;
use
super
::
node_runtime
::
runtime_types
::
pallet_balances
;
use
super
::
*
;
use
sp_keyring
::
AccountKeyring
;
use
sp_keyring
::
AccountKeyring
;
use
subxt
::{
sp_runtime
::
MultiAddress
,
PairSigner
};
use
subxt
::{
sp_runtime
::
MultiAddress
,
PairSigner
};
...
@@ -28,8 +28,7 @@ pub async fn set_balance(
...
@@ -28,8 +28,7 @@ pub async fn set_balance(
)
->
Result
<
()
>
{
)
->
Result
<
()
>
{
let
_events
=
create_block_with_extrinsic
(
let
_events
=
create_block_with_extrinsic
(
&
client
,
&
client
,
api
api
.tx
()
.tx
()
.sudo
()
.sudo
()
.sudo
(
gdev_runtime
::
Call
::
Balances
(
.sudo
(
gdev_runtime
::
Call
::
Balances
(
pallet_balances
::
pallet
::
Call
::
set_balance
{
pallet_balances
::
pallet
::
Call
::
set_balance
{
...
@@ -80,8 +79,7 @@ pub async fn transfer_all(
...
@@ -80,8 +79,7 @@ pub async fn transfer_all(
let
_events
=
create_block_with_extrinsic
(
let
_events
=
create_block_with_extrinsic
(
&
client
,
&
client
,
api
api
.tx
()
.tx
()
.balances
()
.balances
()
.transfer_all
(
to
.clone
()
.into
(),
false
)
.transfer_all
(
to
.clone
()
.into
(),
false
)
.create_signed
(
&
from
,
())
.create_signed
(
&
from
,
())
...
...
This diff is collapsed.
Click to expand it.
integration-tests/tests/cucumber_tests.rs
+
45
−
26
View file @
bbbcd3b4
...
@@ -64,12 +64,16 @@ fn parse_amount(amount: u64, unit: &str) -> (u64, bool) {
...
@@ -64,12 +64,16 @@ fn parse_amount(amount: u64, unit: &str) -> (u64, bool) {
#[given(regex
=
r"([a-zA-Z]+) have (\d+) (ĞD|cĞD|UD|mUD)"
)]
#[given(regex
=
r"([a-zA-Z]+) have (\d+) (ĞD|cĞD|UD|mUD)"
)]
async
fn
who_have
(
world
:
&
mut
DuniterWorld
,
who
:
String
,
amount
:
u64
,
unit
:
String
)
->
Result
<
()
>
{
async
fn
who_have
(
world
:
&
mut
DuniterWorld
,
who
:
String
,
amount
:
u64
,
unit
:
String
)
->
Result
<
()
>
{
// Parse inputs
// Parse inputs
let
who
=
AccountKeyring
::
from_str
(
&
who
)
let
who
=
AccountKeyring
::
from_str
(
&
who
)
.expect
(
"unknown to"
);
.expect
(
"unknown to"
);
let
(
mut
amount
,
is_ud
)
=
parse_amount
(
amount
,
&
unit
);
let
(
mut
amount
,
is_ud
)
=
parse_amount
(
amount
,
&
unit
);
if
is_ud
{
if
is_ud
{
let
current_ud_amount
=
world
.api
.storage
()
.universal_dividend
()
.current_ud_storage
(
None
)
.await
?
;
let
current_ud_amount
=
world
.api
.storage
()
.universal_dividend
()
.current_ud_storage
(
None
)
.await
?
;
amount
=
(
amount
*
current_ud_amount
)
/
1_000
;
amount
=
(
amount
*
current_ud_amount
)
/
1_000
;
}
}
...
@@ -80,7 +84,13 @@ async fn who_have(world: &mut DuniterWorld, who: String, amount: u64, unit: Stri
...
@@ -80,7 +84,13 @@ async fn who_have(world: &mut DuniterWorld, who: String, amount: u64, unit: Stri
}
}
#[when(regex
=
r"([a-zA-Z]+) send (\d+) (ĞD|cĞD|UD|mUD) to ([a-zA-Z]+)"
)]
#[when(regex
=
r"([a-zA-Z]+) send (\d+) (ĞD|cĞD|UD|mUD) to ([a-zA-Z]+)"
)]
async
fn
transfer
(
world
:
&
mut
DuniterWorld
,
from
:
String
,
amount
:
u64
,
unit
:
String
,
to
:
String
)
->
Result
<
()
>
{
async
fn
transfer
(
world
:
&
mut
DuniterWorld
,
from
:
String
,
amount
:
u64
,
unit
:
String
,
to
:
String
,
)
->
Result
<
()
>
{
// Parse inputs
// Parse inputs
let
from
=
AccountKeyring
::
from_str
(
&
from
)
.expect
(
"unknown from"
);
let
from
=
AccountKeyring
::
from_str
(
&
from
)
.expect
(
"unknown from"
);
let
to
=
AccountKeyring
::
from_str
(
&
to
)
.expect
(
"unknown to"
);
let
to
=
AccountKeyring
::
from_str
(
&
to
)
.expect
(
"unknown to"
);
...
@@ -116,11 +126,20 @@ async fn should_have(world: &mut DuniterWorld, who: String, amount: u64) -> Resu
...
@@ -116,11 +126,20 @@ async fn should_have(world: &mut DuniterWorld, who: String, amount: u64) -> Resu
}
}
#[then(regex
=
r"current UD amount should be (\d+).(\d+)"
)]
#[then(regex
=
r"current UD amount should be (\d+).(\d+)"
)]
async
fn
current_ud_amount_should_be
(
world
:
&
mut
DuniterWorld
,
amount
:
u64
,
cents
:
u64
)
->
Result
<
()
>
{
async
fn
current_ud_amount_should_be
(
world
:
&
mut
DuniterWorld
,
amount
:
u64
,
cents
:
u64
,
)
->
Result
<
()
>
{
// Parse inputs
// Parse inputs
let
expected_amount
=
amount
+
(
cents
*
100
);
let
expected_amount
=
amount
+
(
cents
*
100
);
let
current_ud_amount
=
world
.api
.storage
()
.universal_dividend
()
.current_ud_storage
(
None
)
.await
?
;
let
current_ud_amount
=
world
.api
.storage
()
.universal_dividend
()
.current_ud_storage
(
None
)
.await
?
;
assert_eq!
(
current_ud_amount
,
expected_amount
);
assert_eq!
(
current_ud_amount
,
expected_amount
);
Ok
(())
Ok
(())
}
}
...
...
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