Remove Purchase Pallet from Polkadot + Westend (#1636)

* Remove purchase pallet

* Update runtime/common/src/purchase.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Actually check and fix compile

* Add events to dummy

* Fix kusama too

* remove events where it did not exist historically

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Shawn Tabrizi
2020-09-08 15:10:28 +02:00
committed by GitHub
parent d1b1c17285
commit 4d31f8159d
5 changed files with 101 additions and 204 deletions
+50
View File
@@ -371,6 +371,20 @@ fn account_to_bytes<AccountId>(account: &AccountId) -> Result<[u8; 32], Dispatch
Ok(bytes)
}
/// WARNING: Executing this function will clear all storage used by this pallet.
/// Be sure this is what you want...
pub fn remove_pallet<T>() -> frame_support::weights::Weight
where T: frame_system::Trait
{
use frame_support::migration::remove_storage_prefix;
remove_storage_prefix(b"Purchase", b"Accounts", b"");
remove_storage_prefix(b"Purchase", b"PaymentAccount", b"");
remove_storage_prefix(b"Purchase", b"Statement", b"");
remove_storage_prefix(b"Purchase", b"UnlockBlock", b"");
T::MaximumBlockWeight::get()
}
#[cfg(test)]
mod tests {
use super::*;
@@ -1011,4 +1025,40 @@ mod tests {
), BalancesError::<Test, _>::InsufficientBalance);
});
}
#[test]
fn remove_pallet_works() {
new_test_ext().execute_with(|| {
let account_status = AccountStatus {
validity: AccountValidity::Completed,
free_balance: 1234,
locked_balance: 4321,
signature: b"my signature".to_vec(),
vat: Permill::from_percent(50),
};
// Add some storage.
Accounts::<Test>::insert(alice(), account_status.clone());
Accounts::<Test>::insert(bob(), account_status);
PaymentAccount::<Test>::put(alice());
Statement::put(b"hello, world!".to_vec());
UnlockBlock::<Test>::put(4);
// Verify storage exists.
assert_eq!(Accounts::<Test>::iter().count(), 2);
assert!(PaymentAccount::<Test>::exists());
assert!(Statement::exists());
assert!(UnlockBlock::<Test>::exists());
// Remove storage.
remove_pallet::<Test>();
// Verify storage is gone.
assert_eq!(Accounts::<Test>::iter().count(), 0);
assert!(!PaymentAccount::<Test>::exists());
assert!(!Statement::exists());
assert!(!UnlockBlock::<Test>::exists());
});
}
}