-
Notifications
You must be signed in to change notification settings - Fork 31
RMNRemote: curse admin management + blessing removal [CCIP-10871] #1991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
0e48d42
562749c
6146e92
2e46186
859aebd
cb2f428
0d81f1f
ba7b90e
bd92861
4e4d1a3
276b4ad
bc1c30b
f824349
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,9 +27,117 @@ contract RMNRemote_curse is RMNRemoteSetup { | |
| } | ||
|
|
||
| function test_RevertWhen_curse_calledByNonOwner() public { | ||
| vm.expectRevert(abi.encodeWithSelector(RMNRemote.OnlyOwnerOrCurseAdmin.selector, STRANGER)); | ||
|
Collaborator
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. nit: nothing should be between the expect and the call, pranks should be done before the expect |
||
| vm.stopPrank(); | ||
| vm.prank(STRANGER); | ||
| s_rmnRemote.curse(s_curseSubjects); | ||
| } | ||
| } | ||
|
|
||
| contract RMNRemote_curseAdmin is RMNRemoteSetup { | ||
|
Collaborator
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. We only allow a single contract per file. See the style guide |
||
| address internal s_curseAdmin = makeAddr("curseAdmin"); | ||
|
|
||
| function setUp() public override { | ||
| super.setUp(); | ||
| address[] memory adds = new address[](1); | ||
| adds[0] = s_curseAdmin; | ||
| s_rmnRemote.applyCurseAdminUpdates(new address[](0), adds); | ||
| } | ||
|
|
||
| function test_curse_byCurseAdmin_Success() public { | ||
|
Collaborator
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. nit: we no longer use |
||
| vm.expectEmit(); | ||
| emit RMNRemote.Cursed(s_curseSubjects); | ||
|
|
||
| vm.stopPrank(); | ||
| vm.prank(s_curseAdmin); | ||
| s_rmnRemote.curse(s_curseSubjects); | ||
|
|
||
| assertTrue(s_rmnRemote.isCursed(CURSE_SUBJ_1)); | ||
| assertTrue(s_rmnRemote.isCursed(CURSE_SUBJ_2)); | ||
| } | ||
|
|
||
| function test_applyCurseAdminUpdates_addsAndRemoves() public { | ||
|
Collaborator
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. We have one file per tested function. Should be semi-solved if you use allowedCallers instead of custom code as that will reduce the to-be-tested functions a lot. |
||
| address newAdmin = makeAddr("newAdmin"); | ||
| address[] memory adds = new address[](1); | ||
| adds[0] = newAdmin; | ||
|
|
||
| vm.expectEmit(); | ||
| emit RMNRemote.CurseAdminAdded(newAdmin); | ||
| s_rmnRemote.applyCurseAdminUpdates(new address[](0), adds); | ||
| assertTrue(s_rmnRemote.isCurseAdmin(newAdmin)); | ||
|
|
||
| address[] memory adminList = s_rmnRemote.getCurseAdmins(); | ||
| assertEq(adminList.length, 2); // s_curseAdmin (from setUp) + newAdmin | ||
|
|
||
| // Duplicate add is idempotent (no event emitted) | ||
| vm.recordLogs(); | ||
| s_rmnRemote.applyCurseAdminUpdates(new address[](0), adds); | ||
| assertEq(vm.getRecordedLogs().length, 0); | ||
|
|
||
| // Remove | ||
| address[] memory toRemove = new address[](1); | ||
| toRemove[0] = newAdmin; | ||
| vm.expectEmit(); | ||
| emit RMNRemote.CurseAdminRemoved(newAdmin); | ||
| s_rmnRemote.applyCurseAdminUpdates(toRemove, new address[](0)); | ||
| assertFalse(s_rmnRemote.isCurseAdmin(newAdmin)); | ||
|
|
||
| // Remove of non-member is idempotent (no event emitted) | ||
| vm.recordLogs(); | ||
| s_rmnRemote.applyCurseAdminUpdates(toRemove, new address[](0)); | ||
| assertEq(vm.getRecordedLogs().length, 0); | ||
| } | ||
|
|
||
| function test_RevertWhen_applyCurseAdminUpdates_calledByNonOwner() public { | ||
| vm.expectRevert(Ownable2Step.OnlyCallableByOwner.selector); | ||
| vm.stopPrank(); | ||
| vm.prank(STRANGER); | ||
| s_rmnRemote.applyCurseAdminUpdates(new address[](0), new address[](0)); | ||
| } | ||
|
|
||
| function test_curse_byOwner_SuccessWhenCurseAdminsExist() public { | ||
| vm.expectEmit(); | ||
| emit RMNRemote.Cursed(s_curseSubjects); | ||
| s_rmnRemote.curse(s_curseSubjects); | ||
|
|
||
| assertTrue(s_rmnRemote.isCursed(CURSE_SUBJ_1)); | ||
| assertTrue(s_rmnRemote.isCursed(CURSE_SUBJ_2)); | ||
| } | ||
|
|
||
| function test_curse_byNewlyAddedCurseAdmin_Success() public { | ||
| address newAdmin = makeAddr("newAdmin"); | ||
| address[] memory adds = new address[](1); | ||
| adds[0] = newAdmin; | ||
| s_rmnRemote.applyCurseAdminUpdates(new address[](0), adds); | ||
|
|
||
| vm.expectEmit(); | ||
| emit RMNRemote.Cursed(s_curseSubjects); | ||
|
|
||
| vm.stopPrank(); | ||
| vm.prank(newAdmin); | ||
| s_rmnRemote.curse(s_curseSubjects); | ||
|
|
||
| assertTrue(s_rmnRemote.isCursed(CURSE_SUBJ_1)); | ||
| assertTrue(s_rmnRemote.isCursed(CURSE_SUBJ_2)); | ||
| } | ||
|
|
||
| function test_RevertWhen_curse_calledByRemovedCurseAdmin() public { | ||
| address[] memory toRemove = new address[](1); | ||
| toRemove[0] = s_curseAdmin; | ||
| s_rmnRemote.applyCurseAdminUpdates(toRemove, new address[](0)); | ||
|
|
||
| vm.expectRevert(abi.encodeWithSelector(RMNRemote.OnlyOwnerOrCurseAdmin.selector, s_curseAdmin)); | ||
| vm.stopPrank(); | ||
| vm.prank(s_curseAdmin); | ||
| s_rmnRemote.curse(s_curseSubjects); | ||
| } | ||
|
|
||
| function test_RevertWhen_uncurse_calledByCurseAdmin() public { | ||
| s_rmnRemote.curse(s_curseSubjects); | ||
|
|
||
| vm.expectRevert(Ownable2Step.OnlyCallableByOwner.selector); | ||
| vm.stopPrank(); | ||
| vm.prank(s_curseAdmin); | ||
| s_rmnRemote.uncurse(s_curseSubjects); | ||
| } | ||
| } | ||
This file was deleted.
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.