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
use {
18
    cumulus_primitives_core::Junctions::X1,
19
    emulated_integration_tests_common::build_genesis_storage,
20
    pallet_configuration::HostConfiguration,
21
    sp_core::storage::Storage,
22
    tanssi_emulated_integration_tests_common::accounts::{get_aura_id_from_seed, ALICE, BOB},
23
    xcm::prelude::*,
24
    xcm_builder::{ParentIsPreset, SiblingParachainConvertsVia},
25
    xcm_executor::traits::ConvertLocation,
26
};
27

            
28
88
pub fn genesis() -> Storage {
29
88
    let genesis_config = dancebox_runtime::RuntimeGenesisConfig {
30
88
        balances: dancebox_runtime::BalancesConfig {
31
88
            balances: vec![
32
88
                // Alice gets 10k extra tokens for her mapping deposit
33
88
                (
34
88
                    dancebox_runtime::AccountId::from(ALICE),
35
88
                    210_000 * dancebox_runtime::UNIT,
36
88
                ),
37
88
                (
38
88
                    dancebox_runtime::AccountId::from(BOB),
39
88
                    100_000 * dancebox_runtime::UNIT,
40
88
                ),
41
88
                // Give some balance to the relay chain account
42
88
                (
43
88
                    ParentIsPreset::<dancebox_runtime::AccountId>::convert_location(
44
88
                        &Location::parent(),
45
88
                    )
46
88
                    .unwrap(),
47
88
                    100_000 * dancebox_runtime::UNIT,
48
88
                ),
49
88
                // And to sovereigns
50
88
                (
51
88
                    SiblingParachainConvertsVia::<
52
88
                        polkadot_parachain_primitives::primitives::Sibling,
53
88
                        dancebox_runtime::AccountId,
54
88
                    >::convert_location(&Location {
55
88
                        parents: 1,
56
88
                        interior: X1([Parachain(2001u32)].into()),
57
88
                    })
58
88
                    .unwrap(),
59
88
                    100_000 * dancebox_runtime::UNIT,
60
88
                ),
61
88
                (
62
88
                    SiblingParachainConvertsVia::<
63
88
                        polkadot_parachain_primitives::primitives::Sibling,
64
88
                        dancebox_runtime::AccountId,
65
88
                    >::convert_location(&Location {
66
88
                        parents: 1,
67
88
                        interior: X1([Parachain(2002u32)].into()),
68
88
                    })
69
88
                    .unwrap(),
70
88
                    100_000 * dancebox_runtime::UNIT,
71
88
                ),
72
88
            ],
73
88
            ..Default::default()
74
88
        },
75
88
        configuration: dancebox_runtime::ConfigurationConfig {
76
88
            config: HostConfiguration {
77
88
                max_collators: 100,
78
88
                min_orchestrator_collators: 1,
79
88
                max_orchestrator_collators: 1,
80
88
                collators_per_container: 1,
81
88
                collators_per_parathread: 1,
82
88
                full_rotation_period: 0,
83
88
                ..Default::default()
84
88
            },
85
88
            ..Default::default()
86
88
        },
87
88
        invulnerables: dancebox_runtime::InvulnerablesConfig {
88
88
            invulnerables: vec![
89
88
                (
90
88
                    dancebox_runtime::AccountId::from(ALICE),
91
88
                    210 * dancebox_runtime::UNIT,
92
88
                ),
93
88
                (
94
88
                    dancebox_runtime::AccountId::from(BOB),
95
88
                    100 * dancebox_runtime::UNIT,
96
88
                ),
97
88
            ]
98
88
            .clone()
99
88
            .into_iter()
100
176
            .map(|(account, _balance)| account)
101
88
            .collect(),
102
88
        },
103
88
        parachain_info: dancebox_runtime::ParachainInfoConfig {
104
88
            parachain_id: 2000u32.into(),
105
88
            ..Default::default()
106
88
        },
107
88
        polkadot_xcm: dancebox_runtime::PolkadotXcmConfig {
108
88
            safe_xcm_version: 3.into(),
109
88
            ..Default::default()
110
88
        },
111
88
        session: dancebox_runtime::SessionConfig {
112
88
            keys: vec![
113
88
                (
114
88
                    dancebox_runtime::AccountId::from(ALICE),
115
88
                    210 * dancebox_runtime::UNIT,
116
88
                ),
117
88
                (
118
88
                    dancebox_runtime::AccountId::from(BOB),
119
88
                    100 * dancebox_runtime::UNIT,
120
88
                ),
121
88
            ]
122
88
            .into_iter()
123
176
            .map(|(account, _balance)| {
124
176
                let nimbus_id = get_aura_id_from_seed(&account.to_string());
125
176
                (
126
176
                    account.clone(),
127
176
                    account,
128
176
                    dancebox_runtime::SessionKeys { nimbus: nimbus_id },
129
176
                )
130
176
            })
131
88
            .collect(),
132
88
            ..Default::default()
133
88
        },
134
88
        ..Default::default()
135
88
    };
136
88

            
137
88
    let mut storage =
138
88
        build_genesis_storage(&genesis_config, dancebox_runtime::WASM_BINARY.unwrap());
139
88

            
140
88
    storage
141
88
        .top
142
88
        .insert(b"__mock_is_xcm_test".to_vec(), b"1".to_vec());
143
88

            
144
88
    storage
145
88
}