This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
nomination-pools: allow pool-ids to be reused #12407
Merged
paritytech-processbot
merged 13 commits into
paritytech:master
from
Doordashcon:ddc-RPI-T1
Oct 29, 2022
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0edf4d6
initial
Doordashcon 94f6170
logic check
Doordashcon d7b3ad3
do_create
Doordashcon dfe6b9a
Merge branch 'paritytech:master' into ddc-RPI-T1
Doordashcon f282d90
cargo fmt
Doordashcon 1a11c59
fixes
Doordashcon 290c061
Merge branch 'paritytech:master' into ddc-RPI-T1
Doordashcon 77c43d1
ensure_signed
Doordashcon f989c64
Merge branch 'paritytech:master' into ddc-RPI-T1
Doordashcon 643db1c
update
Doordashcon 260932c
cargo fmt
Doordashcon b55ac0b
Merge branch 'paritytech:master' into ddc-RPI-T1
Doordashcon 268eb8f
remove unused import
Doordashcon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4198,6 +4198,44 @@ mod create { | |
); | ||
}); | ||
} | ||
|
||
#[test] | ||
fn create_with_pool_id_works() { | ||
ExtBuilder::default().build_and_execute(|| { | ||
let ed = Balances::minimum_balance(); | ||
|
||
Balances::make_free_balance_be(&11, StakingMock::minimum_bond() + ed); | ||
assert_ok!(Pools::create( | ||
RuntimeOrigin::signed(11), | ||
StakingMock::minimum_bond(), | ||
123, | ||
456, | ||
789 | ||
)); | ||
Comment on lines
+4207
to
+4214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are accounts created in mock.rs that are already funded. You need not create a new one. also, I think this test will pass entirely without you creating this new pool as well, not sure what you are testing here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an assumption I have that I would like clarified....If there is only ever one nomination pool created the |
||
|
||
assert_eq!(Balances::free_balance(&11), 0); | ||
// delete the initial pool created, then pool_Id `1` will be free | ||
|
||
assert_noop!( | ||
Pools::create_with_pool_id(RuntimeOrigin::signed(12), 20, 234, 654, 783, 1), | ||
Error::<Runtime>::PoolIdInUse | ||
); | ||
|
||
assert_noop!( | ||
Pools::create_with_pool_id(RuntimeOrigin::signed(12), 20, 234, 654, 783, 3), | ||
Error::<Runtime>::InvalidPoolId | ||
); | ||
|
||
// start dismantling the pool. | ||
assert_ok!(Pools::set_state(RuntimeOrigin::signed(902), 1, PoolState::Destroying)); | ||
assert_ok!(fully_unbond_permissioned(10)); | ||
|
||
CurrentEra::set(3); | ||
assert_ok!(Pools::withdraw_unbonded(RuntimeOrigin::signed(10), 10, 10)); | ||
|
||
assert_ok!(Pools::create_with_pool_id(RuntimeOrigin::signed(10), 20, 234, 654, 783, 1)); | ||
}); | ||
} | ||
} | ||
|
||
mod nominate { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ensure_signed must always be the first operation! If you start reading storage before checking the origin, it is a DOS attack.