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 = 66u8)]
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 {
39
        super::*, polkadot_runtime_parachains::assigner_on_demand as parachains_assigner_on_demand,
40
    };
41

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

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