-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update primitives #105
Update primitives #105
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,9 +20,13 @@ | |
pub mod currency { | ||
use node_primitives::Balance; | ||
|
||
pub const MILLICENTS: Balance = 1_000_000_000; | ||
pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. | ||
pub const DOLLARS: Balance = 100 * CENTS; | ||
pub const NANO: Balance = 1; | ||
pub const MICRO: Balance = 1_000 * NANO; | ||
pub const MILLI: Balance = 1_000 * MICRO; | ||
pub const COIN: Balance = 1_000 * MILLI; | ||
// pub const MILLICENTS: Balance = 1_000 * MILLI; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove comments |
||
// pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. | ||
// pub const DOLLARS: Balance = 100 * CENTS; | ||
} | ||
|
||
/// Time. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,33 @@ | ||
pub use node_runtime::constants::currency::MILLICENTS; | ||
|
||
use std::{cell::RefCell, collections::HashSet}; | ||
|
||
use sr_primitives::{ | ||
testing::Header, | ||
traits::{BlakeTwo256, IdentityLookup}, | ||
weights::Weight, | ||
Perbill, | ||
}; | ||
use srml_support::{impl_outer_origin, parameter_types}; | ||
use substrate_primitives::H256; | ||
|
||
use super::*; | ||
use crate::{GenesisConfig, Module}; | ||
|
||
pub const COIN: u64 = 1_000_000_000; | ||
use node_primitives::Balance; | ||
|
||
thread_local! { | ||
static SESSION: RefCell<(Vec<AccountId>, HashSet<AccountId>)> = RefCell::new(Default::default()); | ||
static EXISTENTIAL_DEPOSIT: RefCell<u64> = RefCell::new(0); | ||
static EXISTENTIAL_DEPOSIT: RefCell<Balance> = RefCell::new(0); | ||
} | ||
|
||
/// The AccountId alias in this test module. | ||
pub type AccountId = u64; | ||
// FIXME: | ||
// replace | ||
// testing::Header.number: u64 | ||
// with | ||
// node_primitives::BlockNumber | ||
pub type BlockNumber = u64; | ||
pub type Balance = u64; | ||
|
||
impl_outer_origin! { | ||
pub enum Origin for Test {} | ||
|
@@ -31,8 +37,8 @@ impl_outer_origin! { | |
#[derive(Clone, PartialEq, Eq, Debug)] | ||
pub struct Test; | ||
parameter_types! { | ||
pub const BlockHashCount: u64 = 250; | ||
pub const MaximumBlockWeight: u32 = 1024; | ||
pub const BlockHashCount: BlockNumber = 250; | ||
pub const MaximumBlockWeight: Weight = 1024; | ||
pub const MaximumBlockLength: u32 = 2 * 1024; | ||
pub const AvailableBlockRatio: Perbill = Perbill::one(); | ||
} | ||
|
@@ -71,7 +77,7 @@ impl Trait for Test { | |
} | ||
|
||
pub struct ExtBuilder { | ||
existential_deposit: u64, | ||
existential_deposit: Balance, | ||
} | ||
|
||
impl Default for ExtBuilder { | ||
|
@@ -81,7 +87,7 @@ impl Default for ExtBuilder { | |
} | ||
|
||
impl ExtBuilder { | ||
pub fn existential_deposit(mut self, existential_deposit: u64) -> Self { | ||
pub fn existential_deposit(mut self, existential_deposit: Balance) -> Self { | ||
self.existential_deposit = existential_deposit; | ||
self | ||
} | ||
|
@@ -94,9 +100,9 @@ impl ExtBuilder { | |
self.set_associated_consts(); | ||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap(); | ||
let balance_factor = if self.existential_deposit > 0 { | ||
1_000 * COIN | ||
1_000 * MILLICENTS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} else { | ||
1 * COIN | ||
1 * MILLICENTS | ||
}; | ||
|
||
let _ = GenesisConfig::<Test> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep COIN plz