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
45e6eb44
Commit
45e6eb44
authored
1 year ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
add change owner key test
parent
f78c17f9
No related branches found
No related tags found
No related merge requests found
Pipeline
#33519
waiting for manual action
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
runtime/gdev/tests/integration_tests.rs
+38
-0
38 additions, 0 deletions
runtime/gdev/tests/integration_tests.rs
with
38 additions
and
0 deletions
runtime/gdev/tests/integration_tests.rs
+
38
−
0
View file @
45e6eb44
...
@@ -21,6 +21,7 @@ use frame_support::traits::{Get, PalletInfo, StorageInfo, StorageInfoTrait};
...
@@ -21,6 +21,7 @@ use frame_support::traits::{Get, PalletInfo, StorageInfo, StorageInfoTrait};
use
frame_support
::{
assert_noop
,
assert_ok
};
use
frame_support
::{
assert_noop
,
assert_ok
};
use
frame_support
::{
StorageHasher
,
Twox128
};
use
frame_support
::{
StorageHasher
,
Twox128
};
use
gdev_runtime
::
*
;
use
gdev_runtime
::
*
;
use
sp_core
::
Encode
;
use
sp_keyring
::
AccountKeyring
;
use
sp_keyring
::
AccountKeyring
;
use
sp_runtime
::
MultiAddress
;
use
sp_runtime
::
MultiAddress
;
...
@@ -1088,3 +1089,40 @@ fn test_oneshot_accounts() {
...
@@ -1088,3 +1089,40 @@ fn test_oneshot_accounts() {
);
);
});
});
}
}
/// test change owner key
// Dave identity should be able to transfer his identity to Eve pubkey
#[test]
fn
test_change_owner_key
()
{
ExtBuilder
::
new
(
1
,
3
,
4
)
.build
()
.execute_with
(||
{
// payload
let
genesis_hash
=
System
::
block_hash
(
0
);
// 0x454545454545...
let
old_owner_key
=
AccountKeyring
::
Dave
.to_account_id
();
let
new_owner_key
=
AccountKeyring
::
Eve
.to_account_id
();
let
payload
=
pallet_identity
::
NewOwnerKeyPayload
{
genesis_hash
:
&
genesis_hash
,
idty_index
:
4u64
,
old_owner_key
:
&
old_owner_key
,
};
// check that Dave identity index is actually 4
assert_eq!
(
Identity
::
identity_index_of
(
AccountKeyring
::
Dave
.to_account_id
()),
Some
(
4
)
);
// Dave can change his owner key
assert_ok!
(
Identity
::
change_owner_key
(
// origin is Dave (current identity)
frame_system
::
RawOrigin
::
Signed
(
AccountKeyring
::
Dave
.to_account_id
())
.into
(),
// new key is Eve's key (no identity)
new_owner_key
.clone
(),
// payload is signed by Eve
AccountKeyring
::
Eve
.sign
(
// payload is prefixed by "icok"
&
(
pallet_identity
::
NEW_OWNER_KEY_PAYLOAD_PREFIX
,
payload
)
.encode
()
)
.into
()
));
})
}
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