|
| 1 | +// This file is part of https://github.com/galacticcouncil/* |
| 2 | +// |
| 3 | +// $$$$$$$ Licensed under the Apache License, Version 2.0 (the "License") |
| 4 | +// $$$$$$$$$$$$$ you may only use this file in compliance with the License |
| 5 | +// $$$$$$$$$$$$$$$$$$$ |
| 6 | +// $$$$$$$$$ Copyright (C) 2021-2024 Intergalactic, Limited (GIB) |
| 7 | +// $$$$$$$$$$$ $$$$$$$$$$ SPDX-License-Identifier: Apache-2.0 |
| 8 | +// $$$$$$$$$$$$$$$$$$$$$$$$$$ |
| 9 | +// $$$$$$$$$$$$$$$$$$$$$$$ $ Built with <3 for decentralisation |
| 10 | +// $$$$$$$$$$$$$$$$$$$ $$$$$$$ |
| 11 | +// $$$$$$$ $$$$$$$$$$$$$$$$$$ Unless required by applicable law or agreed to in |
| 12 | +// $ $$$$$$$$$$$$$$$$$$$$$$$ writing, software distributed under the License is |
| 13 | +// $$$$$$$$$$$$$$$$$$$$$$$$$$ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES |
| 14 | +// $$$$$$$$$ $$$$$$$$$$$ OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +// $$$$$$$$ |
| 16 | +// $$$$$$$$$$$$$$$$$$ See the License for the specific language governing |
| 17 | +// $$$$$$$$$$$$$ permissions and limitations under the License. |
| 18 | +// $$$$$$$ |
| 19 | +// $$ |
| 20 | +// $$$$$ $$$$$ $$ $ |
| 21 | +// $$$ $$$ $$$ $$ $$$$$ $$ $$$ $$$$ $$$$$$$ $$$$ $$$ $$$$$$ $$ $$$$$$ |
| 22 | +// $$$ $$$ $$$ $$ $$$ $$$ $$$ $ $$ $$ $$ $$ $$ $$ $$$ $$$ |
| 23 | +// $$$$$$$$$$$ $$ $$ $$$ $$ $$ $$$$$$$ $$ $$ $$ $$$ $$ $$ |
| 24 | +// $$$ $$$ $$$$ $$$ $$ $$ $$$ $$ $$ $$ $$ $$ $$ $$ |
| 25 | +// $$$$$ $$$$$ $$ $$$$$$$$ $ $$$ $$$$$$$$ $$$ $$$$ $$$$$$$ $$$$ $$$$ |
| 26 | +// $$$ |
| 27 | + |
| 28 | +use crate::polkadot_test_net::*; |
| 29 | +use codec::Encode; |
| 30 | +use hydradx_runtime::*; |
| 31 | +use primitives::constants::time::{HOURS, MINUTES}; |
| 32 | +use sp_core::{storage::StorageKey, Get}; |
| 33 | +use xcm_emulator::TestExt; |
| 34 | + |
| 35 | +#[test] |
| 36 | +fn is_testnet_sets_correct_referenda_params_when_default() { |
| 37 | + TestNet::reset(); |
| 38 | + Hydra::execute_with(|| { |
| 39 | + // Assert |
| 40 | + let tracks = <hydradx_runtime::Runtime as pallet_referenda::Config>::Tracks::get(); |
| 41 | + |
| 42 | + let root_track = tracks |
| 43 | + .iter() |
| 44 | + .find(|(id, _info)| *id == 0) |
| 45 | + .expect("Root track should exist"); |
| 46 | + |
| 47 | + assert_eq!(root_track.1.prepare_period, HOURS); |
| 48 | + assert_eq!(root_track.1.confirm_period, 12 * HOURS); |
| 49 | + assert_eq!(root_track.1.min_enactment_period, 10 * MINUTES); |
| 50 | + }); |
| 51 | +} |
| 52 | + |
| 53 | +#[test] |
| 54 | +fn is_testnet_sets_correct_referenda_params_when_testnet() { |
| 55 | + TestNet::reset(); |
| 56 | + Hydra::execute_with(|| { |
| 57 | + // Prepare |
| 58 | + let key = StorageKey(frame_support::storage::storage_prefix(b"Parameters", b"IsTestnet").to_vec()); |
| 59 | + let value = true.encode(); |
| 60 | + sp_io::storage::set(&key.0, &value); |
| 61 | + |
| 62 | + // Assert |
| 63 | + let tracks = <hydradx_runtime::Runtime as pallet_referenda::Config>::Tracks::get(); |
| 64 | + let root_track = tracks |
| 65 | + .iter() |
| 66 | + .find(|(id, _info)| *id == 0) |
| 67 | + .expect("Root track should exist"); |
| 68 | + |
| 69 | + assert_eq!(root_track.1.prepare_period, 1); |
| 70 | + assert_eq!(root_track.1.confirm_period, 1); |
| 71 | + assert_eq!(root_track.1.min_enactment_period, 1); |
| 72 | + }); |
| 73 | +} |
0 commit comments