add negative tests#11995
Conversation
frame/alliance/src/tests.rs
Outdated
| assert_noop!(Alliance::add_unscrupulous_items(user.clone(), vec![]), BadOrigin); | ||
|
|
||
| assert_noop!(Alliance::remove_unscrupulous_items(user.clone(), vec![]), BadOrigin); | ||
|
|
||
| assert_noop!(Alliance::announce(user, cid.clone()), Error::<Test, ()>::NotAlly); |
There was a problem hiding this comment.
there three checked by AnnouncementOrigin, which is configurable by user, and for these tests its mocked to return true for user 3
| }); | ||
| } | ||
|
|
||
| fn assert_powerless(user: Origin) { |
There was a problem hiding this comment.
Nice!
I think right not it make sense to check if method supposed to be executed by a member.
For add_unscrupulous_items for example, its not really a case, because its checked by AnnouncementOrigin provided by client of pallet.
If you think it should be different (should check if the caller is a member for example), I think we need a different issue for it.
There was a problem hiding this comment.
Otherwise in this context we are not really checking than the retirement made the use powerless, but more that announcement functionality is allowed only for AnnouncementOrigin
| // Move time on: | ||
| System::set_block_number(System::block_number() + RetirementPeriod::get()); | ||
|
|
||
| assert_powerless(Origin::signed(3)); |
frame/alliance/src/tests.rs
Outdated
|
|
||
| assert_noop!(Alliance::nominate_ally(user.clone(), 4), Error::<Test, ()>::NoVotingRights); | ||
|
|
||
| assert_noop!(Alliance::propose(user.clone(), 5, Box::new(proposal), 1000), Error::<Test, ()>::NoVotingRights); |
There was a problem hiding this comment.
@gilescope
the last one user.clone() could be just user
* Alliance pallet: retirement notice * add alliance pallet to benchmark list for dev chain * fix type * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * link weight generated by bench for retirement_notice method * migration to clear UpForKicking storage prefix * rename migration from v1 to v0_to_v1 * Apply suggestions from code review Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * rename `retirement-notice to give-retirement-notice * Apply suggestions from code review Co-authored-by: Squirrel <gilescope@gmail.com> * review fixes: update doc, saturating add, BlockNumber type alias * add suffix to duratin consts *_IN_BLOCKS * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * add negative tests (#11995) * add negative tests * remove tests powerless asserts checking against announcment origin * assert bad origin from announcement origin checks Co-authored-by: muharem <ismailov.m.h@gmail.com> Co-authored-by: command-bot <> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Squirrel <gilescope@gmail.com>
* Alliance pallet: retirement notice * add alliance pallet to benchmark list for dev chain * fix type * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * link weight generated by bench for retirement_notice method * migration to clear UpForKicking storage prefix * rename migration from v1 to v0_to_v1 * Apply suggestions from code review Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * rename `retirement-notice to give-retirement-notice * Apply suggestions from code review Co-authored-by: Squirrel <gilescope@gmail.com> * review fixes: update doc, saturating add, BlockNumber type alias * add suffix to duratin consts *_IN_BLOCKS * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * add negative tests (paritytech#11995) * add negative tests * remove tests powerless asserts checking against announcment origin * assert bad origin from announcement origin checks Co-authored-by: muharem <ismailov.m.h@gmail.com> Co-authored-by: command-bot <> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Squirrel <gilescope@gmail.com>
Added some more negative tests to make sure a retired person has no special privileges.
The last 3 asserts currently return Ok(()) and thus fail the test.
We're using 4 and the announcement origin is defined as the following in the mock:
Maybe I have got the test wrong in some way?