Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
cuteolaf committed Feb 24, 2023
1 parent bcaf363 commit e2daab0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pallets/asset_management/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<T: Config> Pallet<T> {
Ok(())
}

pub fn revoke_representative(who: T::AccountId) -> DispatchResult {
pub fn revoke_representative_role(who: T::AccountId) -> DispatchResult {
Roles::RepresentativeLog::<T>::mutate(&who, |val| {
let mut val0 = val.clone().unwrap();
val0.activated = false;
Expand Down
7 changes: 6 additions & 1 deletion pallets/asset_management/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,12 @@ pub mod pallet {
);

//revoke Representative Role
Self::revoke_representative(rep_account.clone()).ok();
Self::revoke_representative_role(rep_account.clone()).ok();
Onboarding::Houses::<T>::mutate(collection, item, |asset| {
let mut asset0 = asset.clone().unwrap();
asset0.representative = None;
*asset = Some(asset0);
});

Self::deposit_event(Event::RepresentativeDemoted {
candidate: rep_account,
Expand Down
7 changes: 7 additions & 0 deletions pallets/asset_management/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ fn test_integration_test() {
Error::<Test>::NotAPendingRepresentative
);

let asset = Onboarding::Pallet::<Test>::houses(NftColl::OFFICESTEST.value(), item_id0);
assert!(asset.is_some());
assert_eq!(asset.unwrap().representative, Some(FERDIE));

// FIXME: the following test should not fail
// assert_ok!(AssetManagement::launch_representative_session(
// origin_eve.clone(),
Expand Down Expand Up @@ -677,5 +681,8 @@ fn test_integration_test() {
//The line below evaluate the results of TEST_0, TEST_1, & TEST_2 by looking for the result
// of a correctly executed call.
assert!(!Roles::AccountsRolesLog::<Test>::contains_key(FERDIE));

let asset = Onboarding::Pallet::<Test>::houses(NftColl::OFFICESTEST.value(), item_id0);
assert!(asset.unwrap().representative.is_none());
});
}

0 comments on commit e2daab0

Please sign in to comment.