1
// Copyright (C) Moondance Labs Ltd.
2
// This file is part of Tanssi.
3

            
4
// Tanssi is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Tanssi is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Tanssi.  If not, see <http://www.gnu.org/licenses/>
16

            
17
#![cfg(test)]
18

            
19
use {
20
    crate::{tests::common::*, Configuration},
21
    frame_support::assert_ok,
22
    runtime_parachains::configuration as parachains_configuration,
23
};
24

            
25
#[test]
26
1
fn test_configuration_on_session_change() {
27
1
    ExtBuilder::default().build().execute_with(|| {
28
1
        assert_eq!(
29
1
            parachains_configuration::ActiveConfig::<Runtime>::get().dispute_period,
30
1
            6
31
1
        );
32
1
        assert_eq!(
33
1
            parachains_configuration::ActiveConfig::<Runtime>::get()
34
1
                .minimum_validation_upgrade_delay,
35
1
            2
36
1
        );
37

            
38
        // We need to advance to the first session first
39
1
        run_to_session(1u32);
40
1
        assert_ok!(
41
1
            Configuration::set_minimum_validation_upgrade_delay(root_origin(), 50),
42
1
            ()
43
1
        );
44

            
45
1
        run_to_session(2u32);
46
1

            
47
1
        assert_ok!(Configuration::set_dispute_period(root_origin(), 20), ());
48
1
        assert_eq!(
49
1
            parachains_configuration::ActiveConfig::<Runtime>::get().dispute_period,
50
1
            6
51
1
        );
52
1
        assert_eq!(
53
1
            parachains_configuration::ActiveConfig::<Runtime>::get()
54
1
                .minimum_validation_upgrade_delay,
55
1
            2
56
1
        );
57

            
58
1
        run_to_session(3u32);
59
1
        assert_eq!(
60
1
            parachains_configuration::ActiveConfig::<Runtime>::get().dispute_period,
61
1
            6
62
1
        );
63
1
        assert_eq!(
64
1
            parachains_configuration::ActiveConfig::<Runtime>::get()
65
1
                .minimum_validation_upgrade_delay,
66
1
            50
67
1
        );
68

            
69
1
        run_to_session(4u32);
70
1

            
71
1
        assert_eq!(
72
1
            parachains_configuration::ActiveConfig::<Runtime>::get().dispute_period,
73
1
            20
74
1
        );
75
1
        assert_eq!(
76
1
            parachains_configuration::ActiveConfig::<Runtime>::get()
77
1
                .minimum_validation_upgrade_delay,
78
1
            50
79
1
        );
80
1
    });
81
1
}