Skip to content

Commit 62680ee

Browse files
committed
test: reset team on refund
1 parent 1ad53b2 commit 62680ee

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

pallets/pallet-bonded-coins/src/tests/transactions/start_refund.rs

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use frame_support::{assert_err, assert_ok};
1+
use frame_support::{assert_err, assert_ok, traits::fungibles::roles::Inspect};
22
use frame_system::{pallet_prelude::OriginFor, RawOrigin};
33
use sp_runtime::traits::BadOrigin;
44

55
use crate::{
66
mock::{runtime::*, *},
7-
types::PoolStatus,
7+
types::{PoolManagingTeam, PoolStatus},
88
AccountIdOf, Error, Event, Pools,
99
};
1010

@@ -45,6 +45,55 @@ fn start_refund_works() {
4545
});
4646
}
4747

48+
#[test]
49+
fn start_refund_resets_asset_admin() {
50+
let pool_details = generate_pool_details(
51+
vec![DEFAULT_BONDED_CURRENCY_ID],
52+
get_linear_bonding_curve(),
53+
true,
54+
Some(PoolStatus::Active),
55+
Some(ACCOUNT_00),
56+
Some(DEFAULT_COLLATERAL_CURRENCY_ID),
57+
Some(ACCOUNT_00),
58+
);
59+
let pool_id: AccountIdOf<Test> = calculate_pool_id(&[DEFAULT_BONDED_CURRENCY_ID]);
60+
let currency_count = 1;
61+
62+
ExtBuilder::default()
63+
.with_pools(vec![(pool_id.clone(), pool_details.clone())])
64+
.with_native_balances(vec![(ACCOUNT_00, u128::MAX)])
65+
.with_collaterals(vec![DEFAULT_COLLATERAL_CURRENCY_ID])
66+
.with_bonded_balance(vec![
67+
(DEFAULT_COLLATERAL_CURRENCY_ID, pool_id.clone(), u128::MAX / 10),
68+
(DEFAULT_BONDED_CURRENCY_ID, ACCOUNT_00, u128::MAX / 10),
69+
])
70+
.build()
71+
.execute_with(|| {
72+
let origin: OriginFor<Test> = RawOrigin::Signed(ACCOUNT_00).into();
73+
74+
assert_ok!(BondingPallet::reset_team(
75+
origin.clone(),
76+
pool_id.clone(),
77+
PoolManagingTeam {
78+
admin: ACCOUNT_00,
79+
freezer: ACCOUNT_00
80+
},
81+
0
82+
));
83+
84+
assert_eq!(Assets::admin(DEFAULT_BONDED_CURRENCY_ID), Some(ACCOUNT_00));
85+
assert_eq!(Assets::freezer(DEFAULT_BONDED_CURRENCY_ID), Some(ACCOUNT_00));
86+
87+
assert_ok!(BondingPallet::start_refund(origin, pool_id.clone(), currency_count));
88+
89+
// Verify that the pool state has been updated to refunding
90+
assert_eq!(Pools::<Test>::get(&pool_id).unwrap().state, PoolStatus::Refunding);
91+
92+
assert_eq!(Assets::admin(DEFAULT_BONDED_CURRENCY_ID), Some(pool_id.clone()));
93+
assert_eq!(Assets::freezer(DEFAULT_BONDED_CURRENCY_ID), Some(pool_id));
94+
});
95+
}
96+
4897
#[test]
4998
fn start_refund_fails_when_pool_not_live() {
5099
let pool_details = generate_pool_details(

0 commit comments

Comments
 (0)