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 {cumulus_primitives_core::ParaId, parity_scale_codec::Encode};
18

            
19
pub type Balance = u128;
20

            
21
#[derive(Encode)]
22
pub enum RelayCall {
23
    #[codec(index = 56u8)]
24
    OnDemandAssignmentProvider(OnDemandAssignmentProviderCall),
25
}
26

            
27
#[derive(Encode)]
28
pub enum OnDemandAssignmentProviderCall {
29
    #[codec(index = 0u8)]
30
    PlaceOrderAllowDeath {
31
        max_amount: Balance,
32
        para_id: ParaId,
33
    },
34
}
35

            
36
#[cfg(test)]
37
mod tests {
38
    use {super::*, polkadot_runtime_parachains::on_demand as parachains_assigner_on_demand};
39

            
40
    #[test]
41
1
    fn encode_place_order_allow_death() {
42
1
        let max_amount = u128::MAX;
43
1
        let para_id = u32::MAX.into();
44
1
        let call = westend_runtime::RuntimeCall::OnDemandAssignmentProvider(
45
1
            parachains_assigner_on_demand::Call::place_order_allow_death {
46
1
                max_amount,
47
1
                para_id,
48
1
            },
49
1
        );
50
1
        let call2 = RelayCall::OnDemandAssignmentProvider(
51
1
            OnDemandAssignmentProviderCall::PlaceOrderAllowDeath {
52
1
                max_amount,
53
1
                para_id,
54
1
            },
55
1
        );
56
1

            
57
1
        // If this fails check most probably indices changed
58
1
        assert_eq!(call.encode(), call2.encode());
59
1
    }
60
}