@@ -16,6 +16,7 @@ import {
16
16
toGRT ,
17
17
Account ,
18
18
applyL1ToL2Alias ,
19
+ provider ,
19
20
} from '../lib/testHelpers'
20
21
import { BridgeEscrow } from '../../build/types/BridgeEscrow'
21
22
@@ -61,6 +62,8 @@ describe('L1GraphTokenGateway', () => {
61
62
; [ governor , tokenSender , l2Receiver , mockRouter , mockL2GRT , mockL2Gateway , pauseGuardian ] =
62
63
await getAccounts ( )
63
64
65
+ // Dummy code on the mock router so that it appears as a contract
66
+ await provider ( ) . send ( 'hardhat_setCode' , [ mockRouter . address , '0x1234' ] )
64
67
fixture = new NetworkFixture ( )
65
68
fixtureContracts = await fixture . load ( governor . signer )
66
69
; ( { grt, l1GraphTokenGateway, bridgeEscrow } = fixtureContracts )
@@ -128,6 +131,16 @@ describe('L1GraphTokenGateway', () => {
128
131
. setArbitrumAddresses ( inboxMock . address , mockRouter . address )
129
132
await expect ( tx ) . revertedWith ( 'Caller must be Controller governor' )
130
133
} )
134
+ it ( 'rejects setting an EOA as router or inbox' , async function ( ) {
135
+ let tx = l1GraphTokenGateway
136
+ . connect ( governor . signer )
137
+ . setArbitrumAddresses ( tokenSender . address , mockRouter . address )
138
+ await expect ( tx ) . revertedWith ( 'INBOX_MUST_BE_CONTRACT' )
139
+ tx = l1GraphTokenGateway
140
+ . connect ( governor . signer )
141
+ . setArbitrumAddresses ( inboxMock . address , tokenSender . address )
142
+ await expect ( tx ) . revertedWith ( 'ROUTER_MUST_BE_CONTRACT' )
143
+ } )
131
144
it ( 'sets inbox and router address' , async function ( ) {
132
145
const tx = l1GraphTokenGateway
133
146
. connect ( governor . signer )
@@ -192,42 +205,56 @@ describe('L1GraphTokenGateway', () => {
192
205
it ( 'is not callable by addreses that are not the governor' , async function ( ) {
193
206
const tx = l1GraphTokenGateway
194
207
. connect ( tokenSender . signer )
195
- . addToCallhookWhitelist ( tokenSender . address )
208
+ . addToCallhookWhitelist ( fixtureContracts . rewardsManager . address )
196
209
await expect ( tx ) . revertedWith ( 'Caller must be Controller governor' )
197
- expect ( await l1GraphTokenGateway . callhookWhitelist ( tokenSender . address ) ) . eq ( false )
210
+ expect (
211
+ await l1GraphTokenGateway . callhookWhitelist ( fixtureContracts . rewardsManager . address ) ,
212
+ ) . eq ( false )
198
213
} )
199
- it ( 'adds an address to the callhook whitelist' , async function ( ) {
214
+ it ( 'rejects adding an EOA to the callhook whitelist' , async function ( ) {
200
215
const tx = l1GraphTokenGateway
201
216
. connect ( governor . signer )
202
217
. addToCallhookWhitelist ( tokenSender . address )
218
+ await expect ( tx ) . revertedWith ( 'MUST_BE_CONTRACT' )
219
+ } )
220
+ it ( 'adds an address to the callhook whitelist' , async function ( ) {
221
+ const tx = l1GraphTokenGateway
222
+ . connect ( governor . signer )
223
+ . addToCallhookWhitelist ( fixtureContracts . rewardsManager . address )
203
224
await expect ( tx )
204
225
. emit ( l1GraphTokenGateway , 'AddedToCallhookWhitelist' )
205
- . withArgs ( tokenSender . address )
206
- expect ( await l1GraphTokenGateway . callhookWhitelist ( tokenSender . address ) ) . eq ( true )
226
+ . withArgs ( fixtureContracts . rewardsManager . address )
227
+ expect (
228
+ await l1GraphTokenGateway . callhookWhitelist ( fixtureContracts . rewardsManager . address ) ,
229
+ ) . eq ( true )
207
230
} )
208
231
} )
209
232
describe ( 'removeFromCallhookWhitelist' , function ( ) {
210
233
it ( 'is not callable by addreses that are not the governor' , async function ( ) {
211
234
await l1GraphTokenGateway
212
235
. connect ( governor . signer )
213
- . addToCallhookWhitelist ( tokenSender . address )
236
+ . addToCallhookWhitelist ( fixtureContracts . rewardsManager . address )
214
237
const tx = l1GraphTokenGateway
215
238
. connect ( tokenSender . signer )
216
- . removeFromCallhookWhitelist ( tokenSender . address )
239
+ . removeFromCallhookWhitelist ( fixtureContracts . rewardsManager . address )
217
240
await expect ( tx ) . revertedWith ( 'Caller must be Controller governor' )
218
- expect ( await l1GraphTokenGateway . callhookWhitelist ( tokenSender . address ) ) . eq ( true )
241
+ expect (
242
+ await l1GraphTokenGateway . callhookWhitelist ( fixtureContracts . rewardsManager . address ) ,
243
+ ) . eq ( true )
219
244
} )
220
245
it ( 'removes an address from the callhook whitelist' , async function ( ) {
221
246
await l1GraphTokenGateway
222
247
. connect ( governor . signer )
223
- . addToCallhookWhitelist ( tokenSender . address )
248
+ . addToCallhookWhitelist ( fixtureContracts . rewardsManager . address )
224
249
const tx = l1GraphTokenGateway
225
250
. connect ( governor . signer )
226
- . removeFromCallhookWhitelist ( tokenSender . address )
251
+ . removeFromCallhookWhitelist ( fixtureContracts . rewardsManager . address )
227
252
await expect ( tx )
228
253
. emit ( l1GraphTokenGateway , 'RemovedFromCallhookWhitelist' )
229
- . withArgs ( tokenSender . address )
230
- expect ( await l1GraphTokenGateway . callhookWhitelist ( tokenSender . address ) ) . eq ( false )
254
+ . withArgs ( fixtureContracts . rewardsManager . address )
255
+ expect (
256
+ await l1GraphTokenGateway . callhookWhitelist ( fixtureContracts . rewardsManager . address ) ,
257
+ ) . eq ( false )
231
258
} )
232
259
} )
233
260
describe ( 'Pausable behavior' , ( ) => {
@@ -479,6 +506,8 @@ describe('L1GraphTokenGateway', () => {
479
506
await expect ( tx ) . revertedWith ( 'CALL_HOOK_DATA_NOT_ALLOWED' )
480
507
} )
481
508
it ( 'allows sending nonempty calldata, if the sender is whitelisted' , async function ( ) {
509
+ // Make the sender a contract so that it can be allowed to send callhooks
510
+ await provider ( ) . send ( 'hardhat_setCode' , [ tokenSender . address , '0x1234' ] )
482
511
await l1GraphTokenGateway
483
512
. connect ( governor . signer )
484
513
. addToCallhookWhitelist ( tokenSender . address )
0 commit comments