@@ -14,6 +14,7 @@ use(smock.matchers)
14
14
import { getAccounts , toGRT , Account , toBN , getL2SignerFromL1 } from '../lib/testHelpers'
15
15
import { Interface } from 'ethers/lib/utils'
16
16
import { deployContract } from '../lib/deployment'
17
+ import { RewardsManager } from '../../build/types/RewardsManager'
17
18
18
19
const { AddressZero } = constants
19
20
@@ -34,6 +35,7 @@ describe('L2GraphTokenGateway', () => {
34
35
let grt : L2GraphToken
35
36
let l2GraphTokenGateway : L2GraphTokenGateway
36
37
let callhookReceiverMock : CallhookReceiverMock
38
+ let rewardsManager : RewardsManager
37
39
38
40
const senderTokens = toGRT ( '1000' )
39
41
const defaultData = '0x'
@@ -61,7 +63,7 @@ describe('L2GraphTokenGateway', () => {
61
63
62
64
fixture = new NetworkFixture ( )
63
65
fixtureContracts = await fixture . loadL2 ( governor . signer )
64
- ; ( { grt, l2GraphTokenGateway } = fixtureContracts )
66
+ ; ( { grt, l2GraphTokenGateway, rewardsManager } = fixtureContracts )
65
67
66
68
callhookReceiverMock = ( await deployContract (
67
69
'CallhookReceiverMock' ,
@@ -408,6 +410,28 @@ describe('L2GraphTokenGateway', () => {
408
410
)
409
411
await expect ( tx ) . revertedWith ( 'FOO_IS_ZERO' )
410
412
} )
413
+ it ( 'reverts if trying to call a callhook in a contract that does not implement onTokenTransfer' , async function ( ) {
414
+ const callHookData = utils . defaultAbiCoder . encode ( [ 'uint256' ] , [ toBN ( '0' ) ] )
415
+ const data = utils . defaultAbiCoder . encode ( [ 'bytes' , 'bytes' ] , [ '0x' , callHookData ] )
416
+ const mockL1GatewayL2Alias = await getL2SignerFromL1 ( mockL1Gateway . address )
417
+ await me . signer . sendTransaction ( {
418
+ to : await mockL1GatewayL2Alias . getAddress ( ) ,
419
+ value : utils . parseUnits ( '1' , 'ether' ) ,
420
+ } )
421
+ // RewardsManager does not implement onTokenTransfer, so this will fail
422
+ const tx = l2GraphTokenGateway
423
+ . connect ( mockL1GatewayL2Alias )
424
+ . finalizeInboundTransfer (
425
+ mockL1GRT . address ,
426
+ tokenSender . address ,
427
+ rewardsManager . address ,
428
+ toGRT ( '10' ) ,
429
+ data ,
430
+ )
431
+ await expect ( tx ) . revertedWith (
432
+ "function selector was not recognized and there's no fallback function" ,
433
+ )
434
+ } )
411
435
} )
412
436
} )
413
437
} )
0 commit comments