Introduce frozen indices. (#6307)

* Introduce frozen indices.

* Fix.

* Bump runtime

* Benchmark for freeze

* Fix

* fix benchmarks

* update freeze weights

* remove copy pasta

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
Gavin Wood
2020-06-09 16:31:18 +02:00
committed by GitHub
parent 07b984b609
commit d29baf9945
4 changed files with 94 additions and 15 deletions
+16 -2
View File
@@ -48,6 +48,20 @@ fn freeing_should_work() {
});
}
#[test]
fn freezing_should_work() {
new_test_ext().execute_with(|| {
assert_ok!(Indices::claim(Some(1).into(), 0));
assert_noop!(Indices::freeze(Some(1).into(), 1), Error::<Test>::NotAssigned);
assert_noop!(Indices::freeze(Some(2).into(), 0), Error::<Test>::NotOwner);
assert_ok!(Indices::freeze(Some(1).into(), 0));
assert_noop!(Indices::freeze(Some(1).into(), 0), Error::<Test>::Permanent);
assert_noop!(Indices::free(Some(1).into(), 0), Error::<Test>::Permanent);
assert_noop!(Indices::transfer(Some(1).into(), 2, 0), Error::<Test>::Permanent);
});
}
#[test]
fn indexing_lookup_should_work() {
new_test_ext().execute_with(|| {
@@ -87,7 +101,7 @@ fn transfer_index_on_accounts_should_work() {
fn force_transfer_index_on_preowned_should_work() {
new_test_ext().execute_with(|| {
assert_ok!(Indices::claim(Some(1).into(), 0));
assert_ok!(Indices::force_transfer(Origin::ROOT, 3, 0));
assert_ok!(Indices::force_transfer(Origin::ROOT, 3, 0, false));
assert_eq!(Balances::reserved_balance(1), 0);
assert_eq!(Balances::reserved_balance(3), 0);
assert_eq!(Indices::lookup_index(0), Some(3));
@@ -97,7 +111,7 @@ fn force_transfer_index_on_preowned_should_work() {
#[test]
fn force_transfer_index_on_free_should_work() {
new_test_ext().execute_with(|| {
assert_ok!(Indices::force_transfer(Origin::ROOT, 3, 0));
assert_ok!(Indices::force_transfer(Origin::ROOT, 3, 0, false));
assert_eq!(Balances::reserved_balance(3), 0);
assert_eq!(Indices::lookup_index(0), Some(3));
});