|
1 | 1 | import { expect } from 'chai' |
2 | 2 | import hre from 'hardhat' |
3 | 3 | import GraphChain from '../../../../gre/helpers/network' |
| 4 | +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' |
4 | 5 |
|
5 | 6 | describe('[L1] L1GraphTokenGateway configuration', function () { |
6 | 7 | const graph = hre.graph() |
7 | 8 | const { Controller, L1GraphTokenGateway } = graph.contracts |
8 | 9 |
|
| 10 | + let unauthorized: SignerWithAddress |
9 | 11 | before(async function () { |
10 | 12 | if (GraphChain.isL2(graph.chainId)) this.skip() |
| 13 | + unauthorized = (await graph.getTestAccounts())[0] |
| 14 | + }) |
| 15 | + |
| 16 | + it('bridge should be unpaused', async function () { |
| 17 | + const paused = await L1GraphTokenGateway.paused() |
| 18 | + expect(paused).eq(false) |
11 | 19 | }) |
12 | 20 |
|
13 | 21 | it('should be controlled by Controller', async function () { |
14 | 22 | const controller = await L1GraphTokenGateway.controller() |
15 | 23 | expect(controller).eq(Controller.address) |
16 | 24 | }) |
| 25 | + |
| 26 | + describe('calls with unauthorized user', () => { |
| 27 | + it('initialize should revert', async function () { |
| 28 | + const tx = L1GraphTokenGateway.connect(unauthorized).initialize(unauthorized.address) |
| 29 | + await expect(tx).revertedWith('Caller must be the implementation') |
| 30 | + }) |
| 31 | + |
| 32 | + it('setArbitrumAddresses should revert', async function () { |
| 33 | + const tx = L1GraphTokenGateway.connect(unauthorized).setArbitrumAddresses( |
| 34 | + unauthorized.address, |
| 35 | + unauthorized.address, |
| 36 | + ) |
| 37 | + await expect(tx).revertedWith('Caller must be Controller governor') |
| 38 | + }) |
| 39 | + |
| 40 | + it('setL2TokenAddress should revert', async function () { |
| 41 | + const tx = L1GraphTokenGateway.connect(unauthorized).setL2TokenAddress(unauthorized.address) |
| 42 | + await expect(tx).revertedWith('Caller must be Controller governor') |
| 43 | + }) |
| 44 | + |
| 45 | + it('setL2CounterpartAddress should revert', async function () { |
| 46 | + const tx = L1GraphTokenGateway.connect(unauthorized).setL2CounterpartAddress( |
| 47 | + unauthorized.address, |
| 48 | + ) |
| 49 | + await expect(tx).revertedWith('Caller must be Controller governor') |
| 50 | + }) |
| 51 | + |
| 52 | + it('setEscrowAddress should revert', async function () { |
| 53 | + const tx = L1GraphTokenGateway.connect(unauthorized).setEscrowAddress(unauthorized.address) |
| 54 | + await expect(tx).revertedWith('Caller must be Controller governor') |
| 55 | + }) |
| 56 | + |
| 57 | + it('addToCallhookWhitelist should revert', async function () { |
| 58 | + const tx = L1GraphTokenGateway.connect(unauthorized).addToCallhookWhitelist( |
| 59 | + unauthorized.address, |
| 60 | + ) |
| 61 | + await expect(tx).revertedWith('Caller must be Controller governor') |
| 62 | + }) |
| 63 | + |
| 64 | + it('removeFromCallhookWhitelist should revert', async function () { |
| 65 | + const tx = L1GraphTokenGateway.connect(unauthorized).removeFromCallhookWhitelist( |
| 66 | + unauthorized.address, |
| 67 | + ) |
| 68 | + await expect(tx).revertedWith('Caller must be Controller governor') |
| 69 | + }) |
| 70 | + |
| 71 | + it('finalizeInboundTransfer should revert', async function () { |
| 72 | + const tx = L1GraphTokenGateway.connect(unauthorized).finalizeInboundTransfer( |
| 73 | + unauthorized.address, |
| 74 | + unauthorized.address, |
| 75 | + unauthorized.address, |
| 76 | + '100', |
| 77 | + '0x00', |
| 78 | + ) |
| 79 | + |
| 80 | + await expect(tx).revertedWith('ONLY_COUNTERPART_GATEWAY') |
| 81 | + }) |
| 82 | + }) |
17 | 83 | }) |
0 commit comments