@@ -1063,6 +1063,7 @@ describe('AccessManager', function () {
10631063
10641064 describe ( 'restrictions' , function ( ) {
10651065 beforeEach ( 'set method and args' , function ( ) {
1066+ this . operationDelayTarget = this . newManagedTarget ;
10661067 this . calldata = this . manager . interface . encodeFunctionData ( 'updateAuthority(address,address)' , [
10671068 this . newManagedTarget . target ,
10681069 this . newAuthority . target ,
@@ -1086,6 +1087,7 @@ describe('AccessManager', function () {
10861087 describe ( '#setTargetClosed' , function ( ) {
10871088 describe ( 'restrictions' , function ( ) {
10881089 beforeEach ( 'set method and args' , function ( ) {
1090+ this . operationDelayTarget = this . other ;
10891091 const args = [ this . other . address , true ] ;
10901092 const method = this . manager . interface . getFunction ( 'setTargetClosed(address,bool)' ) ;
10911093 this . calldata = this . manager . interface . encodeFunctionData ( method , args ) ;
@@ -1124,6 +1126,7 @@ describe('AccessManager', function () {
11241126 describe ( '#setTargetFunctionRole' , function ( ) {
11251127 describe ( 'restrictions' , function ( ) {
11261128 beforeEach ( 'set method and args' , function ( ) {
1129+ this . operationDelayTarget = this . other ;
11271130 const args = [ this . other . address , [ '0x12345678' ] , 443342 ] ;
11281131 const method = this . manager . interface . getFunction ( 'setTargetFunctionRole(address,bytes4[],uint64)' ) ;
11291132 this . calldata = this . manager . interface . encodeFunctionData ( method , args ) ;
@@ -1162,6 +1165,15 @@ describe('AccessManager', function () {
11621165 ) ;
11631166 }
11641167 } ) ;
1168+
1169+ it ( 'reverts setting a function role for the setAuthority selector' , async function ( ) {
1170+ const { selector } = this . target . interface . getFunction ( 'setAuthority' ) ;
1171+ await expect (
1172+ this . manager . connect ( this . admin ) . $_setTargetFunctionRole ( this . target , selector , this . roles . ADMIN . id ) ,
1173+ )
1174+ . to . be . revertedWithCustomError ( this . manager , 'AccessManagerLockedFunction' )
1175+ . withArgs ( selector ) ;
1176+ } ) ;
11651177 } ) ;
11661178
11671179 describe ( 'role admin operations' , function ( ) {
@@ -2240,6 +2252,41 @@ describe('AccessManager', function () {
22402252 . to . be . revertedWithCustomError ( this . manager , 'AccessManagerNotScheduled' )
22412253 . withArgs ( operationId ) ;
22422254 } ) ;
2255+
2256+ it ( 'can execute a setAuthority call when no target admin delay is set' , async function ( ) {
2257+ const newAuthority = await ethers . deployContract ( '$AccessManager' , [ this . admin ] ) ;
2258+
2259+ await expect ( this . manager . getTargetAdminDelay ( this . target ) ) . to . eventually . equal ( 0n ) ;
2260+
2261+ await expect (
2262+ this . manager
2263+ . connect ( this . admin )
2264+ . execute ( this . target , this . target . interface . encodeFunctionData ( 'setAuthority' , [ newAuthority . target ] ) ) ,
2265+ )
2266+ . to . emit ( this . target , 'AuthorityUpdated' )
2267+ . withArgs ( newAuthority ) ;
2268+ } ) ;
2269+
2270+ it ( 'cannot execute a setAuthority call when a target admin delay is set' , async function ( ) {
2271+ const newAuthority = await ethers . deployContract ( '$AccessManager' , [ this . admin ] ) ;
2272+
2273+ await this . manager . $_setTargetAdminDelay ( this . target , 10n ) ;
2274+ await time . increaseBy . timestamp ( 5n * 86400n , true ) ; // minSetBack is 5 days
2275+
2276+ await expect ( this . manager . getTargetAdminDelay ( this . target ) ) . to . eventually . equal ( 10n ) ;
2277+
2278+ // cannot update directly - there is a delay
2279+ await expect (
2280+ this . manager . connect ( this . admin ) . updateAuthority ( this . target , newAuthority ) ,
2281+ ) . to . be . revertedWithCustomError ( this . manager , 'AccessManagerNotScheduled' ) ;
2282+
2283+ // cannot bypass via execute either - targetAdminDelay is enforced for setAuthority
2284+ await expect (
2285+ this . manager
2286+ . connect ( this . admin )
2287+ . execute ( this . target , this . target . interface . encodeFunctionData ( 'setAuthority' , [ newAuthority . target ] ) ) ,
2288+ ) . to . be . revertedWithCustomError ( this . manager , 'AccessManagerNotScheduled' ) ;
2289+ } ) ;
22432290 } ) ;
22442291
22452292 describe ( '#consumeScheduledOp' , function ( ) {
0 commit comments