Newer
Older
use frame_support::{construct_runtime, parameter_types, traits::SortedMembers};
mod oracle {
pub use super::super::*;
}
parameter_types! {
pub const BlockHashCount: u64 = 250;
}
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type BlockWeights = ();
type BlockLength = ();
thread_local! {
static TIME: RefCell<u32> = RefCell::new(0);
pub struct Timestamp;
impl Time for Timestamp {
type Moment = u32;
impl Timestamp {
pub fn set_timestamp(val: u32) {
TIME.with(|v| *v.borrow_mut() = val);
parameter_types! {
pub const MinimumCount: u32 = 3;
pub const ExpiresIn: u32 = 600;
pub const RootOperatorAccountId: AccountId = 4;
pub static OracleMembers: Vec<AccountId> = vec![1, 2, 3];
}
pub struct Members;
impl SortedMembers<AccountId> for Members {
fn sorted_members() -> Vec<AccountId> {
OracleMembers::get()
}
type CombineData = DefaultCombineData<Self, MinimumCount, ExpiresIn>;
type OracleKey = Key;
type OracleValue = Value;
type RootOperatorAccountId = RootOperatorAccountId;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
ModuleOracle: oracle::{Pallet, Storage, Call, Event<T>},
// This function basically just builds a genesis storage key/value store
// according to our desired mockup.
pub fn new_test_ext() -> sp_io::TestExternalities {
let storage = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t: sp_io::TestExternalities = storage.into();
t.execute_with(|| {
Timestamp::set_timestamp(12345);
});