Refactor as_sub to make things clearer. (#6503)

* Refactor as_sub to make things clearer.

- `as_sub` becomes `as_alternative`
- `as_sub_limited` becomes `as_derivative`
- `as_alternative` and `as_derivative` generate a mutually exclusive set of accounts.

* Test fix

* Add test

* Fix test

* Remove `as_alternative`.

* Docs.
This commit is contained in:
Gavin Wood
2020-06-26 11:03:02 +02:00
committed by GitHub
parent 39c3d1c026
commit 0532db6b86
4 changed files with 27 additions and 59 deletions
+6 -6
View File
@@ -138,16 +138,16 @@ fn expect_event<E: Into<TestEvent>>(e: E) {
}
#[test]
fn as_sub_works() {
fn as_derivative_works() {
new_test_ext().execute_with(|| {
let sub_1_0 = Utility::sub_account_id(1, 0);
let sub_1_0 = Utility::derivative_account_id(1, 0);
assert_ok!(Balances::transfer(Origin::signed(1), sub_1_0, 5));
assert_noop!(Utility::as_sub(
assert_noop!(Utility::as_derivative(
Origin::signed(1),
1,
Box::new(Call::Balances(BalancesCall::transfer(6, 3))),
), BalancesError::<Test, _>::InsufficientBalance);
assert_ok!(Utility::as_sub(
assert_ok!(Utility::as_derivative(
Origin::signed(1),
0,
Box::new(Call::Balances(BalancesCall::transfer(2, 3))),
@@ -158,9 +158,9 @@ fn as_sub_works() {
}
#[test]
fn as_sub_filters() {
fn as_derivative_filters() {
new_test_ext().execute_with(|| {
assert_noop!(Utility::as_sub(
assert_noop!(Utility::as_derivative(
Origin::signed(1),
1,
Box::new(Call::System(frame_system::Call::remark(vec![]))),