Migrate generic-asset, identity and im-online to decl_error (#4473)

* Migrate generic-asset, identity and im-online to decl_error

* Update democracy tests

* Update nicks test
This commit is contained in:
Stanislav Tkach
2019-12-21 16:10:29 +02:00
committed by Shawn Tabrizi
parent f6cbf4421f
commit 2c2e0d772d
8 changed files with 153 additions and 77 deletions
+10 -12
View File
@@ -65,7 +65,7 @@ fn issuing_with_next_asset_id_overflow_should_not_work() {
permissions: default_permission
}
),
"No new assets id available."
Error::<Test>::NoIdAvailable
);
assert_eq!(GenericAsset::next_asset_id(), u32::max_value());
});
@@ -173,7 +173,7 @@ fn transferring_amount_should_fail_when_transferring_more_than_free_balance() {
));
assert_noop!(
GenericAsset::transfer(Origin::signed(1), asset_id, 2, 2000),
"balance too low to send amount"
Error::<Test>::InsufficientBalance
);
});
}
@@ -198,7 +198,7 @@ fn transferring_less_than_one_unit_should_not_work() {
assert_eq!(GenericAsset::free_balance(&asset_id, &1), 100);
assert_noop!(
GenericAsset::transfer(Origin::signed(1), asset_id, 2, 0),
"cannot transfer zero amount"
Error::<Test>::ZeroAmount
);
});
}
@@ -256,7 +256,7 @@ fn transferring_more_units_than_total_supply_should_not_work() {
assert_eq!(GenericAsset::free_balance(&asset_id, &1), 100);
assert_noop!(
GenericAsset::transfer(Origin::signed(1), asset_id, 2, 101),
"balance too low to send amount"
Error::<Test>::InsufficientBalance
);
});
}
@@ -424,7 +424,7 @@ fn reserve_should_moves_amount_from_balance_to_reserved_balance() {
#[test]
fn reserve_should_not_moves_amount_from_balance_to_reserved_balance() {
ExtBuilder::default().free_balance((1, 0, 100)).build().execute_with(|| {
assert_noop!(GenericAsset::reserve(&1, &0, 120), "not enough free funds");
assert_noop!(GenericAsset::reserve(&1, &0, 120), Error::<Test>::InsufficientBalance);
assert_eq!(GenericAsset::free_balance(&1, &0), 100);
assert_eq!(GenericAsset::reserved_balance(&1, &0), 0);
});
@@ -626,7 +626,7 @@ fn mint_should_throw_permission_error() {
assert_noop!(
GenericAsset::mint(Origin::signed(origin), asset_id, to_account, amount),
"The origin does not have permission to mint an asset."
Error::<Test>::NoMintPermission,
);
});
}
@@ -687,7 +687,7 @@ fn burn_should_throw_permission_error() {
assert_noop!(
GenericAsset::burn(Origin::signed(origin), asset_id, to_account, amount),
"The origin does not have permission to burn an asset."
Error::<Test>::NoBurnPermission,
);
});
}
@@ -873,8 +873,6 @@ fn update_permission_should_throw_error_when_lack_of_permissions() {
burn: Owner::None,
};
let expected_error_message = "Origin does not have enough permission to update permissions.";
assert_ok!(GenericAsset::create(
Origin::signed(origin),
AssetOptions {
@@ -885,7 +883,7 @@ fn update_permission_should_throw_error_when_lack_of_permissions() {
assert_noop!(
GenericAsset::update_permission(Origin::signed(origin), asset_id, new_permission),
expected_error_message,
Error::<Test>::NoUpdatePermission,
);
});
}
@@ -963,7 +961,7 @@ fn create_asset_with_non_reserved_asset_id_should_not_work() {
permissions: default_permission.clone()
}
),
"Asset id not available."
Error::<Test>::IdUnavailable,
);
});
}
@@ -1005,7 +1003,7 @@ fn create_asset_with_a_taken_asset_id_should_not_work() {
permissions: default_permission.clone()
}
),
"Asset id already taken."
Error::<Test>::IdAlreadyTaken,
);
});
}