Skip to content

Commit 305e8a7

Browse files
committed
test: reset team on refund
1 parent bffa377 commit 305e8a7

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

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

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717
// If you feel like getting in touch with us, you can do so at [email protected]
18-
use frame_support::{assert_err, assert_ok};
18+
use frame_support::{assert_err, assert_ok, traits::fungibles::roles::Inspect};
1919
use frame_system::{pallet_prelude::OriginFor, RawOrigin};
2020
use sp_runtime::traits::BadOrigin;
2121

2222
use crate::{
2323
mock::{runtime::*, *},
24-
types::PoolStatus,
24+
types::{PoolManagingTeam, PoolStatus},
2525
AccountIdOf, Error, Event, Pools,
2626
};
2727

@@ -62,6 +62,56 @@ fn start_refund_works() {
6262
});
6363
}
6464

65+
#[test]
66+
fn start_refund_resets_asset_admin() {
67+
let pool_details = generate_pool_details(
68+
vec![DEFAULT_BONDED_CURRENCY_ID],
69+
get_linear_bonding_curve(),
70+
true,
71+
Some(PoolStatus::Active),
72+
Some(ACCOUNT_00),
73+
Some(DEFAULT_COLLATERAL_CURRENCY_ID),
74+
Some(ACCOUNT_00),
75+
None,
76+
);
77+
let pool_id: AccountIdOf<Test> = calculate_pool_id(&[DEFAULT_BONDED_CURRENCY_ID]);
78+
let currency_count = 1;
79+
80+
ExtBuilder::default()
81+
.with_pools(vec![(pool_id.clone(), pool_details)])
82+
.with_native_balances(vec![(ACCOUNT_00, u128::MAX)])
83+
.with_collaterals(vec![DEFAULT_COLLATERAL_CURRENCY_ID])
84+
.with_bonded_balance(vec![
85+
(DEFAULT_COLLATERAL_CURRENCY_ID, pool_id.clone(), u128::MAX / 10),
86+
(DEFAULT_BONDED_CURRENCY_ID, ACCOUNT_00, u128::MAX / 10),
87+
])
88+
.build()
89+
.execute_with(|| {
90+
let origin: OriginFor<Test> = RawOrigin::Signed(ACCOUNT_00).into();
91+
92+
assert_ok!(BondingPallet::reset_team(
93+
origin.clone(),
94+
pool_id.clone(),
95+
PoolManagingTeam {
96+
admin: ACCOUNT_00,
97+
freezer: ACCOUNT_00
98+
},
99+
0
100+
));
101+
102+
assert_eq!(Assets::admin(DEFAULT_BONDED_CURRENCY_ID), Some(ACCOUNT_00));
103+
assert_eq!(Assets::freezer(DEFAULT_BONDED_CURRENCY_ID), Some(ACCOUNT_00));
104+
105+
assert_ok!(BondingPallet::start_refund(origin, pool_id.clone(), currency_count));
106+
107+
// Verify that the pool state has been updated to refunding
108+
assert_eq!(Pools::<Test>::get(&pool_id).unwrap().state, PoolStatus::Refunding);
109+
110+
assert_eq!(Assets::admin(DEFAULT_BONDED_CURRENCY_ID), Some(pool_id.clone()));
111+
assert_eq!(Assets::freezer(DEFAULT_BONDED_CURRENCY_ID), Some(pool_id));
112+
});
113+
}
114+
65115
#[test]
66116
fn start_refund_fails_when_pool_not_live() {
67117
let pool_details = generate_pool_details(

0 commit comments

Comments
 (0)