1
// Copyright 2019-2025 PureStake Inc.
2
// This file is part of Moonbeam.
3

            
4
// Moonbeam 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
// Moonbeam 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 Moonbeam.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
//! Assertion helpers for XCM tests
18

            
19
use crate::xcm_mock::{parachain, Assets, ParaA};
20
use xcm_simulator::TestExt;
21

            
22
// Balance assertion helpers
23

            
24
15
pub fn assert_asset_balance(account: &[u8; 20], asset_id: parachain::AssetId, expected: u128) {
25
15
	ParaA::execute_with(|| {
26
15
		let account_id = parachain::AccountId::from(*account);
27
15
		assert_eq!(Assets::balance(asset_id, &account_id), expected);
28
15
	});
29
15
}
30

            
31
// Balance change assertion helpers
32

            
33
2
pub fn assert_native_balance_decreased_by(
34
2
	account: &[u8; 20],
35
2
	initial_balance: u128,
36
2
	decrease: u128,
37
2
) {
38
2
	ParaA::execute_with(|| {
39
2
		let account_id = parachain::AccountId::from(*account);
40
2
		let current_balance = parachain::Balances::free_balance(&account_id);
41
2
		assert_eq!(current_balance, initial_balance - decrease);
42
2
	});
43
2
}