Skip to content
Snippets Groups Projects
Commit 5493a681 authored by Nicolas80's avatar Nicolas80
Browse files

Adapted sr25519 seed derivation test to use a different (newly generated for test) base mnemonic

parent badf52ce
No related branches found
No related tags found
1 merge request!41Adding db persistence for all SecretFormat of vault keys as well as supporting derivations
......@@ -378,40 +378,54 @@ mod tests {
/// Testing sr25519 seed derivations
///
/// Using `subkey` command to have expected values from seed derivations (using seed linked to `SUBSTRATE_MNEMONIC` for tests)
/// Using `subkey` command to have expected values from seed derivations (using a newly generated mnemonic `festival insane keep vivid surface photo razor unaware twice sudden involve false` for this test)
///
/// ##### The root seed
/// (from the mnemonic first)
/// ```
/// subkey inspect
/// URI:
/// Secret Key URI `0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e` is account:
/// Secret phrase: festival insane keep vivid surface photo razor unaware twice sudden involve false
/// Network ID: substrate
/// Secret seed: 0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e
/// Public key (hex): 0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a
/// Account ID: 0x46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a
/// Public key (SS58): 5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV
/// SS58 Address: 5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV
/// Secret seed: 0xf813535799c3a15b8e419a06964e87fabd3f265caebcbb38c935a1acdbe05253
/// Public key (hex): 0xce47000c942392afacc938b0db0b79d3377b1d1f5fbad6374c2943af05dfe379
/// Account ID: 0xce47000c942392afacc938b0db0b79d3377b1d1f5fbad6374c2943af05dfe379
/// Public key (SS58): 5GjAp6kkbsDjxABGouMvu1Mxbr7PaFqbMrprEoZ466vPF2Vt
/// SS58 Address: 5GjAp6kkbsDjxABGouMvu1Mxbr7PaFqbMrprEoZ466vPF2Vt
/// ```
///
/// When using the seed directly
/// ```
/// subkey inspect
/// URI:
/// Secret Key URI `0xf813535799c3a15b8e419a06964e87fabd3f265caebcbb38c935a1acdbe05253` is account:
/// Network ID: substrate
/// Secret seed: 0xf813535799c3a15b8e419a06964e87fabd3f265caebcbb38c935a1acdbe05253
/// Public key (hex): 0xce47000c942392afacc938b0db0b79d3377b1d1f5fbad6374c2943af05dfe379
/// Account ID: 0xce47000c942392afacc938b0db0b79d3377b1d1f5fbad6374c2943af05dfe379
/// Public key (SS58): 5GjAp6kkbsDjxABGouMvu1Mxbr7PaFqbMrprEoZ466vPF2Vt
/// SS58 Address: 5GjAp6kkbsDjxABGouMvu1Mxbr7PaFqbMrprEoZ466vPF2Vt
/// ```
///
/// ##### The '//0' derivation
/// ```
/// subkey inspect
/// URI:
/// Secret Key URI `0xfac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e//0` is account:
/// Secret Key URI `0xf813535799c3a15b8e419a06964e87fabd3f265caebcbb38c935a1acdbe05253//0` is account:
/// Network ID: substrate
/// Secret seed: 0x914dded06277afbe5b0e8a30bce539ec8a9552a784d08e530dc7c2915c478393
/// Public key (hex): 0x2afba9278e30ccf6a6ceb3a8b6e336b70068f045c666f2e7f4f9cc5f47db8972
/// Account ID: 0x2afba9278e30ccf6a6ceb3a8b6e336b70068f045c666f2e7f4f9cc5f47db8972
/// Public key (SS58): 5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH
/// SS58 Address: 5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH
/// Secret seed: 0xb1f84cbfd8db9de2b198f6658cf8ad5aacc157589e891a653ca1eed3979f8220
/// Public key (hex): 0xe2b36186911ac4bc7480516b8711be124d97c625f255cbf494bd5f997b8e6023
/// Account ID: 0xe2b36186911ac4bc7480516b8711be124d97c625f255cbf494bd5f997b8e6023
/// Public key (SS58): 5HBwy19piXNWg7bfShuNgWsBCWRzkG99M8eRGB6PHkxeAKAV
/// SS58 Address: 5HBwy19piXNWg7bfShuNgWsBCWRzkG99M8eRGB6PHkxeAKAV
/// ```
#[test]
fn test_sr25519_seed_derivations() {
let root_seed = "fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e";
let root_seed = "f813535799c3a15b8e419a06964e87fabd3f265caebcbb38c935a1acdbe05253";
let root_sr25519_pair = pair_from_sr25519_seed(root_seed).unwrap();
let expected_root_ss58_address_string =
"5DfhGyQdFobKM8NsWvEeAKk5EQQgYe9AydgJ7rMB6E1EqRzV".to_string();
"5GjAp6kkbsDjxABGouMvu1Mxbr7PaFqbMrprEoZ466vPF2Vt".to_string();
let root_ss58_address: AccountId = root_sr25519_pair.public().into();
println!("root SS58 Address: '{}'", root_ss58_address);
assert_eq!(
......@@ -425,7 +439,7 @@ mod tests {
.unwrap();
let expected_deriv_0_ss58_address_string =
"5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH".to_string();
"5HBwy19piXNWg7bfShuNgWsBCWRzkG99M8eRGB6PHkxeAKAV".to_string();
let deriv_0_ss58_address: AccountId = deriv_0_sr25519_pair.public().into();
println!("derived '//0' SS58 Address: '{}'", deriv_0_ss58_address);
assert_eq!(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment