From 9f80a33ca9128cd674d4a24c3c37fb64aeee7365 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 23 Nov 2019 08:07:06 +0800 Subject: [PATCH] update: currency primitives --- node/cli/src/chain_spec.rs | 27 ++- node/runtime/src/constants.rs | 4 +- node/runtime/src/lib.rs | 41 +++-- srml/kton/src/mock.rs | 6 +- srml/staking/src/mock.rs | 14 +- srml/staking/src/tests.rs | 324 +++++++++++++++++----------------- 6 files changed, 202 insertions(+), 214 deletions(-) diff --git a/node/cli/src/chain_spec.rs b/node/cli/src/chain_spec.rs index b6fb9af20..1d59faccd 100644 --- a/node/cli/src/chain_spec.rs +++ b/node/cli/src/chain_spec.rs @@ -15,26 +15,23 @@ // along with Substrate. If not, see . //! Substrate chain configurations. +pub use node_runtime::GenesisConfig; + use babe_primitives::AuthorityId as BabeId; use chain_spec::ChainSpecExtension; use grandpa_primitives::AuthorityId as GrandpaId; use hex_literal::hex; use im_online::sr25519::AuthorityId as ImOnlineId; use node_primitives::{AccountId, Balance}; -use node_runtime::constants::currency::*; -use node_runtime::Block; -pub use node_runtime::GenesisConfig; use node_runtime::{ - constants::currency::MILLICENTS, AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, ContractsConfig, + constants::currency::*, AuthorityDiscoveryConfig, BabeConfig, BalancesConfig, Block, ContractsConfig, GrandpaConfig, ImOnlineConfig, IndicesConfig, KtonConfig, SessionConfig, SessionKeys, StakerStatus, StakingConfig, SudoConfig, SystemConfig, WASM_BINARY, }; use primitives::{crypto::UncheckedInto, Pair, Public}; use serde::{Deserialize, Serialize}; -use serde_json::de::ParserNumber; -use serde_json::Number; +use serde_json::{de::ParserNumber, Number}; use sr_primitives::Perbill; -use substrate_service; use substrate_service::Properties; use substrate_telemetry::TelemetryEndpoints; @@ -195,8 +192,8 @@ pub fn testnet_genesis( ] }); - const ENDOWMENT: Balance = 10_000_000 * DOLLARS; - const STASH: Balance = 100 * DOLLARS; + const ENDOWMENT: Balance = 10_000_000 * COIN; + const STASH: Balance = 100 * COIN; GenesisConfig { system: Some(SystemConfig { @@ -230,7 +227,7 @@ pub fn testnet_genesis( enable_println, // this should only be enabled on development chains ..Default::default() }, - gas_price: 1 * MILLICENTS, + gas_price: 1 * MICRO, }), sudo: Some(SudoConfig { key: root_key }), babe: Some(BabeConfig { authorities: vec![] }), @@ -249,7 +246,7 @@ pub fn testnet_genesis( }), staking: Some(StakingConfig { current_era: 0, - // current_era_total_reward: 80_000_000 * MILLICENTS / 63720, + // current_era_total_reward: 80_000_000 * COIN / 63720, // offline_slash: Perbill::from_parts(1_000_000), session_reward: Perbill::from_percent(90), validator_count: 7, @@ -350,8 +347,8 @@ pub fn darwinia_genesis_verbose( ] }); - const ENDOWMENT: Balance = 100_000_000 * MILLICENTS; - const STASH: Balance = 100 * MILLICENTS; + const ENDOWMENT: Balance = 100_000_000 * COIN; + const STASH: Balance = 100 * COIN; GenesisConfig { system: Some(SystemConfig { @@ -385,7 +382,7 @@ pub fn darwinia_genesis_verbose( enable_println, // this should only be enabled on development chains ..Default::default() }, - gas_price: 1 * MILLICENTS, + gas_price: 1 * MICRO, }), sudo: Some(SudoConfig { key: root_key }), babe: Some(BabeConfig { authorities: vec![] }), @@ -404,7 +401,7 @@ pub fn darwinia_genesis_verbose( }), staking: Some(StakingConfig { current_era: 0, - // current_era_total_reward: 80_000_000 * MILLICENTS / 63720, + // current_era_total_reward: 80_000_000 * COIN / 63720, // offline_slash: Perbill::from_parts(1_000_000), session_reward: Perbill::from_percent(90), validator_count: 7, diff --git a/node/runtime/src/constants.rs b/node/runtime/src/constants.rs index 39dc0dc7b..c6271bc12 100644 --- a/node/runtime/src/constants.rs +++ b/node/runtime/src/constants.rs @@ -23,9 +23,7 @@ pub mod currency { pub const NANO: Balance = 1; pub const MICRO: Balance = 1_000 * NANO; pub const MILLI: Balance = 1_000 * MICRO; - pub const MILLICENTS: Balance = 1_000 * MILLI; - pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. - pub const DOLLARS: Balance = 100 * CENTS; + pub const COIN: Balance = 1_000 * MILLI; } /// Time. diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 5b0de4faf..9eaf3f9a7 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -19,6 +19,11 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] +/// Constant values used within the runtime. +pub mod constants; +/// Implementations of some helper traits passed into runtime modules as associated types. +pub mod impls; + pub use contracts::Gas; pub use timestamp::Call as TimestampCall; @@ -55,16 +60,10 @@ use version::RuntimeVersion; //use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight}; //use im_online::sr25519::AuthorityId as ImOnlineId; -use darwinia_support::TimeStamp; -use staking::EraIndex; - -/// Constant values used within the runtime. -pub mod constants; -/// Implementations of some helper traits passed into runtime modules as associated types. -pub mod impls; - use constants::{currency::*, time::*}; +use darwinia_support::TimeStamp; use impls::{Author, CurrencyToVoteHandler, LinearWeightToFee, TargetedFeeAdjustment}; +use staking::EraIndex; // Make the WASM binary available. #[cfg(feature = "std")] @@ -151,9 +150,9 @@ impl indices::Trait for Runtime { } parameter_types! { - pub const ExistentialDeposit: Balance = 1 * MILLICENTS; - pub const TransferFee: Balance = 1 * MILLI; - pub const CreationFee: Balance = 1 * MILLI; + pub const ExistentialDeposit: Balance = 1 * COIN; + pub const TransferFee: Balance = 1 * MICRO; + pub const CreationFee: Balance = 1 * MICRO; } impl balances::Trait for Runtime { type Balance = Balance; @@ -168,7 +167,7 @@ impl balances::Trait for Runtime { } parameter_types! { - pub const TransactionBaseFee: Balance = 1 * MILLI; + pub const TransactionBaseFee: Balance = 1 * MICRO; pub const TransactionByteFee: Balance = 10 * MICRO; // setting this to zero will disable the weight fee. pub const WeightFeeCoefficient: Balance = 1_000; @@ -290,15 +289,15 @@ impl finality_tracker::Trait for Runtime { } parameter_types! { - pub const ContractTransferFee: Balance = 1 * MILLI; - pub const ContractCreationFee: Balance = 1 * MILLI; - pub const ContractTransactionBaseFee: Balance = 1 * MILLI; + pub const ContractTransferFee: Balance = 1 * MICRO; + pub const ContractCreationFee: Balance = 1 * MICRO; + pub const ContractTransactionBaseFee: Balance = 1 * MICRO; pub const ContractTransactionByteFee: Balance = 10 * MICRO; - pub const ContractFee: Balance = 1 * MILLI; - pub const TombstoneDeposit: Balance = 1 * MILLICENTS; - pub const RentByteFee: Balance = 1 * MILLICENTS; - pub const RentDepositOffset: Balance = 1000 * MILLICENTS; - pub const SurchargeReward: Balance = 150 * MILLICENTS; + pub const ContractFee: Balance = 1 * MICRO; + pub const TombstoneDeposit: Balance = 1 * COIN; + pub const RentByteFee: Balance = 1 * COIN; + pub const RentDepositOffset: Balance = 1000 * COIN; + pub const SurchargeReward: Balance = 150 * COIN; } impl contracts::Trait for Runtime { type Currency = Balances; @@ -375,7 +374,7 @@ parameter_types! { // 365 days * 24 hours * 60 minutes / 5 minutes pub const ErasPerEpoch: EraIndex = 105120; // decimal 9 - pub const HardCap: Balance = 10_000_000_000 * MILLICENTS; + pub const HardCap: Balance = 10_000_000_000 * COIN; pub const GenesisTime: Moment = 1_574_156_000_000; } impl staking::Trait for Runtime { diff --git a/srml/kton/src/mock.rs b/srml/kton/src/mock.rs index 1b24b4f1c..b51141bef 100644 --- a/srml/kton/src/mock.rs +++ b/srml/kton/src/mock.rs @@ -1,4 +1,4 @@ -pub use node_runtime::constants::currency::MILLICENTS; +pub use node_runtime::constants::currency::COIN; use std::{cell::RefCell, collections::HashSet}; @@ -100,9 +100,9 @@ impl ExtBuilder { self.set_associated_consts(); let mut t = system::GenesisConfig::default().build_storage::().unwrap(); let balance_factor = if self.existential_deposit > 0 { - 1_000 * MILLICENTS + 1_000 * COIN } else { - 1 * MILLICENTS + 1 * COIN }; let _ = GenesisConfig:: { diff --git a/srml/staking/src/mock.rs b/srml/staking/src/mock.rs index 55d1b2c2d..a9c373727 100644 --- a/srml/staking/src/mock.rs +++ b/srml/staking/src/mock.rs @@ -1,4 +1,4 @@ -pub use node_runtime::constants::currency::MILLICENTS; +pub use node_runtime::constants::currency::COIN; use std::{cell::RefCell, collections::HashSet}; @@ -187,7 +187,7 @@ parameter_types! { } parameter_types! { // decimal 9 - pub const CAP: Balance = 10_000_000_000 * MILLICENTS; + pub const CAP: Balance = 10_000_000_000 * COIN; } impl Trait for Test { type Ring = Ring; @@ -270,9 +270,9 @@ impl ExtBuilder { self.set_associated_consts(); let mut storage = system::GenesisConfig::default().build_storage::().unwrap(); let balance_factor = if self.existential_deposit > 0 { - 1_000 * MILLICENTS + 1_000 * COIN } else { - 1 * MILLICENTS + 1 * COIN }; let validators = if self.validator_pool { vec![10, 20, 30, 40] @@ -322,10 +322,10 @@ impl ExtBuilder { let nominated = if self.nominate { vec![11, 21] } else { vec![] }; let _ = GenesisConfig:: { current_era: self.current_era, - // current_era_total_reward: 80_000_000 * MILLICENTS / ErasPerEpoch::get() as u64, + // current_era_total_reward: 80_000_000 * COIN / ErasPerEpoch::get() as u64, stakers: vec![ - // (2, 1, 1 * MILLICENTS, StakerStatus::::Validator), - (11, 10, 100 * MILLICENTS, StakerStatus::::Validator), + // (2, 1, 1 * COIN, StakerStatus::::Validator), + (11, 10, 100 * COIN, StakerStatus::::Validator), (21, 20, stake_21, StakerStatus::::Validator), (31, 30, stake_31, StakerStatus::::Validator), (41, 40, balance_factor * 1000, status_41), diff --git a/srml/staking/src/tests.rs b/srml/staking/src/tests.rs index 111ccf727..6b0a8701e 100644 --- a/srml/staking/src/tests.rs +++ b/srml/staking/src/tests.rs @@ -17,55 +17,55 @@ use darwinia_support::{BalanceLock, NormalLock, StakingLock, WithdrawLock}; // ($stash:ident($stash_id:expr), $controller:ident($controller_id:expr), $promise_month:ident($how_long:expr)) => { // #[allow(non_snake_case, unused)] // let $stash = $stash_id; -// let _ = Ring::deposit_creating(&$stash, 100 * MILLICENTS); -// Kton::deposit_creating(&$stash, 100 * MILLICENTS); +// let _ = Ring::deposit_creating(&$stash, 100 * COIN); +// Kton::deposit_creating(&$stash, 100 * COIN); // #[allow(non_snake_case, unused)] // let $controller = $controller_id; -// let _ = Ring::deposit_creating(&$controller, MILLICENTS); +// let _ = Ring::deposit_creating(&$controller, COIN); // #[allow(non_snake_case, unused)] // let $promise_month = $how_long; // assert_ok!(Staking::bond( // Origin::signed($stash), // $controller, -// StakingBalance::Ring(50 * MILLICENTS), +// StakingBalance::Ring(50 * COIN), // RewardDestination::Stash, // $how_long // )); // assert_ok!(Staking::bond_extra( // Origin::signed($stash), -// StakingBalance::Kton(50 * MILLICENTS), +// StakingBalance::Kton(50 * COIN), // $how_long // )); // }; // ($stash:ident($stash_id:expr), $controller:ident($controller_id:expr), $how_long:expr) => { // #[allow(non_snake_case, unused)] // let $stash = $stash_id; -// let _ = Ring::deposit_creating(&$stash, 100 * MILLICENTS); -// Kton::deposit_creating(&$stash, 100 * MILLICENTS); +// let _ = Ring::deposit_creating(&$stash, 100 * COIN); +// Kton::deposit_creating(&$stash, 100 * COIN); // #[allow(non_snake_case, unused)] // let $controller = $controller_id; -// let _ = Ring::deposit_creating(&$controller, MILLICENTS); +// let _ = Ring::deposit_creating(&$controller, COIN); // assert_ok!(Staking::bond( // Origin::signed($stash), // $controller, -// StakingBalance::Ring(50 * MILLICENTS), +// StakingBalance::Ring(50 * COIN), // RewardDestination::Stash, // $how_long // )); // assert_ok!(Staking::bond_extra( // Origin::signed($stash), -// StakingBalance::Kton(50 * MILLICENTS), +// StakingBalance::Kton(50 * COIN), // $how_long // )); // }; // ($stash:ident($stash_id:expr), $controller:ident($controller_id:expr)) => { // #[allow(non_snake_case, unused)] // let $stash = $stash_id; -// let _ = Ring::deposit_creating(&$stash, 100 * MILLICENTS); -// Kton::deposit_creating(&$stash, 100 * MILLICENTS); +// let _ = Ring::deposit_creating(&$stash, 100 * COIN); +// Kton::deposit_creating(&$stash, 100 * COIN); // #[allow(non_snake_case, unused)] // let $controller = $controller_id; -// let _ = Ring::deposit_creating(&$controller, MILLICENTS); +// let _ = Ring::deposit_creating(&$controller, COIN); // }; //} @@ -79,16 +79,16 @@ fn test_env_build() { Staking::ledger(&10).unwrap(), StakingLedger { stash: 11, - active_ring: 100 * MILLICENTS, - active_deposit_ring: 100 * MILLICENTS, + active_ring: 100 * COIN, + active_deposit_ring: 100 * COIN, active_kton: 0, deposit_items: vec![TimeDepositItem { - value: 100 * MILLICENTS, + value: 100 * COIN, start_time: 0, expire_time: 12 * MONTH_IN_SECONDS as u64 }], ring_staking_lock: StakingLock { - staking_amount: 100 * MILLICENTS, + staking_amount: 100 * COIN, unbondings: vec![] }, kton_staking_lock: StakingLock { @@ -98,37 +98,37 @@ fn test_env_build() { } ); - assert_eq!(Kton::free_balance(&11), MILLICENTS / 100); - assert_eq!(Kton::total_issuance(), 16 * MILLICENTS / 100); + assert_eq!(Kton::free_balance(&11), COIN / 100); + assert_eq!(Kton::total_issuance(), 16 * COIN / 100); let origin_ledger = Staking::ledger(&10).unwrap(); - let _ = Ring::deposit_creating(&11, 100 * MILLICENTS); + let _ = Ring::deposit_creating(&11, 100 * COIN); assert_ok!(Staking::bond_extra( Origin::signed(11), - StakingBalance::Ring(20 * MILLICENTS), + StakingBalance::Ring(20 * COIN), 13 )); assert_eq!( Staking::ledger(&10).unwrap(), StakingLedger { stash: 11, - active_ring: origin_ledger.active_ring + 20 * MILLICENTS, - active_deposit_ring: origin_ledger.active_deposit_ring + 20 * MILLICENTS, + active_ring: origin_ledger.active_ring + 20 * COIN, + active_deposit_ring: origin_ledger.active_deposit_ring + 20 * COIN, active_kton: 0, deposit_items: vec![ TimeDepositItem { - value: 100 * MILLICENTS, + value: 100 * COIN, start_time: 0, expire_time: 12 * MONTH_IN_SECONDS as u64 }, TimeDepositItem { - value: 20 * MILLICENTS, + value: 20 * COIN, start_time: 0, expire_time: 13 * MONTH_IN_SECONDS as u64 } ], ring_staking_lock: StakingLock { - staking_amount: origin_ledger.active_ring + 20 * MILLICENTS, + staking_amount: origin_ledger.active_ring + 20 * COIN, unbondings: vec![] }, kton_staking_lock: StakingLock { @@ -143,11 +143,11 @@ fn test_env_build() { #[test] fn normal_kton_should_work() { ExtBuilder::default().existential_deposit(0).build().execute_with(|| { - Kton::deposit_creating(&1001, 10 * MILLICENTS); + Kton::deposit_creating(&1001, 10 * COIN); assert_ok!(Staking::bond( Origin::signed(1001), 1000, - StakingBalance::Kton(10 * MILLICENTS), + StakingBalance::Kton(10 * COIN), RewardDestination::Stash, 0 )); @@ -157,14 +157,14 @@ fn normal_kton_should_work() { stash: 1001, active_ring: 0, active_deposit_ring: 0, - active_kton: 10 * MILLICENTS, + active_kton: 10 * COIN, deposit_items: vec![], ring_staking_lock: StakingLock { staking_amount: 0, unbondings: vec![] }, kton_staking_lock: StakingLock { - staking_amount: 10 * MILLICENTS, + staking_amount: 10 * COIN, unbondings: vec![] }, } @@ -174,7 +174,7 @@ fn normal_kton_should_work() { vec![BalanceLock { id: STAKING_ID, withdraw_lock: WithdrawLock::WithStaking(StakingLock { - staking_amount: 10 * MILLICENTS, + staking_amount: 10 * COIN, unbondings: vec![], }), reasons: WithdrawReasons::all() @@ -182,11 +182,11 @@ fn normal_kton_should_work() { ); // promise_month should not work for kton - Kton::deposit_creating(&2001, 10 * MILLICENTS); + Kton::deposit_creating(&2001, 10 * COIN); assert_ok!(Staking::bond( Origin::signed(2001), 2000, - StakingBalance::Kton(10 * MILLICENTS), + StakingBalance::Kton(10 * COIN), RewardDestination::Stash, 12 )); @@ -196,14 +196,14 @@ fn normal_kton_should_work() { stash: 2001, active_ring: 0, active_deposit_ring: 0, - active_kton: 10 * MILLICENTS, + active_kton: 10 * COIN, deposit_items: vec![], ring_staking_lock: StakingLock { staking_amount: 0, unbondings: vec![] }, kton_staking_lock: StakingLock { - staking_amount: 10 * MILLICENTS, + staking_amount: 10 * COIN, unbondings: vec![] }, } @@ -218,23 +218,23 @@ fn time_deposit_ring_unbond_and_withdraw_automactically_should_work() { let locks = vec![BalanceLock { id: STAKING_ID, withdraw_lock: WithdrawLock::WithStaking(StakingLock { - staking_amount: 100 * MILLICENTS, + staking_amount: 100 * COIN, unbondings: vec![], }), reasons: WithdrawReasons::all(), }]; let ledger = StakingLedger { stash: 11, - active_ring: 100 * MILLICENTS, - active_deposit_ring: 100 * MILLICENTS, + active_ring: 100 * COIN, + active_deposit_ring: 100 * COIN, active_kton: 0, deposit_items: vec![TimeDepositItem { - value: 100 * MILLICENTS, + value: 100 * COIN, start_time: 0, expire_time: 12 * MONTH_IN_SECONDS as u64, }], ring_staking_lock: StakingLock { - staking_amount: 100 * MILLICENTS, + staking_amount: 100 * COIN, unbondings: vec![], }, kton_staking_lock: StakingLock { @@ -243,22 +243,16 @@ fn time_deposit_ring_unbond_and_withdraw_automactically_should_work() { }, }; - assert_ok!(Staking::unbond( - Origin::signed(10), - StakingBalance::Ring(10 * MILLICENTS) - )); + assert_ok!(Staking::unbond(Origin::signed(10), StakingBalance::Ring(10 * COIN))); assert_eq!(Ring::locks(11), locks); assert_eq!(Staking::ledger(&10).unwrap(), ledger,); - assert_ok!(Staking::unbond( - Origin::signed(10), - StakingBalance::Ring(120 * MILLICENTS) - )); + assert_ok!(Staking::unbond(Origin::signed(10), StakingBalance::Ring(120 * COIN))); assert_eq!(Ring::locks(11), locks); assert_eq!(Staking::ledger(&10).unwrap(), ledger); } - let (unbond_start, unbond_value) = (13 * MONTH_IN_SECONDS as u64, 10 * MILLICENTS); + let (unbond_start, unbond_value) = (13 * MONTH_IN_SECONDS as u64, 10 * COIN); Timestamp::set_timestamp(unbond_start); assert_ok!(Staking::unbond(Origin::signed(10), StakingBalance::Ring(unbond_value))); @@ -267,7 +261,7 @@ fn time_deposit_ring_unbond_and_withdraw_automactically_should_work() { vec![BalanceLock { id: STAKING_ID, withdraw_lock: WithdrawLock::WithStaking(StakingLock { - staking_amount: 100 * MILLICENTS - unbond_value, + staking_amount: 100 * COIN - unbond_value, unbondings: vec![NormalLock { amount: unbond_value, until: unbond_start + BondingDuration::get(), @@ -280,12 +274,12 @@ fn time_deposit_ring_unbond_and_withdraw_automactically_should_work() { Staking::ledger(&10).unwrap(), StakingLedger { stash: 11, - active_ring: 100 * MILLICENTS - unbond_value, + active_ring: 100 * COIN - unbond_value, active_deposit_ring: 0, active_kton: 0, deposit_items: vec![], ring_staking_lock: StakingLock { - staking_amount: 100 * MILLICENTS - unbond_value, + staking_amount: 100 * COIN - unbond_value, unbondings: vec![NormalLock { amount: unbond_value, until: unbond_start + BondingDuration::get(), @@ -304,7 +298,7 @@ fn time_deposit_ring_unbond_and_withdraw_automactically_should_work() { &11, unbond_value, WithdrawReason::Transfer.into(), - 100 * MILLICENTS - unbond_value - 1, + 100 * COIN - unbond_value - 1, ), "account liquidity restrictions prevent withdrawal" ); @@ -312,7 +306,7 @@ fn time_deposit_ring_unbond_and_withdraw_automactically_should_work() { &11, unbond_value, WithdrawReason::Transfer.into(), - 100 * MILLICENTS - unbond_value, + 100 * COIN - unbond_value, )); }); } @@ -322,9 +316,9 @@ fn normal_unbond_should_work() { ExtBuilder::default().existential_deposit(0).build().execute_with(|| { let stash = 11; let controller = 10; - let value = 200 * MILLICENTS; + let value = 200 * COIN; let promise_month = 12; - let _ = Ring::deposit_creating(&stash, 1000 * MILLICENTS); + let _ = Ring::deposit_creating(&stash, 1000 * COIN); { let kton_free_balance = Kton::free_balance(&stash); @@ -359,7 +353,7 @@ fn normal_unbond_should_work() { // bond += 0.03 assert_ok!(Staking::bond_extra( Origin::signed(stash), - StakingBalance::Kton(MILLICENTS), + StakingBalance::Kton(COIN), 0 )); ledger.active_kton += kton_free_balance; @@ -387,15 +381,15 @@ fn punished_unbond_should_work() { let stash = 1001; let controller = 1000; let promise_month = 36; - let _ = Ring::deposit_creating(&stash, 100 * MILLICENTS); - Kton::deposit_creating(&stash, MILLICENTS / 100000); + let _ = Ring::deposit_creating(&stash, 100 * COIN); + Kton::deposit_creating(&stash, COIN / 100000); // timestamp now is 0. // free balance of kton is too low to work assert_ok!(Staking::bond( Origin::signed(stash), controller, - StakingBalance::Ring(10 * MILLICENTS), + StakingBalance::Ring(10 * COIN), RewardDestination::Stash, promise_month, )); @@ -403,12 +397,12 @@ fn punished_unbond_should_work() { // Staking::ledger(&controller), // Some(StakingLedger { // stash, - // total_deposit_ring: 10 * MILLICENTS, - // active_deposit_ring: 10 * MILLICENTS, - // active_ring: 10 * MILLICENTS, + // total_deposit_ring: 10 * COIN, + // active_deposit_ring: 10 * COIN, + // active_ring: 10 * COIN, // active_kton: 0, // deposit_items: vec![TimeDepositItem { - // value: 10 * MILLICENTS, + // value: 10 * COIN, // start_time: 0, // expire_time: promise_month as u64 * MONTH_IN_SECONDS as u64 // }], // should be cleared @@ -420,16 +414,16 @@ fn punished_unbond_should_work() { // // kton is 0, skip unbond_with_punish // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller), - // 10 * MILLICENTS, + // 10 * COIN, // promise_month as u64 * MONTH_IN_SECONDS as u64 // )); // assert_eq!(&Staking::ledger(&controller).unwrap(), &ledger); // assert_eq!(Kton::free_balance(&stash), kton_free_balance); // // // set more kton balance to make it work - // Kton::deposit_creating(&stash, 10 * MILLICENTS); + // Kton::deposit_creating(&stash, 10 * COIN); // let kton_free_balance = Kton::free_balance(&stash); - // let unbond_value = 5 * MILLICENTS; + // let unbond_value = 5 * COIN; // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller), // unbond_value, @@ -452,7 +446,7 @@ fn punished_unbond_should_work() { // // the whole item should be be dropped // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller), - // 5 * MILLICENTS, + // 5 * COIN, // promise_month as u64 * MONTH_IN_SECONDS as u64 // )); // assert!(Staking::ledger(&controller).unwrap().deposit_items.is_empty()); @@ -462,29 +456,29 @@ fn punished_unbond_should_work() { //#[test] //fn transform_to_promised_ring_should_work() { // ExtBuilder::default().existential_deposit(0).build().execute_with(|| { -// let _ = Ring::deposit_creating(&1001, 100 * MILLICENTS); +// let _ = Ring::deposit_creating(&1001, 100 * COIN); // assert_ok!(Staking::bond( // Origin::signed(1001), // 1000, -// StakingBalance::Ring(10 * MILLICENTS), +// StakingBalance::Ring(10 * COIN), // RewardDestination::Stash, // 0 // )); // let origin_ledger = Staking::ledger(&1000).unwrap(); // let kton_free_balance = Kton::free_balance(&1001); // -// assert_ok!(Staking::promise_extra(Origin::signed(1000), 5 * MILLICENTS, 12)); +// assert_ok!(Staking::promise_extra(Origin::signed(1000), 5 * COIN, 12)); // // assert_eq!( // Staking::ledger(&1000), // Some(StakingLedger { // stash: 1001, -// total_deposit_ring: origin_ledger.total_deposit_ring + 5 * MILLICENTS, -// active_deposit_ring: origin_ledger.active_deposit_ring + 5 * MILLICENTS, +// total_deposit_ring: origin_ledger.total_deposit_ring + 5 * COIN, +// active_deposit_ring: origin_ledger.active_deposit_ring + 5 * COIN, // active_ring: origin_ledger.active_ring, // active_kton: origin_ledger.active_kton, // deposit_items: vec![TimeDepositItem { -// value: 5 * MILLICENTS, +// value: 5 * COIN, // start_time: 0, // expire_time: 12 * MONTH_IN_SECONDS as u64 // }], @@ -492,24 +486,24 @@ fn punished_unbond_should_work() { // }) // ); // -// assert_eq!(Kton::free_balance(&1001), kton_free_balance + (5 * MILLICENTS / 10000)); +// assert_eq!(Kton::free_balance(&1001), kton_free_balance + (5 * COIN / 10000)); // }); //} // //#[test] //fn expired_ring_should_capable_to_promise_again() { // ExtBuilder::default().existential_deposit(0).build().execute_with(|| { -// let _ = Ring::deposit_creating(&1001, 100 * MILLICENTS); +// let _ = Ring::deposit_creating(&1001, 100 * COIN); // assert_ok!(Staking::bond( // Origin::signed(1001), // 1000, -// StakingBalance::Ring(10 * MILLICENTS), +// StakingBalance::Ring(10 * COIN), // RewardDestination::Stash, // 12 // )); // let mut ledger = Staking::ledger(&1000).unwrap(); // let ts = 13 * MONTH_IN_SECONDS as u64; -// let promise_extra_value = 5 * MILLICENTS; +// let promise_extra_value = 5 * COIN; // Timestamp::set_timestamp(ts); // assert_ok!(Staking::promise_extra(Origin::signed(1000), promise_extra_value, 13)); // ledger.total_deposit_ring = promise_extra_value; @@ -527,14 +521,14 @@ fn punished_unbond_should_work() { ////#[test] ////fn inflation_should_be_correct() { //// ExtBuilder::default().existential_deposit(0).build().execute_with(|| { -//// let initial_issuance = 1_200_000_000 * MILLICENTS; +//// let initial_issuance = 1_200_000_000 * COIN; //// let surplus_needed = initial_issuance - Ring::total_issuance(); //// let _ = Ring::deposit_into_existing(&11, surplus_needed); //// assert_eq!(Ring::total_issuance(), initial_issuance); -//// // assert_eq!(Staking::current_era_total_reward(), 80000000 * MILLICENTS / 10); +//// // assert_eq!(Staking::current_era_total_reward(), 80000000 * COIN / 10); //// start_era(11); //// // ErasPerEpoch = 10 -//// // assert_eq!(Staking::current_era_total_reward(), 88000000 * MILLICENTS / 10); +//// // assert_eq!(Staking::current_era_total_reward(), 88000000 * COIN / 10); //// }); ////} // @@ -542,44 +536,44 @@ fn punished_unbond_should_work() { //fn reward_should_work_correctly() { // ExtBuilder::default().existential_deposit(0).build().execute_with(|| { // // create controller account -// let _ = Ring::deposit_creating(&2000, MILLICENTS); -// let _ = Ring::deposit_creating(&1000, MILLICENTS); -// let _ = Ring::deposit_creating(&200, MILLICENTS); +// let _ = Ring::deposit_creating(&2000, COIN); +// let _ = Ring::deposit_creating(&1000, COIN); +// let _ = Ring::deposit_creating(&200, COIN); // // new validator -// let _ = Ring::deposit_creating(&2001, 2000 * MILLICENTS); -// Kton::deposit_creating(&2001, 10 * MILLICENTS); +// let _ = Ring::deposit_creating(&2001, 2000 * COIN); +// Kton::deposit_creating(&2001, 10 * COIN); // // new validator -// let _ = Ring::deposit_creating(&1001, 300 * MILLICENTS); -// Kton::deposit_creating(&1001, 1 * MILLICENTS); +// let _ = Ring::deposit_creating(&1001, 300 * COIN); +// Kton::deposit_creating(&1001, 1 * COIN); // // handle some dirty work -// let _ = Ring::deposit_creating(&201, 2000 * MILLICENTS); -// Kton::deposit_creating(&201, 10 * MILLICENTS); -// assert_eq!(Kton::free_balance(&201), 10 * MILLICENTS); +// let _ = Ring::deposit_creating(&201, 2000 * COIN); +// Kton::deposit_creating(&201, 10 * COIN); +// assert_eq!(Kton::free_balance(&201), 10 * COIN); // // // 2001-2000 // assert_ok!(Staking::bond( // Origin::signed(2001), // 2000, -// StakingBalance::Ring(300 * MILLICENTS), +// StakingBalance::Ring(300 * COIN), // RewardDestination::Controller, // 12, // )); // assert_ok!(Staking::bond_extra( // Origin::signed(2001), -// StakingBalance::Kton(1 * MILLICENTS), +// StakingBalance::Kton(1 * COIN), // 0 // )); // // 1001-1000 // assert_ok!(Staking::bond( // Origin::signed(1001), // 1000, -// StakingBalance::Ring(300 * MILLICENTS), +// StakingBalance::Ring(300 * COIN), // RewardDestination::Controller, // 12, // )); // assert_ok!(Staking::bond_extra( // Origin::signed(1001), -// StakingBalance::Kton(1 * MILLICENTS), +// StakingBalance::Kton(1 * COIN), // 0 // )); // let ring_pool = Staking::ring_pool(); @@ -588,29 +582,29 @@ fn punished_unbond_should_work() { // assert_ok!(Staking::bond( // Origin::signed(201), // 200, -// StakingBalance::Ring(3000 * MILLICENTS - ring_pool), +// StakingBalance::Ring(3000 * COIN - ring_pool), // RewardDestination::Stash, // 12, // )); // assert_ok!(Staking::bond_extra( // Origin::signed(201), -// StakingBalance::Kton(10 * MILLICENTS - kton_pool), +// StakingBalance::Kton(10 * COIN - kton_pool), // 0, // )); // // ring_pool and kton_pool -// assert_eq!(Staking::ring_pool(), 3000 * MILLICENTS); -// assert_eq!(Staking::kton_pool(), 10 * MILLICENTS); +// assert_eq!(Staking::ring_pool(), 3000 * COIN); +// assert_eq!(Staking::kton_pool(), 10 * COIN); // // 1/5 ring_pool and 1/5 kton_pool // assert_ok!(Staking::validate(Origin::signed(2000), [0; 8].to_vec(), 0, 3)); // assert_ok!(Staking::nominate(Origin::signed(1000), vec![2001])); // -// assert_eq!(Staking::ledger(&2000).unwrap().active_kton, 1 * MILLICENTS); -// assert_eq!(Staking::ledger(&2000).unwrap().active_ring, 300 * MILLICENTS); +// assert_eq!(Staking::ledger(&2000).unwrap().active_kton, 1 * COIN); +// assert_eq!(Staking::ledger(&2000).unwrap().active_ring, 300 * COIN); // assert_eq!(Staking::power_of(&2001), 1_000_000_000 / 10 as u128); // // 600COIN for rewarding ring bond-er // // 600COIN for rewarding kton bond-er // Staking::select_validators(); -// Staking::reward_validator(&2001, 1200 * MILLICENTS); +// Staking::reward_validator(&2001, 1200 * COIN); // // assert_eq!( // Staking::stakers(2001), @@ -623,33 +617,33 @@ fn punished_unbond_should_work() { // }] // } // ); -// assert_eq!(Ring::free_balance(&2000), 601 * MILLICENTS); -// assert_eq!(Ring::free_balance(&1000), 601 * MILLICENTS); +// assert_eq!(Ring::free_balance(&2000), 601 * COIN); +// assert_eq!(Ring::free_balance(&1000), 601 * COIN); // }); //} // //#[test] //fn slash_should_work() { // ExtBuilder::default().existential_deposit(0).build().execute_with(|| { -// let _ = Ring::deposit_creating(&1001, 100 * MILLICENTS); -// Kton::deposit_creating(&1001, 100 * MILLICENTS); +// let _ = Ring::deposit_creating(&1001, 100 * COIN); +// Kton::deposit_creating(&1001, 100 * COIN); // // assert_ok!(Staking::bond( // Origin::signed(1001), // 1000, -// StakingBalance::Ring(50 * MILLICENTS), +// StakingBalance::Ring(50 * COIN), // RewardDestination::Controller, // 0, // )); // assert_ok!(Staking::bond_extra( // Origin::signed(1001), -// StakingBalance::Kton(50 * MILLICENTS), +// StakingBalance::Kton(50 * COIN), // 0 // )); // assert_ok!(Staking::validate(Origin::signed(1000), [0; 8].to_vec(), 0, 3)); // // // slash 1% -// let slash_value = 5 * MILLICENTS / 10; +// let slash_value = 5 * COIN / 10; // let mut ledger = Staking::ledger(&1000).unwrap(); // let ring_free_balance = Ring::free_balance(&1001); // let kton_free_balance = Kton::free_balance(&1001); @@ -665,10 +659,10 @@ fn punished_unbond_should_work() { //#[test] ////fn test_inflation() { //// ExtBuilder::default().existential_deposit(0).build().execute_with(|| { -//// assert_eq!(Staking::current_era_total_reward(), 80_000_000 * MILLICENTS / 10); +//// assert_eq!(Staking::current_era_total_reward(), 80_000_000 * COIN / 10); //// start_era(20); //// assert_eq!(Staking::epoch_index(), 2); -//// assert_eq!(Staking::current_era_total_reward(), 9_999_988_266 * MILLICENTS / 1000); +//// assert_eq!(Staking::current_era_total_reward(), 9_999_988_266 * COIN / 1000); //// }); ////} //#[test] @@ -689,9 +683,9 @@ fn punished_unbond_should_work() { //#[test] //fn set_controller_should_not_change_ledger() { // ExtBuilder::default().existential_deposit(0).build().execute_with(|| { -// assert_eq!(Staking::ledger(&10).unwrap().active_ring, 100 * MILLICENTS); +// assert_eq!(Staking::ledger(&10).unwrap().active_ring, 100 * COIN); // assert_ok!(Staking::set_controller(Origin::signed(11), 12)); -// assert_eq!(Staking::ledger(&12).unwrap().active_ring, 100 * MILLICENTS); +// assert_eq!(Staking::ledger(&12).unwrap().active_ring, 100 * COIN); // }); //} // @@ -705,29 +699,29 @@ fn punished_unbond_should_work() { // old_ledger.active_ring, // old_ledger.active_deposit_ring // ), -// (100 * MILLICENTS, 100 * MILLICENTS) +// (100 * COIN, 100 * COIN) // ); // // assert_ok!(Staking::bond_extra( // Origin::signed(11), -// StakingBalance::Ring(100 * MILLICENTS), +// StakingBalance::Ring(100 * COIN), // 0 // )); -// Kton::deposit_creating(&11, 10 * MILLICENTS); +// Kton::deposit_creating(&11, 10 * COIN); // assert_ok!(Staking::bond_extra( // Origin::signed(11), -// StakingBalance::Kton(10 * MILLICENTS), +// StakingBalance::Kton(10 * COIN), // 0 // )); // -// assert_ok!(Staking::unbond(Origin::signed(10), StakingBalance::Ring(10 * MILLICENTS))); +// assert_ok!(Staking::unbond(Origin::signed(10), StakingBalance::Ring(10 * COIN))); // let new_ledger = Staking::ledger(&10).unwrap(); // assert_eq!( // ( // new_ledger.active_ring, // new_ledger.active_deposit_ring // ), -// (190 * MILLICENTS, 100 * MILLICENTS) +// (190 * COIN, 100 * COIN) // ); // // // slash 100% @@ -739,7 +733,7 @@ fn punished_unbond_should_work() { // // 10Ring in unbondings // (0, 0) // ); -// assert_eq!(ledger.unbondings[0].value, StakingBalance::Ring(10 * MILLICENTS)); +// assert_eq!(ledger.unbondings[0].value, StakingBalance::Ring(10 * COIN)); // }); //} // @@ -751,7 +745,7 @@ fn punished_unbond_should_work() { // Staking::bond( // Origin::signed(stash), // controller, -// StakingBalance::Ring(MILLICENTS), +// StakingBalance::Ring(COIN), // RewardDestination::Stash, // 37 // ), @@ -760,7 +754,7 @@ fn punished_unbond_should_work() { // // gen_paired_account!(stash(123), controller(456), promise_month(12)); // assert_err!( -// Staking::bond_extra(Origin::signed(stash), StakingBalance::Ring(MILLICENTS), 37), +// Staking::bond_extra(Origin::signed(stash), StakingBalance::Ring(COIN), 37), // "months at most is 36." // ); // }); @@ -774,7 +768,7 @@ fn punished_unbond_should_work() { // Staking::bond( // Origin::signed(11), // unpaired_controller, -// StakingBalance::Ring(MILLICENTS), +// StakingBalance::Ring(COIN), // RewardDestination::Stash, // 0 // ), @@ -784,7 +778,7 @@ fn punished_unbond_should_work() { // Staking::bond( // Origin::signed(unpaired_stash), // 10, -// StakingBalance::Ring(MILLICENTS), +// StakingBalance::Ring(COIN), // RewardDestination::Stash, // 0 // ), @@ -802,54 +796,54 @@ fn punished_unbond_should_work() { // // bond: 100COIN // gen_paired_account!(stash_1(111), controller_1(222), 0); // gen_paired_account!(stash_2(333), controller_2(444), promise_month(12)); -// ring_pool += 100 * MILLICENTS; -// kton_pool += 100 * MILLICENTS; +// ring_pool += 100 * COIN; +// kton_pool += 100 * COIN; // assert_eq!(Staking::ring_pool(), ring_pool); // assert_eq!(Staking::kton_pool(), kton_pool); // // // unbond: 50Ring 50Kton // assert_ok!(Staking::unbond( // Origin::signed(controller_1), -// StakingBalance::Ring(50 * MILLICENTS) +// StakingBalance::Ring(50 * COIN) // )); // assert_ok!(Staking::unbond( // Origin::signed(controller_1), -// StakingBalance::Kton(25 * MILLICENTS) +// StakingBalance::Kton(25 * COIN) // )); // // not yet expired: promise for 12 months // assert_ok!(Staking::unbond( // Origin::signed(controller_2), -// StakingBalance::Ring(50 * MILLICENTS) +// StakingBalance::Ring(50 * COIN) // )); // assert_ok!(Staking::unbond( // Origin::signed(controller_2), -// StakingBalance::Kton(25 * MILLICENTS) +// StakingBalance::Kton(25 * COIN) // )); -// ring_pool -= 50 * MILLICENTS; -// kton_pool -= 50 * MILLICENTS; +// ring_pool -= 50 * COIN; +// kton_pool -= 50 * COIN; // assert_eq!(Staking::ring_pool(), ring_pool); // assert_eq!(Staking::kton_pool(), kton_pool); // // // unbond with punish: 12.5Ring // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller_2), -// 125 * MILLICENTS / 10, +// 125 * COIN / 10, // promise_month * MONTH_IN_SECONDS as u64 // )); // // unbond deposit items: 12.5Ring // Timestamp::set_timestamp(promise_month * MONTH_IN_SECONDS as u64); // assert_ok!(Staking::unbond( // Origin::signed(controller_2), -// StakingBalance::Ring(125 * MILLICENTS / 10) +// StakingBalance::Ring(125 * COIN / 10) // )); -// ring_pool -= 25 * MILLICENTS; +// ring_pool -= 25 * COIN; // assert_eq!(Staking::ring_pool(), ring_pool); // // // slash: 25Ring 50Kton // Staking::slash_validator(&stash_1, 1_000_000_000); // Staking::slash_validator(&stash_2, 1_000_000_000); -// ring_pool -= 25 * MILLICENTS; -// kton_pool -= 50 * MILLICENTS; +// ring_pool -= 25 * COIN; +// kton_pool -= 50 * COIN; // assert_eq!(Staking::ring_pool(), ring_pool); // assert_eq!(Staking::kton_pool(), kton_pool); // }); @@ -864,7 +858,7 @@ fn punished_unbond_should_work() { // for _ in 1..deposit_items_len { // assert_ok!(Staking::bond_extra( // Origin::signed(stash), -// StakingBalance::Ring(MILLICENTS), +// StakingBalance::Ring(COIN), // promise_month // )); // } @@ -877,7 +871,7 @@ fn punished_unbond_should_work() { // Timestamp::set_timestamp(promise_month as u64 * MONTH_IN_SECONDS as u64); // // for _ in 1..deposit_items_len { -// assert_ok!(Staking::unbond(Origin::signed(controller), StakingBalance::Ring(MILLICENTS))); +// assert_ok!(Staking::unbond(Origin::signed(controller), StakingBalance::Ring(COIN))); // } // { // let ledger = Staking::ledger(&controller).unwrap(); @@ -887,7 +881,7 @@ fn punished_unbond_should_work() { // assert_err!( // Staking::unbond( // Origin::signed(controller), -// StakingBalance::Ring((deposit_items_len - 1) as u64 * MILLICENTS) +// StakingBalance::Ring((deposit_items_len - 1) as u64 * COIN) // ), // "can not schedule more unlock chunks" // ); @@ -901,34 +895,34 @@ fn punished_unbond_should_work() { // { // let stash = 444; // let controller = 555; -// let _ = Ring::deposit_creating(&stash, 100 * MILLICENTS); -// Kton::deposit_creating(&stash, 100 * MILLICENTS); +// let _ = Ring::deposit_creating(&stash, 100 * COIN); +// Kton::deposit_creating(&stash, 100 * COIN); // // assert_ok!(Staking::bond( // Origin::signed(stash), // controller, -// StakingBalance::Ring(50 * MILLICENTS), +// StakingBalance::Ring(50 * COIN), // RewardDestination::Stash, // 0 // )); // assert_ok!(Staking::bond_extra( // Origin::signed(stash), -// StakingBalance::Kton(50 * MILLICENTS), +// StakingBalance::Kton(50 * COIN), // 0 // )); // // let mut unbondings = Staking::ledger(&controller).unwrap().unbondings; // -// assert_ok!(Staking::unbond(Origin::signed(controller), StakingBalance::Ring(MILLICENTS))); +// assert_ok!(Staking::unbond(Origin::signed(controller), StakingBalance::Ring(COIN))); // unbondings.push(NormalLock { -// value: StakingBalance::Ring(MILLICENTS), +// value: StakingBalance::Ring(COIN), // era: 3, // is_time_deposit: false, // }); // assert_eq!(&Staking::ledger(&controller).unwrap().unbondings, &unbondings); -// assert_ok!(Staking::unbond(Origin::signed(controller), StakingBalance::Kton(MILLICENTS))); +// assert_ok!(Staking::unbond(Origin::signed(controller), StakingBalance::Kton(COIN))); // unbondings.push(NormalLock { -// value: StakingBalance::Kton(MILLICENTS), +// value: StakingBalance::Kton(COIN), // era: 3, // is_time_deposit: false, // }); @@ -956,13 +950,13 @@ fn punished_unbond_should_work() { // // assert_ok!(Staking::bond_extra( // Origin::signed(stash), -// StakingBalance::Ring(50 * MILLICENTS), +// StakingBalance::Ring(50 * COIN), // 36 // )); // // let mut unbondings = Staking::ledger(&controller).unwrap().unbondings; // -// assert_ok!(Staking::unbond(Origin::signed(controller), StakingBalance::Ring(MILLICENTS))); +// assert_ok!(Staking::unbond(Origin::signed(controller), StakingBalance::Ring(COIN))); // unbondings.push(NormalLock { // value: StakingBalance::Ring(0), // era: 3, @@ -973,11 +967,11 @@ fn punished_unbond_should_work() { // for month in [12, 36].iter() { // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller), -// 20 * MILLICENTS, +// 20 * COIN, // month * MONTH_IN_SECONDS as u64 // )); // unbondings.push(NormalLock { -// value: StakingBalance::Ring(20 * MILLICENTS), +// value: StakingBalance::Ring(20 * COIN), // era: 3, // is_time_deposit: true, // }); @@ -985,11 +979,11 @@ fn punished_unbond_should_work() { // // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller), -// 29 * MILLICENTS, +// 29 * COIN, // month * MONTH_IN_SECONDS as u64 // )); // unbondings.push(NormalLock { -// value: StakingBalance::Ring(29 * MILLICENTS), +// value: StakingBalance::Ring(29 * COIN), // era: 3, // is_time_deposit: true, // }); @@ -997,11 +991,11 @@ fn punished_unbond_should_work() { // // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller), -// 50 * MILLICENTS, +// 50 * COIN, // month * MONTH_IN_SECONDS as u64 // )); // unbondings.push(NormalLock { -// value: StakingBalance::Ring(1 * MILLICENTS), +// value: StakingBalance::Ring(1 * COIN), // era: 3, // is_time_deposit: true, // }); @@ -1029,17 +1023,17 @@ fn punished_unbond_should_work() { // // assert_ok!(Staking::bond_extra( // Origin::signed(stash), -// StakingBalance::Ring(5 * MILLICENTS), +// StakingBalance::Ring(5 * COIN), // 0 // )); // for _ in 0..expired_item_len { -// assert_ok!(Staking::promise_extra(Origin::signed(controller), MILLICENTS, promise_month)); +// assert_ok!(Staking::promise_extra(Origin::signed(controller), COIN, promise_month)); // } // // Timestamp::set_timestamp(expiry_date - 1); // assert_ok!(Staking::promise_extra( // Origin::signed(controller), -// 2 * MILLICENTS, +// 2 * COIN, // promise_month // )); // assert_eq!( @@ -1050,7 +1044,7 @@ fn punished_unbond_should_work() { // Timestamp::set_timestamp(expiry_date); // assert_ok!(Staking::promise_extra( // Origin::signed(controller), -// 2 * MILLICENTS, +// 2 * COIN, // promise_month // )); // assert_eq!(Staking::ledger(&controller).unwrap().deposit_items.len(), 2); @@ -1061,7 +1055,7 @@ fn punished_unbond_should_work() { //fn unbond_zero_before_expiry() { // ExtBuilder::default().existential_deposit(0).build().execute_with(|| { // let expiry_date = 12 * MONTH_IN_SECONDS as u64; -// let unbond_value = StakingBalance::Ring(MILLICENTS); +// let unbond_value = StakingBalance::Ring(COIN); // // Timestamp::set_timestamp(expiry_date - 1); // assert_ok!(Staking::unbond(Origin::signed(10), unbond_value.clone())); @@ -1110,7 +1104,7 @@ fn punished_unbond_should_work() { // // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller), -// 10_000 * MILLICENTS, +// 10_000 * COIN, // 12 * MONTH_IN_SECONDS as u64 // )); // assert_eq!(Kton::free_balance(&stash), 1); @@ -1134,7 +1128,7 @@ fn punished_unbond_should_work() { // // not enough Kton to unbond // assert_ok!(Staking::unbond_with_punish( // Origin::signed(controller), -// 10_000 * MILLICENTS, +// 10_000 * COIN, // 36 * MONTH_IN_SECONDS as u64 // )); // assert_eq!(&Staking::ledger(&controller).unwrap(), &ledger); @@ -1174,8 +1168,8 @@ fn punished_unbond_should_work() { // if with_new_era { // start_era(2); // } -// Staking::reward_validator(&validator_1_stash, 1000 * MILLICENTS); -// Staking::reward_validator(&validator_2_stash, 1000 * MILLICENTS); +// Staking::reward_validator(&validator_1_stash, 1000 * COIN); +// Staking::reward_validator(&validator_2_stash, 1000 * COIN); // // balance = Ring::free_balance(&nominator_stash); // });