diff --git a/distance-oracle/src/mock.rs b/distance-oracle/src/mock.rs index 881022205f92e5725ad8be079a6f84d8fd2093b3..7276372900209004ccf2204e77d4e3e21db5887f 100644 --- a/distance-oracle/src/mock.rs +++ b/distance-oracle/src/mock.rs @@ -25,7 +25,7 @@ pub struct Client { wot: RustyWebOfTrust, pub pool_len: usize, } -pub type AccountId = subxt::ext::sp_runtime::AccountId32; +pub type AccountId = sp_runtime::AccountId32; pub type IdtyIndex = u32; pub type H256 = subxt::utils::H256; diff --git a/end2end-tests/tests/common/balances.rs b/end2end-tests/tests/common/balances.rs index e7b703736316ea3bcd02bfcb932ed611263324de..b1c469e2b055acb9397499e611bda06cc77ce499 100644 --- a/end2end-tests/tests/common/balances.rs +++ b/end2end-tests/tests/common/balances.rs @@ -15,10 +15,11 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. use super::{gdev, gdev::runtime_types::pallet_balances, *}; -use sp_keyring::AccountKeyring; -use subxt::{tx::PairSigner, utils::MultiAddress}; +use crate::common::pair_signer::PairSigner; +use sp_keyring::sr25519::Keyring; +use subxt::utils::MultiAddress; -pub async fn set_balance(client: &FullClient, who: AccountKeyring, amount: u64) -> Result<()> { +pub async fn set_balance(client: &FullClient, who: Keyring, amount: u64) -> Result<()> { let _events = create_block_with_extrinsic( &client.rpc, client @@ -29,7 +30,7 @@ pub async fn set_balance(client: &FullClient, who: AccountKeyring, amount: u64) .sudo() .sudo(gdev::runtime_types::gdev_runtime::RuntimeCall::Balances( pallet_balances::pallet::Call::force_set_balance { - who: MultiAddress::Id(who.to_account_id().into()), + who: MultiAddress::Id(who.to_raw_public().into()), new_free: amount, }, )), @@ -43,14 +44,9 @@ pub async fn set_balance(client: &FullClient, who: AccountKeyring, amount: u64) Ok(()) } -pub async fn transfer( - client: &FullClient, - from: AccountKeyring, - amount: u64, - to: AccountKeyring, -) -> Result<()> { +pub async fn transfer(client: &FullClient, from: Keyring, amount: u64, to: Keyring) -> Result<()> { let from = PairSigner::new(from.pair()); - let to = to.to_account_id(); + let to = MultiAddress::Id(to.to_raw_public().into()); let _events = create_block_with_extrinsic( &client.rpc, @@ -58,9 +54,7 @@ pub async fn transfer( .client .tx() .create_signed( - &gdev::tx() - .universal_dividend() - .transfer_ud(to.clone().into(), amount), + &gdev::tx().universal_dividend().transfer_ud(to, amount), &from, SubstrateExtrinsicParamsBuilder::new().build(), ) @@ -71,13 +65,9 @@ pub async fn transfer( Ok(()) } -pub async fn transfer_all( - client: &FullClient, - from: AccountKeyring, - to: AccountKeyring, -) -> Result<()> { +pub async fn transfer_all(client: &FullClient, from: Keyring, to: Keyring) -> Result<()> { let from = PairSigner::new(from.pair()); - let to = to.to_account_id(); + let to = MultiAddress::Id(to.to_raw_public().into()); let _events = create_block_with_extrinsic( &client.rpc, @@ -85,7 +75,7 @@ pub async fn transfer_all( .client .tx() .create_signed( - &gdev::tx().balances().transfer_all(to.into(), false), + &gdev::tx().balances().transfer_all(to, false), &from, SubstrateExtrinsicParamsBuilder::new().build(), ) @@ -98,12 +88,11 @@ pub async fn transfer_all( pub async fn transfer_ud( client: &FullClient, - from: AccountKeyring, + from: Keyring, amount: u64, - to: AccountKeyring, + to: Keyring, ) -> Result<()> { let from = PairSigner::new(from.pair()); - let to = to.to_account_id(); let _events = create_block_with_extrinsic( &client.rpc, @@ -113,7 +102,7 @@ pub async fn transfer_ud( .create_signed( &gdev::tx() .universal_dividend() - .transfer_ud(to.clone().into(), amount), + .transfer_ud(MultiAddress::Id(to.to_raw_public().into()), amount), &from, SubstrateExtrinsicParamsBuilder::new().build(), ) diff --git a/end2end-tests/tests/common/cert.rs b/end2end-tests/tests/common/cert.rs index bccd2db932f8d570d3923dd2ab05e2462d0eb0a1..2841643e014e05326ed2ba3c2c834e49cb19998c 100644 --- a/end2end-tests/tests/common/cert.rs +++ b/end2end-tests/tests/common/cert.rs @@ -15,13 +15,14 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. use super::{gdev, gdev::runtime_types::pallet_certification, *}; -use sp_keyring::AccountKeyring; -use subxt::{tx::PairSigner, utils::MultiAddress}; +use crate::common::pair_signer::PairSigner; +use sp_keyring::sr25519::Keyring; +use subxt::utils::MultiAddress; -pub async fn certify(client: &FullClient, from: AccountKeyring, to: AccountKeyring) -> Result<()> { +pub async fn certify(client: &FullClient, from: Keyring, to: Keyring) -> Result<()> { let signer = PairSigner::new(from.pair()); - let from: subxt::utils::AccountId32 = from.to_account_id().into(); - let to: subxt::utils::AccountId32 = to.to_account_id().into(); + let from: subxt::utils::AccountId32 = from.to_raw_public().into(); + let to: subxt::utils::AccountId32 = to.to_raw_public().into(); let _issuer_index = client .client diff --git a/end2end-tests/tests/common/distance.rs b/end2end-tests/tests/common/distance.rs index f7d02df5544cf80a7b8922d90296d2ae8478ad85..a08893ba41dc6904513bfe2edefe9c0f57028f60 100644 --- a/end2end-tests/tests/common/distance.rs +++ b/end2end-tests/tests/common/distance.rs @@ -15,15 +15,11 @@ // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. use super::{gdev, gdev::runtime_types::pallet_identity, *}; -use crate::DuniterWorld; -use sp_keyring::AccountKeyring; -use subxt::{ - backend::rpc::RpcClient, - tx::{PairSigner, Signer}, - utils::AccountId32, -}; +use crate::{common::pair_signer::PairSigner, DuniterWorld}; +use sp_keyring::sr25519::Keyring; +use subxt::{backend::rpc::RpcClient, tx::Signer, utils::AccountId32}; -pub async fn request_evaluation(client: &FullClient, origin: AccountKeyring) -> Result<()> { +pub async fn request_evaluation(client: &FullClient, origin: Keyring) -> Result<()> { let origin = PairSigner::new(origin.pair()); let _events = create_block_with_extrinsic( @@ -43,11 +39,7 @@ pub async fn request_evaluation(client: &FullClient, origin: AccountKeyring) -> Ok(()) } -pub async fn run_oracle( - client: &FullClient, - origin: AccountKeyring, - rpc_url: String, -) -> Result<()> { +pub async fn run_oracle(client: &FullClient, origin: Keyring, rpc_url: String) -> Result<()> { let origin = PairSigner::new(origin.pair()); let account_id: &AccountId32 = origin.account_id(); diff --git a/end2end-tests/tests/common/identity.rs b/end2end-tests/tests/common/identity.rs index da532a67edc83e9bcbec3bae4af19a5c7013402a..00c806e762901386bed56f58fe0f20525e054fc5 100644 --- a/end2end-tests/tests/common/identity.rs +++ b/end2end-tests/tests/common/identity.rs @@ -15,9 +15,12 @@ // along with Substrate-Libre-Currency. If not, see <https://www.gnu.org/licenses/>. use super::{gdev, gdev::runtime_types::pallet_identity, *}; -use crate::{gdev::runtime_types::pallet_identity::types::IdtyName, DuniterWorld}; -use sp_keyring::AccountKeyring; -use subxt::tx::PairSigner; +use crate::{ + common::pair_signer::PairSigner, gdev::runtime_types::pallet_identity::types::IdtyName, + DuniterWorld, +}; +use sp_keyring::sr25519::Keyring; +use subxt::config::substrate::MultiAddress; type BlockNumber = u32; type AccountId = subxt::utils::AccountId32; @@ -27,13 +30,9 @@ type IdtyValue = // submit extrinsics -pub async fn create_identity( - client: &FullClient, - from: AccountKeyring, - to: AccountKeyring, -) -> Result<()> { +pub async fn create_identity(client: &FullClient, from: Keyring, to: Keyring) -> Result<()> { let from = PairSigner::new(from.pair()); - let to = to.to_account_id(); + let to = to.to_raw_public(); let _events = create_block_with_extrinsic( &client.rpc, @@ -52,11 +51,7 @@ pub async fn create_identity( Ok(()) } -pub async fn confirm_identity( - client: &FullClient, - from: AccountKeyring, - pseudo: String, -) -> Result<()> { +pub async fn confirm_identity(client: &FullClient, from: Keyring, pseudo: String) -> Result<()> { let from = PairSigner::new(from.pair()); let pseudo: IdtyName = IdtyName(pseudo.as_bytes().to_vec()); @@ -79,9 +74,9 @@ pub async fn confirm_identity( // get identity index from account keyring name pub async fn get_identity_index(world: &DuniterWorld, account: String) -> Result<u32> { - let account: AccountId = AccountKeyring::from_str(&account) + let account: AccountId = Keyring::from_str(&account) .expect("unknown account") - .to_account_id() + .to_raw_public() .into(); let identity_index = world diff --git a/end2end-tests/tests/common/mod.rs b/end2end-tests/tests/common/mod.rs index 5f8230da51565cda8d1e91b9a90e87e3119fe5c6..c3acaa66b693755ec26c31666c101f50f7aee2e6 100644 --- a/end2end-tests/tests/common/mod.rs +++ b/end2end-tests/tests/common/mod.rs @@ -32,7 +32,7 @@ use anyhow::anyhow; use codec::Encode; use notify_debouncer_mini::new_debouncer; use serde_json::Value; -use sp_keyring::AccountKeyring; +use sp_keyring::sr25519::Keyring; use std::{ io::prelude::*, path::{Path, PathBuf}, @@ -41,29 +41,28 @@ use std::{ time::{Duration, Instant}, }; use subxt::{ - backend::rpc::{RpcClient, RpcParams}, + backend::rpc::RpcClient, config::{substrate::SubstrateExtrinsicParamsBuilder, SubstrateExtrinsicParams}, - ext::{sp_core, sp_runtime}, - rpc_params, + ext::subxt_rpcs::client::{rpc_params, RpcParams}, }; pub type Client = subxt::OnlineClient<GdevConfig>; pub type Event = gdev::Event; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; -pub type SubmittableExtrinsic = subxt::tx::SubmittableExtrinsic<GdevConfig, Client>; +pub type SubmittableExtrinsic = subxt::tx::SubmittableTransaction<GdevConfig, Client>; pub type TxProgress = subxt::tx::TxProgress<GdevConfig, Client>; pub enum GdevConfig {} impl subxt::config::Config for GdevConfig { type AccountId = subxt::utils::AccountId32; - type Address = sp_runtime::MultiAddress<Self::AccountId, u32>; + type Address = subxt::utils::MultiAddress<Self::AccountId, u32>; type AssetId = (); type ExtrinsicParams = SubstrateExtrinsicParams<Self>; type Hash = subxt::utils::H256; type Hasher = subxt::config::substrate::BlakeTwo256; type Header = subxt::config::substrate::SubstrateHeader<u32, subxt::config::substrate::BlakeTwo256>; - type Signature = sp_runtime::MultiSignature; + type Signature = subxt::utils::MultiSignature; } #[derive(Copy, Clone, Debug, Default, Encode)] @@ -89,7 +88,7 @@ impl From<u64> for Tip { } } -pub const SUDO_ACCOUNT: AccountKeyring = AccountKeyring::Alice; +pub const SUDO_ACCOUNT: Keyring = Keyring::Alice; pub struct Process(std::process::Child); impl Process { @@ -339,3 +338,55 @@ pub fn spawn_distance_oracle(distance_oracle_binary_path: &str, duniter_rpc_port .wait() .unwrap(); } + +/// A concrete PairSigner implementation which relies on `sr25519::Pair` for signing +/// and where GdevConfig is the runtime configuration. +mod pair_signer { + use super::*; + use sp_core::{sr25519, Pair as _}; + use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + MultiSignature as SpMultiSignature, + }; + use subxt::{ + config::substrate::{AccountId32, MultiSignature}, + tx::Signer, + Config, + }; + + #[derive(Clone)] + pub struct PairSigner { + account_id: <GdevConfig as Config>::AccountId, + signer: sr25519::Pair, + } + + impl PairSigner { + pub fn new(signer: sr25519::Pair) -> Self { + let account_id = + <SpMultiSignature as Verify>::Signer::from(signer.public()).into_account(); + Self { + account_id: AccountId32(account_id.into()), + signer, + } + } + + pub fn signer(&self) -> &sr25519::Pair { + &self.signer + } + + pub fn account_id(&self) -> &AccountId32 { + &self.account_id + } + } + + impl Signer<GdevConfig> for PairSigner { + fn account_id(&self) -> <GdevConfig as Config>::AccountId { + self.account_id.clone() + } + + fn sign(&self, signer_payload: &[u8]) -> <GdevConfig as Config>::Signature { + let signature = self.signer.sign(signer_payload); + MultiSignature::Sr25519(signature.0) + } + } +} diff --git a/end2end-tests/tests/common/oneshot.rs b/end2end-tests/tests/common/oneshot.rs index bcfe65dc84f06c40a5b6fbc530180633e750bae6..255d5fd4a6b7ba8fd38bb5c1065cebea754163ed 100644 --- a/end2end-tests/tests/common/oneshot.rs +++ b/end2end-tests/tests/common/oneshot.rs @@ -19,15 +19,13 @@ use super::{ gdev::runtime_types::{pallet_balances, pallet_oneshot_account}, *, }; -use sp_keyring::AccountKeyring; -use subxt::{ - tx::PairSigner, - utils::{AccountId32, MultiAddress}, -}; +use crate::common::pair_signer::PairSigner; +use sp_keyring::sr25519::Keyring; +use subxt::utils::{AccountId32, MultiAddress}; pub enum Account { - Normal(AccountKeyring), - Oneshot(AccountKeyring), + Normal(Keyring), + Oneshot(Keyring), } impl Account { @@ -35,24 +33,24 @@ impl Account { &self, ) -> pallet_oneshot_account::types::Account<MultiAddress<AccountId32, ()>> { match self { - Account::Normal(account) => { - pallet_oneshot_account::types::Account::Normal(account.to_account_id().into()) - } - Account::Oneshot(account) => { - pallet_oneshot_account::types::Account::Oneshot(account.to_account_id().into()) - } + Account::Normal(account) => pallet_oneshot_account::types::Account::Normal( + MultiAddress::Id(account.to_raw_public().into()), + ), + Account::Oneshot(account) => pallet_oneshot_account::types::Account::Oneshot( + MultiAddress::Id(account.to_raw_public().into()), + ), } } } pub async fn create_oneshot_account( client: &FullClient, - from: AccountKeyring, + from: Keyring, amount: u64, - to: AccountKeyring, + to: Keyring, ) -> Result<()> { let from = PairSigner::new(from.pair()); - let to = to.to_account_id(); + let to = MultiAddress::Id(to.to_raw_public().into()); let _events = create_block_with_extrinsic( &client.rpc, @@ -62,7 +60,7 @@ pub async fn create_oneshot_account( .create_signed( &gdev::tx() .oneshot_account() - .create_oneshot_account(to.into(), amount), + .create_oneshot_account(to, amount), &from, SubstrateExtrinsicParamsBuilder::new().build(), ) @@ -75,7 +73,7 @@ pub async fn create_oneshot_account( pub async fn consume_oneshot_account( client: &FullClient, - from: AccountKeyring, + from: Keyring, to: Account, ) -> Result<()> { let from = PairSigner::new(from.pair()); @@ -101,7 +99,7 @@ pub async fn consume_oneshot_account( #[allow(clippy::too_many_arguments)] pub async fn consume_oneshot_account_with_remaining( client: &FullClient, - from: AccountKeyring, + from: Keyring, amount: u64, to: Account, remaining_to: Account, diff --git a/end2end-tests/tests/cucumber_tests.rs b/end2end-tests/tests/cucumber_tests.rs index c653027323240ebb88fa38d2d5cbed8e7c7ddb18..2599ca7d5af9a86eb6d2fe7a6794c74ce8ea52fa 100644 --- a/end2end-tests/tests/cucumber_tests.rs +++ b/end2end-tests/tests/cucumber_tests.rs @@ -18,7 +18,7 @@ mod common; use common::*; use cucumber::{given, then, when, StatsWriter, World}; -use sp_keyring::AccountKeyring; +use sp_keyring::sr25519::Keyring; use std::{ path::PathBuf, str::FromStr, @@ -169,7 +169,7 @@ fn parse_amount(amount: u64, unit: &str) -> (u64, bool) { #[given(regex = r"([a-zA-Z]+) ha(?:ve|s) (\d+) (ĞD|cĞD|UD|mUD)")] async fn who_have(world: &mut DuniterWorld, who: String, amount: u64, unit: String) -> Result<()> { // Parse inputs - let who = AccountKeyring::from_str(&who).expect("unknown to"); + let who = Keyring::from_str(&who).expect("unknown to"); let (mut amount, is_ud) = parse_amount(amount, &unit); if is_ud { @@ -208,8 +208,8 @@ async fn transfer( to: String, ) -> Result<()> { // Parse inputs - let from = AccountKeyring::from_str(&from).expect("unknown from"); - let to = AccountKeyring::from_str(&to).expect("unknown to"); + let from = Keyring::from_str(&from).expect("unknown from"); + let to = Keyring::from_str(&to).expect("unknown to"); let (amount, is_ud) = parse_amount(amount, &unit); let res = if is_ud { @@ -235,8 +235,8 @@ async fn create_oneshot_account( to: String, ) -> Result<()> { // Parse inputs - let from = AccountKeyring::from_str(&from).expect("unknown from"); - let to = AccountKeyring::from_str(&to).expect("unknown to"); + let from = Keyring::from_str(&from).expect("unknown from"); + let to = Keyring::from_str(&to).expect("unknown to"); let (amount, is_ud) = parse_amount(amount, &unit); assert!(!is_ud); @@ -253,8 +253,8 @@ async fn consume_oneshot_account( to: String, ) -> Result<()> { // Parse inputs - let from = AccountKeyring::from_str(&from).expect("unknown from"); - let to = AccountKeyring::from_str(&to).expect("unknown to"); + let from = Keyring::from_str(&from).expect("unknown from"); + let to = Keyring::from_str(&to).expect("unknown to"); let to = match is_dest_oneshot.as_str() { "oneshot" => common::oneshot::Account::Oneshot(to), "account" => common::oneshot::Account::Normal(to), @@ -280,9 +280,9 @@ async fn consume_oneshot_account_with_remaining( remaining_to: String, ) -> Result<()> { // Parse inputs - let from = AccountKeyring::from_str(&from).expect("unknown from"); - let to = AccountKeyring::from_str(&to).expect("unknown to"); - let remaining_to = AccountKeyring::from_str(&remaining_to).expect("unknown remaining_to"); + let from = Keyring::from_str(&from).expect("unknown from"); + let to = Keyring::from_str(&to).expect("unknown to"); + let remaining_to = Keyring::from_str(&remaining_to).expect("unknown remaining_to"); let to = match is_dest_oneshot.as_str() { "oneshot" => common::oneshot::Account::Oneshot(to), "account" => common::oneshot::Account::Normal(to), @@ -311,8 +311,8 @@ async fn consume_oneshot_account_with_remaining( #[when(regex = r"([a-zA-Z]+) sends? all (?:his|her) (?:ĞDs?|DUs?|UDs?) to ([a-zA-Z]+)")] async fn send_all_to(world: &mut DuniterWorld, from: String, to: String) -> Result<()> { // Parse inputs - let from = AccountKeyring::from_str(&from).expect("unknown from"); - let to = AccountKeyring::from_str(&to).expect("unknown to"); + let from = Keyring::from_str(&from).expect("unknown from"); + let to = Keyring::from_str(&to).expect("unknown to"); common::balances::transfer_all(world.full_client(), from, to).await } @@ -321,8 +321,8 @@ async fn send_all_to(world: &mut DuniterWorld, from: String, to: String) -> Resu #[when(regex = r"([a-zA-Z]+) certifies ([a-zA-Z]+)")] async fn certifies(world: &mut DuniterWorld, from: String, to: String) -> Result<()> { // Parse inputs - let from = AccountKeyring::from_str(&from).expect("unknown from"); - let to = AccountKeyring::from_str(&to).expect("unknown to"); + let from = Keyring::from_str(&from).expect("unknown from"); + let to = Keyring::from_str(&to).expect("unknown to"); common::cert::certify(world.full_client(), from, to).await } @@ -331,8 +331,8 @@ async fn certifies(world: &mut DuniterWorld, from: String, to: String) -> Result #[when(regex = r"([a-zA-Z]+) creates identity for ([a-zA-Z]+)")] async fn creates_identity(world: &mut DuniterWorld, from: String, to: String) -> Result<()> { // Parse inputs - let from = AccountKeyring::from_str(&from).expect("unknown from"); - let to = AccountKeyring::from_str(&to).expect("unknown to"); + let from = Keyring::from_str(&from).expect("unknown from"); + let to = Keyring::from_str(&to).expect("unknown to"); common::identity::create_identity(world.full_client(), from, to).await } @@ -340,7 +340,7 @@ async fn creates_identity(world: &mut DuniterWorld, from: String, to: String) -> #[allow(clippy::needless_pass_by_ref_mut)] #[when(regex = r#"([a-zA-Z]+) confirms (?:his|her) identity with pseudo "([a-zA-Z]+)""#)] async fn confirm_identity(world: &mut DuniterWorld, from: String, pseudo: String) -> Result<()> { - let from = AccountKeyring::from_str(&from).expect("unknown from"); + let from = Keyring::from_str(&from).expect("unknown from"); common::identity::confirm_identity(world.full_client(), from, pseudo).await } @@ -348,7 +348,7 @@ async fn confirm_identity(world: &mut DuniterWorld, from: String, pseudo: String #[allow(clippy::needless_pass_by_ref_mut)] #[when(regex = r#"([a-zA-Z]+) requests distance evaluation"#)] async fn request_distance_evaluation(world: &mut DuniterWorld, who: String) -> Result<()> { - let who = AccountKeyring::from_str(&who).expect("unknown origin"); + let who = Keyring::from_str(&who).expect("unknown origin"); common::distance::request_evaluation(world.full_client(), who).await } @@ -356,7 +356,7 @@ async fn request_distance_evaluation(world: &mut DuniterWorld, who: String) -> R #[allow(clippy::needless_pass_by_ref_mut)] #[when(regex = r#"([a-zA-Z]+) runs distance oracle"#)] async fn run_distance_oracle(world: &mut DuniterWorld, who: String) -> Result<()> { - let who = AccountKeyring::from_str(&who).expect("unknown origin"); + let who = Keyring::from_str(&who).expect("unknown origin"); common::distance::run_oracle( world.full_client(), @@ -398,9 +398,9 @@ async fn should_have( reserved: String, ) -> Result<()> { // Parse inputs - let who: subxt::utils::AccountId32 = AccountKeyring::from_str(&who) + let who: subxt::utils::AccountId32 = Keyring::from_str(&who) .expect("unknown to") - .to_account_id() + .to_raw_public() .into(); let (amount, _is_ud) = parse_amount(amount, &unit); @@ -425,9 +425,9 @@ async fn should_have_oneshot( unit: String, ) -> Result<()> { // Parse inputs - let who: subxt::utils::AccountId32 = AccountKeyring::from_str(&who) + let who: subxt::utils::AccountId32 = Keyring::from_str(&who) .expect("unknown to") - .to_account_id() + .to_raw_public() .into(); let (amount, _is_ud) = parse_amount(amount, &unit); @@ -475,13 +475,13 @@ async fn should_be_certified_by( issuer: String, ) -> Result<()> { // Parse inputs - let receiver_account: subxt::utils::AccountId32 = AccountKeyring::from_str(&receiver) + let receiver_account: subxt::utils::AccountId32 = Keyring::from_str(&receiver) .expect("unknown to") - .to_account_id() + .to_raw_public() .into(); - let issuer_account: subxt::utils::AccountId32 = AccountKeyring::from_str(&issuer) + let issuer_account: subxt::utils::AccountId32 = Keyring::from_str(&issuer) .expect("unknown to") - .to_account_id() + .to_raw_public() .into(); // get corresponding identities index diff --git a/pallets/authority-members/src/mock.rs b/pallets/authority-members/src/mock.rs index 1a582ef73b4a31082c1fc11bd90f28012920d8f5..23dcd5a6617e9de33d571377da4d15a560004e5d 100644 --- a/pallets/authority-members/src/mock.rs +++ b/pallets/authority-members/src/mock.rs @@ -103,6 +103,7 @@ impl ShouldEndSession<u64> for TestShouldEndSession { } impl pallet_session::Config for Test { + type DisablingStrategy = (); type Keys = MockSessionKeys; type NextSessionRotation = (); type RuntimeEvent = RuntimeEvent; diff --git a/pallets/distance/src/mock.rs b/pallets/distance/src/mock.rs index 23f8652124bfcdaf381c892400322dd74920916d..e72adceae674b16888ec08edbd4c24cd722f66c5 100644 --- a/pallets/distance/src/mock.rs +++ b/pallets/distance/src/mock.rs @@ -51,7 +51,16 @@ impl From<[u8; 32]> for AccountId32Mock { } /// Test signature that impl From<ed25519::Signature> (required to compile pallet identity) -#[derive(Clone, codec::Decode, Debug, Eq, codec::Encode, PartialEq, scale_info::TypeInfo)] +#[derive( + Clone, + codec::DecodeWithMemTracking, + codec::Decode, + Debug, + Eq, + codec::Encode, + PartialEq, + scale_info::TypeInfo, +)] pub struct TestSignature(SubtrateTestSignature); impl From<sp_core::ed25519::Signature> for TestSignature { fn from(_: sp_core::ed25519::Signature) -> Self { @@ -143,6 +152,7 @@ impl ShouldEndSession<u64> for TestShouldEndSession { } impl pallet_session::Config for Test { + type DisablingStrategy = (); type Keys = MockSessionKeys; type NextSessionRotation = (); type RuntimeEvent = RuntimeEvent; diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index 0685fc5d3466da6cabec09f14d0402b73cbdecce..0a73b16234947373f353f2b1c27d9f5c7f11853a 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -45,7 +45,16 @@ impl From<[u8; 32]> for AccountId32Mock { } /// Test signature that impl From<ed25519::Signature> (required to compile pallet identity) -#[derive(Clone, codec::Decode, Debug, Eq, codec::Encode, PartialEq, scale_info::TypeInfo)] +#[derive( + Clone, + codec::DecodeWithMemTracking, + codec::Decode, + Debug, + Eq, + codec::Encode, + PartialEq, + scale_info::TypeInfo, +)] pub struct TestSignature(SubtrateTestSignature); impl TestSignature { diff --git a/runtime/gdev/tests/balance_tests.rs b/runtime/gdev/tests/balance_tests.rs index 0d3955c5445073380e0871361fc7a603fcff2b1d..93516456b2673a8278138f671b07ff96fd67c228 100644 --- a/runtime/gdev/tests/balance_tests.rs +++ b/runtime/gdev/tests/balance_tests.rs @@ -22,7 +22,7 @@ use common::*; use frame_support::{assert_noop, assert_ok, traits::StoredMap}; use gdev_runtime::*; use sp_core::Encode; -use sp_keyring::AccountKeyring; +use sp_keyring::sr25519::Keyring; use sp_runtime::MultiAddress; /// test currency transfer @@ -32,24 +32,24 @@ use sp_runtime::MultiAddress; fn test_transfer() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { // Alice gives 500 to Eve assert_ok!(Balances::transfer_allow_death( - frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), - AccountKeyring::Eve.to_account_id().into(), + frame_system::RawOrigin::Signed(Keyring::Alice.to_account_id()).into(), + Keyring::Eve.to_account_id().into(), 500 )); // check amounts assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 10_000 - 500 ); assert_eq!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), + Balances::free_balance(Keyring::Eve.to_account_id()), 10_000 + 500 ); }) @@ -59,14 +59,14 @@ fn test_transfer() { #[test] fn test_transfer_not_enough() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 599)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 599)]) .build() .execute_with(|| { run_to_block(1); assert_noop!( Balances::transfer_allow_death( - frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), - AccountKeyring::Dave.to_account_id().into(), + frame_system::RawOrigin::Signed(Keyring::Alice.to_account_id()).into(), + Keyring::Dave.to_account_id().into(), 500 ), sp_runtime::TokenError::Frozen // frozen because trying to transfer more than liquid @@ -79,15 +79,15 @@ fn test_transfer_not_enough() { #[test] fn test_transfer_underflow() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 400)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 400)]) .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(), + frame_system::RawOrigin::Signed(Keyring::Alice.to_account_id()).into(), + Keyring::Dave.to_account_id().into(), 500 // larger than total issuance ), sp_runtime::ArithmeticError::Underflow @@ -101,16 +101,16 @@ fn test_transfer_underflow() { fn test_transfer_funds_unavailable() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 499), - (AccountKeyring::Bob.to_account_id(), 200), + (Keyring::Alice.to_account_id(), 499), + (Keyring::Bob.to_account_id(), 200), ]) .build() .execute_with(|| { run_to_block(1); assert_noop!( Balances::transfer_allow_death( - frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), - AccountKeyring::Dave.to_account_id().into(), + frame_system::RawOrigin::Signed(Keyring::Alice.to_account_id()).into(), + Keyring::Dave.to_account_id().into(), 500 ), sp_runtime::TokenError::FundsUnavailable @@ -122,16 +122,16 @@ fn test_transfer_funds_unavailable() { #[test] fn test_transfer_all_linked_no_member() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 5_000)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 5_000)]) .build() .execute_with(|| { run_to_block(1); let genesis_hash = System::block_hash(0); - let alice = AccountKeyring::Alice.to_account_id(); - let ferdie = AccountKeyring::Ferdie.to_account_id(); + let alice = Keyring::Alice.to_account_id(); + let ferdie = Keyring::Ferdie.to_account_id(); let payload = (b"link", genesis_hash, 1u32, ferdie.clone()).encode(); - let signature = AccountKeyring::Ferdie.sign(&payload); + let signature = Keyring::Ferdie.sign(&payload); assert_ok!(Balances::transfer_allow_death( frame_system::RawOrigin::Signed(alice.clone()).into(), @@ -150,7 +150,7 @@ fn test_transfer_all_linked_no_member() { ); assert_ok!(Balances::transfer_all( frame_system::RawOrigin::Signed(ferdie.clone()).into(), - AccountKeyring::Bob.to_account_id().into(), + Keyring::Bob.to_account_id().into(), false ),); assert_eq!(Balances::free_balance(ferdie.clone()), 0); diff --git a/runtime/gdev/tests/common/mod.rs b/runtime/gdev/tests/common/mod.rs index b8d13eaefae415969b7c4c2f295931f6042966b5..6f4d0ed904894b641ee58b7c2a386ef2af997f6e 100644 --- a/runtime/gdev/tests/common/mod.rs +++ b/runtime/gdev/tests/common/mod.rs @@ -25,7 +25,7 @@ use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::{AuthorityId as BabeId, Slot, VrfInput, VrfProof}; use sp_consensus_grandpa::AuthorityId as GrandpaId; use sp_core::{crypto::IsWrappedBy, sr25519, Encode, Pair, Public, H256}; -use sp_keyring::AccountKeyring; +use sp_keyring::sr25519::Keyring; use sp_membership::MembershipData; use sp_runtime::{ generic::SignedPayload, @@ -488,7 +488,7 @@ pub fn get_unchecked_extrinsic( call: RuntimeCall, era: u64, block: u64, - signer: AccountKeyring, + signer: Keyring, tip: Balance, nonce: u32, ) -> gdev_runtime::UncheckedExtrinsic { diff --git a/runtime/gdev/tests/fee_tests.rs b/runtime/gdev/tests/fee_tests.rs index 14c7f15e3e1e6cc3466913e4bfdeb9f4c0be7839..c4647a6d4da8fdd7d6ecd439b0cd93be8ab4b598 100644 --- a/runtime/gdev/tests/fee_tests.rs +++ b/runtime/gdev/tests/fee_tests.rs @@ -21,35 +21,28 @@ mod common; use common::*; use frame_support::{assert_ok, pallet_prelude::DispatchClass}; use gdev_runtime::*; -use sp_keyring::AccountKeyring; +use sp_keyring::sr25519::Keyring; /// This test checks that an almost empty block incurs no fees for an extrinsic. #[test] fn test_fees_empty() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { - dest: AccountKeyring::Eve.to_account_id().into(), + dest: Keyring::Eve.to_account_id().into(), value: 500, }); - let xt = common::get_unchecked_extrinsic( - call, - 4u64, - 8u64, - AccountKeyring::Alice, - 0u64, - 0u32, - ); + let xt = common::get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Alice, 0u64, 0u32); assert_ok!(Executive::apply_extrinsic(xt)); // The block is almost empty, so the extrinsic should incur no fee assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 10_000 - 500 ); }) @@ -62,8 +55,8 @@ fn test_fees_empty() { fn test_fees_weight() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { @@ -79,10 +72,10 @@ fn test_fees_weight() { let call = RuntimeCall::System(SystemCall::remark { remark: vec![255u8; 1], }); - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 0u64, 0); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Alice, 0u64, 0); assert_ok!(Executive::apply_extrinsic(xt)); assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 10_000 ); @@ -93,10 +86,10 @@ fn test_fees_weight() { remark: vec![255u8; 1], }); - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 0u64, 1u32); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Alice, 0u64, 1u32); assert_ok!(Executive::apply_extrinsic(xt)); assert_ne!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 10_000 ); }) @@ -109,8 +102,8 @@ fn test_fees_weight() { fn test_fees_length() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { @@ -122,10 +115,10 @@ fn test_fees_length() { let call = RuntimeCall::System(SystemCall::remark { remark: vec![255u8; 100], }); - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 0u64, 0u32); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Alice, 0u64, 0u32); assert_ok!(Executive::apply_extrinsic(xt)); assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 10_000 ); @@ -134,10 +127,10 @@ fn test_fees_length() { let call = RuntimeCall::System(SystemCall::remark { remark: vec![0u8; 147], }); - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 0u64, 1u32); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Alice, 0u64, 1u32); assert_ok!(Executive::apply_extrinsic(xt)); assert_ne!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 10_000 ); @@ -151,12 +144,9 @@ fn test_fees_length() { remark: vec![255u8; 1], }); - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Eve, 0u64, 0u32); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Eve, 0u64, 0u32); assert_ok!(Executive::apply_extrinsic(xt)); - assert_ne!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), - 10_000 - ); + assert_ne!(Balances::free_balance(Keyring::Eve.to_account_id()), 10_000); }) } @@ -166,8 +156,8 @@ fn test_fees_length() { fn test_fees_multiplier_weight() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { @@ -214,8 +204,8 @@ fn test_fees_multiplier_weight() { fn test_fees_multiplier_length() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 4031f377f9bd11cdf86ae4c744232819ee21ebc8..463f8842e26a01131ab2bad379d01b6b5b10dfed 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -29,7 +29,7 @@ use pallet_session::historical::SessionManager; use pallet_smith_members::{SmithMeta, SmithStatus}; use scale_info::prelude::num::NonZeroU16; use sp_core::{Encode, Pair}; -use sp_keyring::AccountKeyring; +use sp_keyring::sr25519::Keyring; use sp_runtime::MultiAddress; #[test] @@ -96,35 +96,26 @@ fn test_genesis_build() { fn test_initial_state() { ExtBuilder::new(1, 2, 3) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 1_000), - (AccountKeyring::Bob.to_account_id(), 200), - (AccountKeyring::Charlie.to_account_id(), 100), // below ED allowed for identities - (AccountKeyring::Dave.to_account_id(), 900), + (Keyring::Alice.to_account_id(), 1_000), + (Keyring::Bob.to_account_id(), 200), + (Keyring::Charlie.to_account_id(), 100), // below ED allowed for identities + (Keyring::Dave.to_account_id(), 900), ]) .build() .execute_with(|| { run_to_block(1); assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 1_000 ); + assert_eq!(Balances::free_balance(Keyring::Bob.to_account_id()), 200); assert_eq!( - Balances::free_balance(AccountKeyring::Bob.to_account_id()), - 200 - ); - assert_eq!( - Balances::free_balance(AccountKeyring::Charlie.to_account_id()), + Balances::free_balance(Keyring::Charlie.to_account_id()), 100 ); - assert_eq!( - Balances::free_balance(AccountKeyring::Dave.to_account_id()), - 900 - ); - assert_eq!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), - 0 - ); + assert_eq!(Balances::free_balance(Keyring::Dave.to_account_id()), 900); + assert_eq!(Balances::free_balance(Keyring::Eve.to_account_id()), 0); // total issuance and monetary mass should be coherent assert_eq!(Balances::total_issuance(), 2_200); assert_eq!( @@ -141,9 +132,9 @@ fn test_initial_state() { fn test_total_issuance_vs_monetary_mass() { ExtBuilder::new(1, 2, 3) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 2000), - (AccountKeyring::Bob.to_account_id(), 1000), - (AccountKeyring::Charlie.to_account_id(), 0), + (Keyring::Alice.to_account_id(), 2000), + (Keyring::Bob.to_account_id(), 1000), + (Keyring::Charlie.to_account_id(), 0), ]) .build() .execute_with(|| { @@ -167,7 +158,7 @@ fn test_total_issuance_vs_monetary_mass() { ); // Alice claims her UD assert_ok!(UniversalDividend::claim_uds(RuntimeOrigin::signed( - AccountKeyring::Alice.to_account_id() + Keyring::Alice.to_account_id() ))); assert_eq!(Balances::total_issuance(), 4000); assert_eq!( @@ -178,7 +169,7 @@ fn test_total_issuance_vs_monetary_mass() { run_to_block(21); // Bob claims his 2 UDs assert_ok!(UniversalDividend::claim_uds(RuntimeOrigin::signed( - AccountKeyring::Bob.to_account_id() + Keyring::Bob.to_account_id() ))); assert_eq!(Balances::total_issuance(), 6000); assert_eq!( @@ -192,7 +183,7 @@ fn test_total_issuance_vs_monetary_mass() { #[test] fn test_identity_below_ed() { ExtBuilder::new(1, 1, 1) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 900)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 900)]) .build() .execute_with(|| { run_to_block(1); @@ -200,8 +191,8 @@ fn test_identity_below_ed() { // a transfer below ED will lead to frozen token error assert_noop!( Balances::transfer_allow_death( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - MultiAddress::Id(AccountKeyring::Bob.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + MultiAddress::Id(Keyring::Bob.to_account_id()), 850 ), sp_runtime::TokenError::Frozen @@ -209,33 +200,33 @@ fn test_identity_below_ed() { // // Old behavior below // // Should be able to go below existential deposit, loose dust, and still not die // assert_ok!(Balances::transfer( - // RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - // MultiAddress::Id(AccountKeyring::Bob.to_account_id()), + // RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + // MultiAddress::Id(Keyring::Bob.to_account_id()), // 800 // )); // assert_eq!( - // Balances::free_balance(AccountKeyring::Alice.to_account_id()), + // Balances::free_balance(Keyring::Alice.to_account_id()), // 0 // ); // assert_eq!( - // Balances::free_balance(AccountKeyring::Bob.to_account_id()), + // Balances::free_balance(Keyring::Bob.to_account_id()), // 800 // ); // // since alice is identity, her account should not be killed even she lost currency below ED // System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Transfer { - // from: AccountKeyring::Alice.to_account_id(), - // to: AccountKeyring::Bob.to_account_id(), + // from: Keyring::Alice.to_account_id(), + // to: Keyring::Bob.to_account_id(), // amount: 800, // })); // System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::DustLost { - // account: AccountKeyring::Alice.to_account_id(), + // account: Keyring::Alice.to_account_id(), // amount: 100, // })); // System::assert_has_event(RuntimeEvent::System(frame_system::Event::NewAccount { - // account: AccountKeyring::Bob.to_account_id(), + // account: Keyring::Bob.to_account_id(), // })); // System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Endowed { - // account: AccountKeyring::Bob.to_account_id(), + // account: Keyring::Bob.to_account_id(), // free_balance: 800, // })); }) @@ -319,7 +310,7 @@ fn test_remove_identity() { )); // since Dave does not have ED, his account is killed System::assert_has_event(RuntimeEvent::System(frame_system::Event::KilledAccount { - account: AccountKeyring::Dave.to_account_id(), + account: Keyring::Dave.to_account_id(), })); }); } @@ -329,37 +320,37 @@ fn test_remove_identity() { fn test_validate_identity_when_claim() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Eve.to_account_id(), 2000), - (AccountKeyring::Ferdie.to_account_id(), 1000), + (Keyring::Eve.to_account_id(), 2000), + (Keyring::Ferdie.to_account_id(), 1000), ]) .build() .execute_with(|| { run_to_block(1); // alice create identity for Eve assert_ok!(Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Eve.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Eve.to_account_id(), )); run_to_block(2); // eve confirms her identity assert_ok!(Identity::confirm_identity( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), "Eeeeeveeeee".into(), )); run_to_block(3); // eve gets certified by bob and charlie assert_ok!(Certification::add_cert( - RuntimeOrigin::signed(AccountKeyring::Bob.to_account_id()), + RuntimeOrigin::signed(Keyring::Bob.to_account_id()), 5 )); assert_ok!(Certification::add_cert( - RuntimeOrigin::signed(AccountKeyring::Charlie.to_account_id()), + RuntimeOrigin::signed(Keyring::Charlie.to_account_id()), 5 )); // eve request distance evaluation for herself assert_ok!(Distance::request_distance_evaluation( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), )); // Pass 2nd evaluation period @@ -368,7 +359,7 @@ fn test_validate_identity_when_claim() { // simulate an evaluation published by smith Alice assert_ok!(Distance::force_update_evaluation( RuntimeOrigin::root(), - AccountKeyring::Alice.to_account_id(), + Keyring::Alice.to_account_id(), pallet_distance::ComputationResult { distances: vec![Perbill::one()], } @@ -386,7 +377,7 @@ fn test_validate_identity_when_claim() { // the following call does not exist anymore // assert_noop!( // Membership::claim_membership( - // RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + // RuntimeOrigin::signed(Keyring::Eve.to_account_id()), // ), // pallet_membership::Error::<Runtime>::AlreadyMember // ); @@ -408,17 +399,17 @@ fn test_validate_identity_when_claim() { fn test_identity_creation_workflow() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Charlie.to_account_id(), 10_000), // necessary for evalation distance reserve - (AccountKeyring::Eve.to_account_id(), 2_000), - (AccountKeyring::Ferdie.to_account_id(), 1_000), + (Keyring::Charlie.to_account_id(), 10_000), // necessary for evalation distance reserve + (Keyring::Eve.to_account_id(), 2_000), + (Keyring::Ferdie.to_account_id(), 1_000), ]) .build() .execute_with(|| { run_to_block(1); // alice create identity for Eve assert_ok!(Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Eve.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Eve.to_account_id(), )); assert_eq!( Identity::identity(5), @@ -426,7 +417,7 @@ fn test_identity_creation_workflow() { data: Default::default(), next_creatable_identity_on: 0u32, old_owner_key: None, - owner_key: AccountKeyring::Eve.to_account_id(), + owner_key: Keyring::Eve.to_account_id(), next_scheduled: 1 + 40, status: pallet_identity::IdtyStatus::Unconfirmed, }) @@ -434,7 +425,7 @@ fn test_identity_creation_workflow() { run_to_block(2); // eve confirms her identity assert_ok!(Identity::confirm_identity( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), "Eeeeeveeeee".into(), )); assert_eq!( @@ -443,7 +434,7 @@ fn test_identity_creation_workflow() { data: Default::default(), next_creatable_identity_on: 0u32, old_owner_key: None, - owner_key: AccountKeyring::Eve.to_account_id(), + owner_key: Keyring::Eve.to_account_id(), next_scheduled: 2 + 876600, status: pallet_identity::IdtyStatus::Unvalidated, }) @@ -451,23 +442,23 @@ fn test_identity_creation_workflow() { run_to_block(3); // eve gets certified by bob and charlie assert_ok!(Certification::add_cert( - RuntimeOrigin::signed(AccountKeyring::Bob.to_account_id()), + RuntimeOrigin::signed(Keyring::Bob.to_account_id()), 5 )); assert_ok!(Certification::add_cert( - RuntimeOrigin::signed(AccountKeyring::Charlie.to_account_id()), + RuntimeOrigin::signed(Keyring::Charlie.to_account_id()), 5 )); // charlie also request distance evaluation for eve // (could be done in batch) assert_ok!(Distance::request_distance_evaluation_for( - RuntimeOrigin::signed(AccountKeyring::Charlie.to_account_id()), + RuntimeOrigin::signed(Keyring::Charlie.to_account_id()), 5 )); // then the evaluation is pending assert_eq!( Distance::pending_evaluation_request(5), - Some(AccountKeyring::Charlie.to_account_id(),) + Some(Keyring::Charlie.to_account_id(),) ); // Pass 2nd evaluation period @@ -476,7 +467,7 @@ fn test_identity_creation_workflow() { // simulate evaluation published by smith Alice assert_ok!(Distance::force_update_evaluation( RuntimeOrigin::root(), - AccountKeyring::Alice.to_account_id(), + Keyring::Alice.to_account_id(), pallet_distance::ComputationResult { distances: vec![Perbill::one()], } @@ -509,7 +500,7 @@ fn test_identity_creation_workflow() { }, next_creatable_identity_on: 0u32, old_owner_key: None, - owner_key: AccountKeyring::Eve.to_account_id(), + owner_key: Keyring::Eve.to_account_id(), next_scheduled: 0, status: pallet_identity::IdtyStatus::Member, }) @@ -525,13 +516,13 @@ fn test_identity_creation_workflow() { }, )); assert_ok!(UniversalDividend::claim_uds(RuntimeOrigin::signed( - AccountKeyring::Eve.to_account_id() + Keyring::Eve.to_account_id() ),)); System::assert_has_event(RuntimeEvent::UniversalDividend( pallet_universal_dividend::Event::UdsClaimed { count: (10 - first_eligible), total: (10 - first_eligible as u64) * 1_000, - who: AccountKeyring::Eve.to_account_id(), + who: Keyring::Eve.to_account_id(), }, )); }); @@ -554,10 +545,7 @@ fn test_can_not_issue_cert_when_membership_lost() { // Bob can not issue a certification assert_noop!( - Certification::add_cert( - RuntimeOrigin::signed(AccountKeyring::Bob.to_account_id()), - 3, - ), + Certification::add_cert(RuntimeOrigin::signed(Keyring::Bob.to_account_id()), 3,), pallet_duniter_wot::Error::<gdev_runtime::Runtime>::IssuerNotMember ); }); @@ -609,13 +597,13 @@ fn test_membership_expiry_with_identity_removal() { #[test] fn test_membership_renewal() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 2000)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 2000)]) .build() .execute_with(|| { // can not renew membership immediately assert_noop!( Distance::request_distance_evaluation(RuntimeOrigin::signed( - AccountKeyring::Alice.to_account_id() + Keyring::Alice.to_account_id() ),), pallet_duniter_wot::Error::<Runtime>::MembershipRenewalPeriodNotRespected, ); @@ -623,7 +611,7 @@ fn test_membership_renewal() { // but ok after waiting 10 blocks delay run_to_block(11); assert_ok!(Distance::request_distance_evaluation( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), )); // Pass 3rd evaluation period @@ -631,7 +619,7 @@ fn test_membership_renewal() { run_to_block(3 * eval_period); assert_ok!(Distance::force_update_evaluation( RuntimeOrigin::root(), - AccountKeyring::Alice.to_account_id(), + Keyring::Alice.to_account_id(), pallet_distance::ComputationResult { distances: vec![Perbill::one()], } @@ -651,7 +639,7 @@ fn test_membership_renewal() { // can not ask renewal when period is not respected assert_noop!( Distance::request_distance_evaluation(RuntimeOrigin::signed( - AccountKeyring::Alice.to_account_id() + Keyring::Alice.to_account_id() ),), pallet_duniter_wot::Error::<Runtime>::MembershipRenewalPeriodNotRespected, ); @@ -679,8 +667,7 @@ fn test_revoke_identity_should_unlink() { Identity::do_revoke_identity(1, pallet_identity::RevocationReason::Root); assert_eq!( - frame_system::Pallet::<Runtime>::get(&AccountKeyring::Alice.to_account_id()) - .linked_idty, + frame_system::Pallet::<Runtime>::get(&Keyring::Alice.to_account_id()).linked_idty, None ); }) @@ -699,10 +686,7 @@ fn test_revoke_identity_after_one_ud() { // before UD, dave has 0 (initial amount) run_to_block(1); - assert_eq!( - Balances::free_balance(AccountKeyring::Dave.to_account_id()), - 0 - ); + assert_eq!(Balances::free_balance(Keyring::Dave.to_account_id()), 0); // go after UD creation block run_to_block( @@ -719,12 +703,12 @@ fn test_revoke_identity_after_one_ud() { pallet_universal_dividend::Event::UdsAutoPaid { count: 1, total: 1_000, - who: AccountKeyring::Dave.to_account_id(), + who: Keyring::Dave.to_account_id(), }, )); // dave account actually received this UD System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Deposit { - who: AccountKeyring::Dave.to_account_id(), + who: Keyring::Dave.to_account_id(), amount: 1_000, })); // membership and identity were actually removed @@ -742,10 +726,7 @@ fn test_revoke_identity_after_one_ud() { )); assert!(Identity::identity(4).is_some()); // identity still exists, but its status is revoked - assert_eq!( - Balances::free_balance(AccountKeyring::Dave.to_account_id()), - 1_000 - ); + assert_eq!(Balances::free_balance(Keyring::Dave.to_account_id()), 1_000); }); } @@ -761,18 +742,12 @@ fn test_claim_ud_after_revoke() { // before UD, bob has 0 (initial amount) run_to_block(1); - assert_eq!( - Balances::free_balance(AccountKeyring::Bob.to_account_id()), - 0 - ); + assert_eq!(Balances::free_balance(Keyring::Bob.to_account_id()), 0); // revoke identity Identity::do_revoke_identity(2, pallet_identity::RevocationReason::Root); - assert_eq!( - Balances::free_balance(AccountKeyring::Bob.to_account_id()), - 1_000 - ); + assert_eq!(Balances::free_balance(Keyring::Bob.to_account_id()), 1_000); // go after UD creation block run_to_block( @@ -781,22 +756,14 @@ fn test_claim_ud_after_revoke() { + 1) as u32, ); - assert_eq!( - Balances::free_balance(AccountKeyring::Bob.to_account_id()), - 1_000 - ); + assert_eq!(Balances::free_balance(Keyring::Bob.to_account_id()), 1_000); assert_err!( - UniversalDividend::claim_uds(RuntimeOrigin::signed( - AccountKeyring::Bob.to_account_id() - )), + UniversalDividend::claim_uds(RuntimeOrigin::signed(Keyring::Bob.to_account_id())), pallet_universal_dividend::Error::<Runtime>::AccountNotAllowedToClaimUds, ); - assert_eq!( - Balances::free_balance(AccountKeyring::Bob.to_account_id()), - 1_000 - ); + assert_eq!(Balances::free_balance(Keyring::Bob.to_account_id()), 1_000); }); } @@ -816,10 +783,7 @@ fn test_ud_claimed_membership_on_and_off() { }, )); // UD not claimed, still initial balance to initial 0 - assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), - 0 - ); + assert_eq!(Balances::free_balance(Keyring::Alice.to_account_id()), 0); run_to_block(13); // alice identity expires @@ -828,14 +792,11 @@ fn test_ud_claimed_membership_on_and_off() { pallet_universal_dividend::Event::UdsAutoPaid { count: 1, total: 1_000, - who: AccountKeyring::Alice.to_account_id(), + who: Keyring::Alice.to_account_id(), }, )); // alice balances should be increased by 1 UD - assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), - 1000 - ); + assert_eq!(Balances::free_balance(Keyring::Alice.to_account_id()), 1000); // UD number 2 run_to_block(14); @@ -857,7 +818,7 @@ fn test_ud_claimed_membership_on_and_off() { // because the call does not exist anymore // assert_noop!( // Membership::claim_membership( - // RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), + // RuntimeOrigin::signed(Keyring::Alice.to_account_id()), // ), // pallet_membership::Error::<Runtime>::AlreadyMember // ); @@ -882,17 +843,17 @@ fn test_ud_claimed_membership_on_and_off() { // one block later, alice claims her new UD run_to_block(25); assert_ok!(UniversalDividend::claim_uds(RuntimeOrigin::signed( - AccountKeyring::Alice.to_account_id() + Keyring::Alice.to_account_id() ))); System::assert_has_event(RuntimeEvent::UniversalDividend( pallet_universal_dividend::Event::UdsClaimed { count: 1, total: 1_000, - who: AccountKeyring::Alice.to_account_id(), + who: Keyring::Alice.to_account_id(), }, )); assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 2000 // one more UD ); @@ -935,18 +896,12 @@ fn test_smith_certification() { run_to_block(1); assert_noop!( - SmithMembers::certify_smith( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - 2 - ), + SmithMembers::certify_smith(RuntimeOrigin::signed(Keyring::Alice.to_account_id()), 2), pallet_smith_members::Error::<Runtime>::CertificationAlreadyExists ); assert_noop!( - SmithMembers::certify_smith( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - 4 - ), + SmithMembers::certify_smith(RuntimeOrigin::signed(Keyring::Alice.to_account_id()), 4), pallet_smith_members::Error::<Runtime>::CertificationReceiverMustHaveBeenInvited ); }); @@ -965,15 +920,15 @@ fn create_dummy_session_keys() -> gdev_runtime::opaque::SessionKeys { #[test] fn test_smith_process() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Dave.to_account_id(), 1_000)]) + .with_initial_balances(vec![(Keyring::Dave.to_account_id(), 1_000)]) .build() .execute_with(|| { run_to_block(1); - let alice = AccountKeyring::Alice.to_account_id(); - let bob = AccountKeyring::Bob.to_account_id(); - let charlie = AccountKeyring::Charlie.to_account_id(); - let dave = AccountKeyring::Dave.to_account_id(); + let alice = Keyring::Alice.to_account_id(); + let bob = Keyring::Bob.to_account_id(); + let charlie = Keyring::Charlie.to_account_id(); + let dave = Keyring::Dave.to_account_id(); let dummy_session_keys = create_dummy_session_keys(); // Eve can not request smith membership because not member of the smith wot @@ -991,7 +946,7 @@ fn test_smith_process() { // Dave cannot (yet) set his session keys assert_err!( AuthorityMembers::set_session_keys( - RuntimeOrigin::signed(AccountKeyring::Dave.to_account_id()), + RuntimeOrigin::signed(Keyring::Dave.to_account_id()), dummy_session_keys.clone() ), pallet_authority_members::Error::<Runtime>::NotMember @@ -1026,13 +981,13 @@ fn test_smith_process() { // Dave can set his (dummy) session keys assert_ok!(AuthorityMembers::set_session_keys( - RuntimeOrigin::signed(AccountKeyring::Dave.to_account_id()), + RuntimeOrigin::signed(Keyring::Dave.to_account_id()), dummy_session_keys )); // Dave can go online assert_ok!(AuthorityMembers::go_online(RuntimeOrigin::signed( - AccountKeyring::Dave.to_account_id() + Keyring::Dave.to_account_id() ),)); }) } @@ -1132,7 +1087,7 @@ fn test_expired_smith_has_null_expires_on() { #[test] fn test_create_new_account() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 1_000)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 1_000)]) .build() .execute_with(|| { run_to_block(2); @@ -1140,49 +1095,43 @@ fn test_create_new_account() { // Should be able to transfer 5 units to a new account assert_ok!(Balances::transfer_allow_death( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - MultiAddress::Id(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + MultiAddress::Id(Keyring::Eve.to_account_id()), 500 )); //println!("{:#?}", System::events()); System::assert_has_event(RuntimeEvent::System(frame_system::Event::NewAccount { - account: AccountKeyring::Eve.to_account_id(), + account: Keyring::Eve.to_account_id(), })); System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Endowed { - account: AccountKeyring::Eve.to_account_id(), + account: Keyring::Eve.to_account_id(), free_balance: 500, })); System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: AccountKeyring::Alice.to_account_id(), - to: AccountKeyring::Eve.to_account_id(), + from: Keyring::Alice.to_account_id(), + to: Keyring::Eve.to_account_id(), amount: 500, })); // The new account must be created immediately - assert_eq!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), - 500 - ); + assert_eq!(Balances::free_balance(Keyring::Eve.to_account_id()), 500); // 100 initial + no deposit (there is no account creation fee) assert_eq!(Balances::free_balance(Treasury::account_id()), 100); // can remove an account using transfer assert_ok!(Balances::transfer_allow_death( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), - MultiAddress::Id(AccountKeyring::Alice.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), + MultiAddress::Id(Keyring::Alice.to_account_id()), 500 )); // Account reaped + assert_eq!(Balances::free_balance(Keyring::Eve.to_account_id()), 0); assert_eq!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), - 0 - ); - assert_eq!( - frame_system::Pallet::<Runtime>::get(&AccountKeyring::Eve.to_account_id()), + frame_system::Pallet::<Runtime>::get(&Keyring::Eve.to_account_id()), pallet_duniter_account::AccountData::default() ); System::assert_has_event(RuntimeEvent::System(frame_system::Event::KilledAccount { - account: AccountKeyring::Eve.to_account_id(), + account: Keyring::Eve.to_account_id(), })); }); } @@ -1190,34 +1139,34 @@ fn test_create_new_account() { #[test] fn test_create_new_idty() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 1_000)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 1_000)]) .build() .execute_with(|| { run_to_block(2); // Should be able to create an identity assert_ok!(Balances::transfer_allow_death( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - MultiAddress::Id(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + MultiAddress::Id(Keyring::Eve.to_account_id()), 200 )); assert_noop!( Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Eve.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Eve.to_account_id(), ), pallet_identity::Error::<Runtime>::InsufficientBalance ); assert_ok!(Balances::transfer_allow_death( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - MultiAddress::Id(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + MultiAddress::Id(Keyring::Eve.to_account_id()), 200 )); assert_ok!(Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Eve.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Eve.to_account_id(), )); // At next block, nothing should be preleved @@ -1230,39 +1179,36 @@ fn test_create_new_idty() { #[test] fn test_create_new_idty_without_founds() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 1_000)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 1_000)]) .build() .execute_with(|| { run_to_block(2); - assert_eq!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), - 0 - ); + assert_eq!(Balances::free_balance(Keyring::Eve.to_account_id()), 0); // Should not be able to create an identity without founds assert_noop!( Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Eve.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Eve.to_account_id(), ), pallet_identity::Error::<Runtime>::AccountNotExist ); // Deposit some founds on the account assert_ok!(Balances::transfer_allow_death( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - MultiAddress::Id(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + MultiAddress::Id(Keyring::Eve.to_account_id()), 500 )); assert_ok!(Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Eve.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Eve.to_account_id(), )); System::assert_has_event(RuntimeEvent::Identity( pallet_identity::Event::IdtyCreated { idty_index: 5, - owner_key: AccountKeyring::Eve.to_account_id(), + owner_key: Keyring::Eve.to_account_id(), }, )); @@ -1273,10 +1219,7 @@ fn test_create_new_idty_without_founds() { // At next block, nothing should be preleved run_to_block(4); - assert_eq!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), - 500 - ); + assert_eq!(Balances::free_balance(Keyring::Eve.to_account_id()), 500); }); } @@ -1285,10 +1228,10 @@ fn test_create_new_idty_without_founds() { fn test_validate_new_idty_after_few_uds() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 1_000), - (AccountKeyring::Bob.to_account_id(), 1_000), - (AccountKeyring::Charlie.to_account_id(), 1_000), - (AccountKeyring::Eve.to_account_id(), 1_000), + (Keyring::Alice.to_account_id(), 1_000), + (Keyring::Bob.to_account_id(), 1_000), + (Keyring::Charlie.to_account_id(), 1_000), + (Keyring::Eve.to_account_id(), 1_000), ]) .build() .execute_with(|| { @@ -1296,26 +1239,26 @@ fn test_validate_new_idty_after_few_uds() { // Should be able to create an identity assert_ok!(Balances::transfer_allow_death( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - MultiAddress::Id(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + MultiAddress::Id(Keyring::Eve.to_account_id()), 200 )); assert_ok!(Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Eve.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Eve.to_account_id(), )); // At next block, the created identity should be confirmed by its owner run_to_block(22); assert_ok!(Identity::confirm_identity( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), pallet_identity::IdtyName::from("Eve"), )); // At next block, Bob should be able to certify the new identity run_to_block(23); assert_ok!(Certification::add_cert( - RuntimeOrigin::signed(AccountKeyring::Bob.to_account_id()), + RuntimeOrigin::signed(Keyring::Bob.to_account_id()), 5, )); // valid distance status should trigger identity validation @@ -1327,7 +1270,7 @@ fn test_validate_new_idty_after_few_uds() { // because the call does not exist anymore // assert_noop!( // Membership::claim_membership( - // RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + // RuntimeOrigin::signed(Keyring::Eve.to_account_id()), // ), // pallet_membership::Error::<Runtime>::AlreadyMember // ); @@ -1350,10 +1293,10 @@ fn test_validate_new_idty_after_few_uds() { fn test_claim_memberhsip_after_few_uds() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 1_000), - (AccountKeyring::Bob.to_account_id(), 1_000), - (AccountKeyring::Charlie.to_account_id(), 1_000), - (AccountKeyring::Eve.to_account_id(), 1_000), + (Keyring::Alice.to_account_id(), 1_000), + (Keyring::Bob.to_account_id(), 1_000), + (Keyring::Charlie.to_account_id(), 1_000), + (Keyring::Eve.to_account_id(), 1_000), ]) .build() .execute_with(|| { @@ -1361,21 +1304,21 @@ fn test_claim_memberhsip_after_few_uds() { // Should be able to create an identity assert_ok!(Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Eve.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Eve.to_account_id(), )); // At next block, the created identity should be confirmed by its owner run_to_block(22); assert_ok!(Identity::confirm_identity( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), pallet_identity::IdtyName::from("Eve"), )); // At next block, Bob should be able to certify the new identity run_to_block(23); assert_ok!(Certification::add_cert( - RuntimeOrigin::signed(AccountKeyring::Bob.to_account_id()), + RuntimeOrigin::signed(Keyring::Bob.to_account_id()), 5, )); @@ -1388,7 +1331,7 @@ fn test_claim_memberhsip_after_few_uds() { // because the call does not exist // assert_noop!( // Membership::claim_membership( - // RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + // RuntimeOrigin::signed(Keyring::Eve.to_account_id()), // ), // pallet_membership::Error::<Runtime>::AlreadyMember // ); @@ -1410,73 +1353,61 @@ fn test_claim_memberhsip_after_few_uds() { fn test_oneshot_accounts() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 1_000), - (AccountKeyring::Eve.to_account_id(), 1_000), + (Keyring::Alice.to_account_id(), 1_000), + (Keyring::Eve.to_account_id(), 1_000), ]) .build() .execute_with(|| { run_to_block(6); assert_ok!(OneshotAccount::create_oneshot_account( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - MultiAddress::Id(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + MultiAddress::Id(Keyring::Eve.to_account_id()), 400 )); - assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), - 600 - ); + assert_eq!(Balances::free_balance(Keyring::Alice.to_account_id()), 600); run_to_block(7); assert_ok!(OneshotAccount::consume_oneshot_account_with_remaining( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), 0, pallet_oneshot_account::Account::Oneshot(MultiAddress::Id( - AccountKeyring::Ferdie.to_account_id() + Keyring::Ferdie.to_account_id() )), pallet_oneshot_account::Account::Normal(MultiAddress::Id( - AccountKeyring::Alice.to_account_id() + Keyring::Alice.to_account_id() )), 300 )); - assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), - 700 - ); + assert_eq!(Balances::free_balance(Keyring::Alice.to_account_id()), 700); assert_noop!( OneshotAccount::consume_oneshot_account( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), 0, pallet_oneshot_account::Account::Oneshot(MultiAddress::Id( - AccountKeyring::Ferdie.to_account_id() + Keyring::Ferdie.to_account_id() )), ), pallet_oneshot_account::Error::<Runtime>::OneshotAccountNotExist ); run_to_block(8); // Oneshot account consumption should not increment the nonce - assert_eq!( - System::account(AccountKeyring::Eve.to_account_id()).nonce, - 0 - ); + assert_eq!(System::account(Keyring::Eve.to_account_id()).nonce, 0); assert_ok!(OneshotAccount::consume_oneshot_account( - RuntimeOrigin::signed(AccountKeyring::Ferdie.to_account_id()), + RuntimeOrigin::signed(Keyring::Ferdie.to_account_id()), 0, pallet_oneshot_account::Account::Normal(MultiAddress::Id( - AccountKeyring::Alice.to_account_id() + Keyring::Alice.to_account_id() )), )); - assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), - 1000 - ); + assert_eq!(Balances::free_balance(Keyring::Alice.to_account_id()), 1000); assert_noop!( OneshotAccount::consume_oneshot_account( - RuntimeOrigin::signed(AccountKeyring::Eve.to_account_id()), + RuntimeOrigin::signed(Keyring::Eve.to_account_id()), 0, pallet_oneshot_account::Account::Normal(MultiAddress::Id( - AccountKeyring::Alice.to_account_id() + Keyring::Alice.to_account_id() )), ), pallet_oneshot_account::Error::<Runtime>::OneshotAccountNotExist @@ -1488,14 +1419,14 @@ fn test_oneshot_accounts() { #[test] fn test_link_account() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Alice.to_account_id(), 8888)]) + .with_initial_balances(vec![(Keyring::Alice.to_account_id(), 8888)]) .build() .execute_with(|| { let genesis_hash = System::block_hash(0); - let alice = AccountKeyring::Alice.to_account_id(); - let ferdie = AccountKeyring::Ferdie.to_account_id(); + let alice = Keyring::Alice.to_account_id(); + let ferdie = Keyring::Ferdie.to_account_id(); let payload = (b"link", genesis_hash, 1u32, ferdie.clone()).encode(); - let signature = AccountKeyring::Ferdie.sign(&payload); + let signature = Keyring::Ferdie.sign(&payload); // Ferdie's account cannot be linked to Alice identity because the account does not exist assert_noop!( @@ -1525,14 +1456,14 @@ fn test_link_account() { #[test] fn test_change_owner_key_validator_online() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Ferdie.to_account_id(), 8888)]) + .with_initial_balances(vec![(Keyring::Ferdie.to_account_id(), 8888)]) .build() .execute_with(|| { let genesis_hash = System::block_hash(0); - let alice = AccountKeyring::Alice.to_account_id(); - let ferdie = AccountKeyring::Ferdie.to_account_id(); + let alice = Keyring::Alice.to_account_id(); + let ferdie = Keyring::Ferdie.to_account_id(); let payload = (b"icok", genesis_hash, 1u32, alice.clone()).encode(); - let signature = AccountKeyring::Ferdie.sign(&payload); + let signature = Keyring::Ferdie.sign(&payload); // Alice is an online validator assert!(pallet_authority_members::OnlineAuthorities::<Runtime>::get().contains(&1)); @@ -1560,14 +1491,14 @@ fn test_change_owner_key_validator_online() { #[ignore = "long to go to ReportLongevity"] fn test_change_owner_key_offline() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Ferdie.to_account_id(), 8888)]) + .with_initial_balances(vec![(Keyring::Ferdie.to_account_id(), 8888)]) .build() .execute_with(|| { let genesis_hash = System::block_hash(0); - let charlie = AccountKeyring::Charlie.to_account_id(); - let ferdie = AccountKeyring::Ferdie.to_account_id(); + let charlie = Keyring::Charlie.to_account_id(); + let ferdie = Keyring::Ferdie.to_account_id(); let payload = (b"icok", genesis_hash, 3u32, charlie.clone()).encode(); - let signature = AccountKeyring::Ferdie.sign(&payload); + let signature = Keyring::Ferdie.sign(&payload); // Charlie is an offline smith SmithMembers::on_smith_goes_offline(3); @@ -1608,7 +1539,7 @@ fn test_change_owner_key_offline() { // Charlie can set its session_keys assert_ok!(AuthorityMembers::set_session_keys( - RuntimeOrigin::signed(AccountKeyring::Charlie.to_account_id()), + RuntimeOrigin::signed(Keyring::Charlie.to_account_id()), create_dummy_session_keys() )); assert_eq!( @@ -1644,14 +1575,14 @@ fn test_change_owner_key_offline() { #[ignore = "long to go to ReportLongevity"] fn test_change_owner_key() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Ferdie.to_account_id(), 8888)]) + .with_initial_balances(vec![(Keyring::Ferdie.to_account_id(), 8888)]) .build() .execute_with(|| { let genesis_hash = System::block_hash(0); - let charlie = AccountKeyring::Charlie.to_account_id(); - let ferdie = AccountKeyring::Ferdie.to_account_id(); + let charlie = Keyring::Charlie.to_account_id(); + let ferdie = Keyring::Ferdie.to_account_id(); let payload = (b"icok", genesis_hash, 3u32, charlie.clone()).encode(); - let signature = AccountKeyring::Ferdie.sign(&payload); + let signature = Keyring::Ferdie.sign(&payload); SmithMembers::on_smith_goes_offline(3); // Charlie is now offline smith @@ -1734,11 +1665,11 @@ fn test_change_owner_key() { // Ferdie can set its session_keys and go online frame_system::Pallet::<Runtime>::inc_providers(&ferdie); assert_ok!(AuthorityMembers::set_session_keys( - RuntimeOrigin::signed(AccountKeyring::Ferdie.to_account_id()), + RuntimeOrigin::signed(Keyring::Ferdie.to_account_id()), create_dummy_session_keys() )); assert_ok!(AuthorityMembers::go_online(RuntimeOrigin::signed( - AccountKeyring::Ferdie.to_account_id() + Keyring::Ferdie.to_account_id() ))); // Charlie is still an offline smith @@ -1780,13 +1711,13 @@ fn test_smith_member_can_revoke_its_idty() { run_to_block(2); // Charlie goes online - frame_system::Pallet::<Runtime>::inc_providers(&AccountKeyring::Charlie.to_account_id()); + frame_system::Pallet::<Runtime>::inc_providers(&Keyring::Charlie.to_account_id()); assert_ok!(AuthorityMembers::set_session_keys( - RuntimeOrigin::signed(AccountKeyring::Charlie.to_account_id()), + RuntimeOrigin::signed(Keyring::Charlie.to_account_id()), create_dummy_session_keys() )); assert_ok!(AuthorityMembers::go_online(RuntimeOrigin::signed( - AccountKeyring::Charlie.to_account_id() + Keyring::Charlie.to_account_id() ))); run_to_block(25); @@ -1803,12 +1734,12 @@ fn test_smith_member_can_revoke_its_idty() { genesis_hash: System::block_hash(0), }; let signature = - AccountKeyring::Charlie.sign(&(REVOCATION_PAYLOAD_PREFIX, revocation_payload).encode()); + Keyring::Charlie.sign(&(REVOCATION_PAYLOAD_PREFIX, revocation_payload).encode()); assert_ok!(Identity::revoke_identity( - RuntimeOrigin::signed(AccountKeyring::Charlie.to_account_id()), + RuntimeOrigin::signed(Keyring::Charlie.to_account_id()), 3, - AccountKeyring::Charlie.to_account_id(), + Keyring::Charlie.to_account_id(), signature.into() )); // membership should be removed @@ -1844,11 +1775,11 @@ fn test_smith_member_can_revoke_its_idty() { #[test] fn test_genesis_account_of_identity_linked() { ExtBuilder::new(1, 3, 4) - .with_initial_balances(vec![(AccountKeyring::Eve.to_account_id(), 8888)]) + .with_initial_balances(vec![(Keyring::Eve.to_account_id(), 8888)]) .build() .execute_with(|| { // Alice account - let account_id = AccountKeyring::Alice.to_account_id(); + let account_id = Keyring::Alice.to_account_id(); // Alice identity index is 1 assert_eq!(Identity::identity_index_of(&account_id), Some(1)); // get account data @@ -1856,8 +1787,7 @@ fn test_genesis_account_of_identity_linked() { assert_eq!(account_data.linked_idty, Some(1)); // Eve is not member, her account has no linked identity assert_eq!( - frame_system::Pallet::<Runtime>::get(&AccountKeyring::Eve.to_account_id()) - .linked_idty, + frame_system::Pallet::<Runtime>::get(&Keyring::Eve.to_account_id()).linked_idty, None ); }) @@ -1867,13 +1797,13 @@ fn test_genesis_account_of_identity_linked() { #[test] fn test_unlink_identity() { ExtBuilder::new(1, 3, 4).build().execute_with(|| { - let alice_account = AccountKeyring::Alice.to_account_id(); + let alice_account = Keyring::Alice.to_account_id(); // check that Alice is 1 assert_eq!(Identity::identity_index_of(&alice_account), Some(1)); // Alice can unlink her identity from her account assert_ok!(Account::unlink_identity(RuntimeOrigin::signed( - AccountKeyring::Alice.to_account_id() + Keyring::Alice.to_account_id() ),)); // Alice account has been unlinked @@ -1889,19 +1819,19 @@ fn test_unlink_identity() { fn test_new_account_linked() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 1_000), - (AccountKeyring::Eve.to_account_id(), 1_000), + (Keyring::Alice.to_account_id(), 1_000), + (Keyring::Eve.to_account_id(), 1_000), ]) .build() .execute_with(|| { - let eve_account = AccountKeyring::Eve.to_account_id(); + let eve_account = Keyring::Eve.to_account_id(); assert_eq!( frame_system::Pallet::<Runtime>::get(&eve_account).linked_idty, None ); // Alice creates identity for Eve assert_ok!(Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), eve_account.clone(), )); // then eve account should be linked to her identity @@ -1918,11 +1848,11 @@ fn test_new_account_linked() { #[test] fn test_killed_account() { ExtBuilder::new(1, 2, 4) - .with_initial_balances(vec![(AccountKeyring::Bob.to_account_id(), 1_000)]) + .with_initial_balances(vec![(Keyring::Bob.to_account_id(), 1_000)]) .build() .execute_with(|| { - let alice_account = AccountKeyring::Alice.to_account_id(); - let bob_account = AccountKeyring::Bob.to_account_id(); + let alice_account = Keyring::Alice.to_account_id(); + let bob_account = Keyring::Bob.to_account_id(); // check that Alice is 1 and Bob 2 assert_eq!(Identity::identity_index_of(&alice_account), Some(1)); assert_eq!(Identity::identity_index_of(&bob_account), Some(2)); diff --git a/runtime/gdev/tests/xt_tests.rs b/runtime/gdev/tests/xt_tests.rs index efac8a18f5da8a26a11df9f340da5c8799faf55b..80e3036b4fcb1d17ecb01dfb8bbc92fd01d4cc78 100644 --- a/runtime/gdev/tests/xt_tests.rs +++ b/runtime/gdev/tests/xt_tests.rs @@ -28,7 +28,7 @@ use frame_support::{ }; use gdev_runtime::*; use sp_core::Encode; -use sp_keyring::AccountKeyring; +use sp_keyring::sr25519::Keyring; /// test currency transfer with extrinsic // the signer account should pay fees and a tip @@ -37,18 +37,18 @@ use sp_keyring::AccountKeyring; fn test_transfer_xt() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { - dest: AccountKeyring::Eve.to_account_id().into(), + dest: Keyring::Eve.to_account_id().into(), value: 500, }); // 1 cĞD of tip - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 1u64, 0); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Alice, 1u64, 0); // let info = xt.get_dispatch_info(); // println!("dispatch info:\n\t {:?}\n", info); @@ -57,11 +57,11 @@ fn test_transfer_xt() { assert_ok!(Executive::apply_extrinsic(xt)); // check amounts assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 10_000 - 500 - 3 // initial - transfered - fees ); assert_eq!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), + Balances::free_balance(Keyring::Eve.to_account_id()), 10_000 + 500 // initial + transfered ); assert_eq!(Balances::free_balance(Treasury::account_id()), 100 + 3); @@ -73,18 +73,18 @@ fn test_transfer_xt() { fn test_refund_queue() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { - dest: AccountKeyring::Eve.to_account_id().into(), + dest: Keyring::Eve.to_account_id().into(), value: 500, }); // 1 cĞD of tip - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 1u64, 0); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Alice, 1u64, 0); assert_ok!(Executive::apply_extrinsic(xt)); // check that refund was added to the queue @@ -93,7 +93,7 @@ fn test_refund_queue() { .first() .expect("a refund should have been added to the queue"), &pallet_quota::pallet::Refund { - account: AccountKeyring::Alice.to_account_id(), + account: Keyring::Alice.to_account_id(), identity: 1u32, amount: 2u64 } @@ -106,18 +106,18 @@ fn test_refund_queue() { fn test_refund_on_idle() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { - dest: AccountKeyring::Eve.to_account_id().into(), + dest: Keyring::Eve.to_account_id().into(), value: 500, }); // 1 cĞD of tip - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Alice, 1u64, 0); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Alice, 1u64, 0); assert_ok!(Executive::apply_extrinsic(xt)); // call on_idle to activate refund @@ -125,7 +125,7 @@ fn test_refund_on_idle() { // check that refund event existed System::assert_has_event(RuntimeEvent::Quota(pallet_quota::Event::Refunded { - who: AccountKeyring::Alice.to_account_id(), + who: Keyring::Alice.to_account_id(), identity: 1u32, amount: 1u64, })); @@ -133,7 +133,7 @@ fn test_refund_on_idle() { // check that refund queue is empty assert!(pallet_quota::RefundQueue::<Runtime>::get().is_empty()); assert_eq!( - Balances::free_balance(AccountKeyring::Alice.to_account_id()), + Balances::free_balance(Keyring::Alice.to_account_id()), 10_000 - 500 - 1 - 2 + 1 // initial - transfered - tip - fees + refunded fees ); }) @@ -144,17 +144,17 @@ fn test_refund_on_idle() { fn test_no_refund() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Eve.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Eve.to_account_id(), 10_000), ]) .build() .execute_with(|| { // Eve → Alice let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { - dest: AccountKeyring::Alice.to_account_id().into(), + dest: Keyring::Alice.to_account_id().into(), value: 500, }); - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Eve, 1u64, 0); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Eve, 1u64, 0); assert_ok!(Executive::apply_extrinsic(xt)); // check that refund queue is empty assert!(pallet_quota::RefundQueue::<Runtime>::get().is_empty()); @@ -167,16 +167,16 @@ fn test_no_refund() { fn test_refund_reaped_linked_account() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Ferdie.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Ferdie.to_account_id(), 10_000), ]) .build() .execute_with(|| { let genesis_hash = System::block_hash(0); - let alice = AccountKeyring::Alice.to_account_id(); - let ferdie = AccountKeyring::Ferdie.to_account_id(); + let alice = Keyring::Alice.to_account_id(); + let ferdie = Keyring::Ferdie.to_account_id(); let payload = (b"link", genesis_hash, 1u32, ferdie.clone()).encode(); - let signature = AccountKeyring::Ferdie.sign(&payload); + let signature = Keyring::Ferdie.sign(&payload); // Ferdie's account can be linked to Alice identity assert_ok!(Identity::link_account( @@ -191,10 +191,10 @@ fn test_refund_reaped_linked_account() { // transfer_all call to extrinsic let call = RuntimeCall::Balances(BalancesCall::transfer_all { - dest: AccountKeyring::Alice.to_account_id().into(), + dest: Keyring::Alice.to_account_id().into(), keep_alive: false, }); - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Ferdie, 0u64, 0); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Ferdie, 0u64, 0); assert_ok!(Executive::apply_extrinsic(xt)); assert_eq!(Balances::free_balance(ferdie.clone()), 0); @@ -213,8 +213,8 @@ fn test_refund_reaped_linked_account() { fn test_no_member_no_refund() { ExtBuilder::new(1, 3, 4) .with_initial_balances(vec![ - (AccountKeyring::Alice.to_account_id(), 10_000), - (AccountKeyring::Bob.to_account_id(), 10_000), + (Keyring::Alice.to_account_id(), 10_000), + (Keyring::Bob.to_account_id(), 10_000), ]) .build() .execute_with(|| { @@ -223,7 +223,7 @@ fn test_no_member_no_refund() { idty_index: 2u32, genesis_hash: System::block_hash(0), }; - let signature = AccountKeyring::Bob.sign( + let signature = Keyring::Bob.sign( &( pallet_identity::REVOCATION_PAYLOAD_PREFIX, revocation_payload, @@ -231,9 +231,9 @@ fn test_no_member_no_refund() { .encode(), ); assert_ok!(Identity::revoke_identity( - RuntimeOrigin::signed(AccountKeyring::Bob.to_account_id()), + RuntimeOrigin::signed(Keyring::Bob.to_account_id()), 2, - AccountKeyring::Bob.to_account_id(), + Keyring::Bob.to_account_id(), signature.into() )); assert_eq!( @@ -243,17 +243,17 @@ fn test_no_member_no_refund() { pallet_identity::IdtyStatus::Revoked ); let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { - dest: AccountKeyring::Ferdie.to_account_id().into(), + dest: Keyring::Ferdie.to_account_id().into(), value: 500, }); - let xt = get_unchecked_extrinsic(call, 4u64, 8u64, AccountKeyring::Bob, 0u64, 0); + let xt = get_unchecked_extrinsic(call, 4u64, 8u64, Keyring::Bob, 0u64, 0); assert_ok!(Executive::apply_extrinsic(xt)); assert!(pallet_quota::RefundQueue::<Runtime>::get().is_empty()); // Unconfirmed identities are not eligible for a refund assert_ok!(Identity::create_identity( - RuntimeOrigin::signed(AccountKeyring::Alice.to_account_id()), - AccountKeyring::Ferdie.to_account_id(), + RuntimeOrigin::signed(Keyring::Alice.to_account_id()), + Keyring::Ferdie.to_account_id(), )); assert_eq!( pallet_identity::Identities::<Runtime>::get(&5) @@ -262,17 +262,16 @@ fn test_no_member_no_refund() { pallet_identity::IdtyStatus::Unconfirmed ); let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { - dest: AccountKeyring::Alice.to_account_id().into(), + dest: Keyring::Alice.to_account_id().into(), value: 500, }); - let xt = - get_unchecked_extrinsic(call.clone(), 4u64, 8u64, AccountKeyring::Ferdie, 0u64, 0); + let xt = get_unchecked_extrinsic(call.clone(), 4u64, 8u64, Keyring::Ferdie, 0u64, 0); assert_ok!(Executive::apply_extrinsic(xt)); assert!(pallet_quota::RefundQueue::<Runtime>::get().is_empty()); // Unvalidated identities are not eligible for a refund assert_ok!(Identity::confirm_identity( - RuntimeOrigin::signed(AccountKeyring::Ferdie.to_account_id()), + RuntimeOrigin::signed(Keyring::Ferdie.to_account_id()), "ferdie".into(), )); assert_eq!( @@ -281,8 +280,7 @@ fn test_no_member_no_refund() { .status, pallet_identity::IdtyStatus::Unvalidated ); - let xt = - get_unchecked_extrinsic(call.clone(), 4u64, 8u64, AccountKeyring::Ferdie, 0u64, 1); + let xt = get_unchecked_extrinsic(call.clone(), 4u64, 8u64, Keyring::Ferdie, 0u64, 1); assert_ok!(Executive::apply_extrinsic(xt)); assert!(pallet_quota::RefundQueue::<Runtime>::get().is_empty()); @@ -295,11 +293,10 @@ fn test_no_member_no_refund() { pallet_identity::IdtyStatus::NotMember ); let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death { - dest: AccountKeyring::Bob.to_account_id().into(), + dest: Keyring::Bob.to_account_id().into(), value: 500, }); - let xt = - get_unchecked_extrinsic(call.clone(), 4u64, 8u64, AccountKeyring::Alice, 0u64, 0); + let xt = get_unchecked_extrinsic(call.clone(), 4u64, 8u64, Keyring::Alice, 0u64, 0); assert_ok!(Executive::apply_extrinsic(xt)); assert!(pallet_quota::RefundQueue::<Runtime>::get().is_empty()); })