-
Notifications
You must be signed in to change notification settings - Fork 3.9k
increase coverage of contracts package #2209
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
Merged
mslipper
merged 1 commit into
ethereum-optimism:develop
from
tonykogias:increase-codecov-contracts-package
Mar 3, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/contracts/test/contracts/L1/deployment/AddressDictator.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* External Imports */ | ||
| import { ethers } from 'hardhat' | ||
| import { Contract, Signer, ContractFactory } from 'ethers' | ||
|
|
||
| /* Internal Imports */ | ||
| import { expect } from '../../../setup' | ||
| import { NON_ZERO_ADDRESS } from '../../../helpers' | ||
|
|
||
| describe('AddressDictator', () => { | ||
| let signer: Signer | ||
| let otherSigner: Signer | ||
| let signerAddress: string | ||
| let Factory__AddressDictator: ContractFactory | ||
| let Factory__Lib_AddressManager: ContractFactory | ||
| before(async () => { | ||
| ;[signer, otherSigner] = await ethers.getSigners() | ||
|
|
||
| Factory__AddressDictator = await ethers.getContractFactory( | ||
| 'AddressDictator' | ||
| ) | ||
|
|
||
| Factory__Lib_AddressManager = await ethers.getContractFactory( | ||
| 'Lib_AddressManager' | ||
| ) | ||
|
|
||
| signerAddress = await signer.getAddress() | ||
| }) | ||
|
|
||
| let AddressDictator: Contract | ||
| let Lib_AddressManager: Contract | ||
| beforeEach(async () => { | ||
| Lib_AddressManager = await Factory__Lib_AddressManager.connect( | ||
| signer | ||
| ).deploy() | ||
|
|
||
| AddressDictator = await Factory__AddressDictator.connect(signer).deploy( | ||
| Lib_AddressManager.address, | ||
| signerAddress, | ||
| ['addr1'], | ||
| [NON_ZERO_ADDRESS] | ||
| ) | ||
|
|
||
| Lib_AddressManager.transferOwnership(AddressDictator.address) | ||
| }) | ||
|
|
||
| describe('initialize', () => { | ||
| it('should revert when providing wrong arguments', async () => { | ||
| await expect( | ||
| Factory__AddressDictator.connect(signer).deploy( | ||
| Lib_AddressManager.address, | ||
| signerAddress, | ||
| ['addr1', 'addr2'], | ||
| [NON_ZERO_ADDRESS] | ||
| ) | ||
| ).to.be.revertedWith( | ||
| 'AddressDictator: Must provide an equal number of names and addresses.' | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| describe('setAddresses', async () => { | ||
| it('should change the addresses associated with a name', async () => { | ||
| await AddressDictator.setAddresses() | ||
| expect(await Lib_AddressManager.getAddress('addr1')).to.be.equal( | ||
| NON_ZERO_ADDRESS | ||
| ) | ||
| }) | ||
| }) | ||
|
|
||
| describe('getNamedAddresses', () => { | ||
| it('should return all the addresses and their names', async () => { | ||
| expect(await AddressDictator.getNamedAddresses()).to.be.deep.equal([ | ||
| ['addr1', NON_ZERO_ADDRESS], | ||
| ]) | ||
| }) | ||
| }) | ||
|
|
||
| describe('returnOwnership', () => { | ||
| it('should transfer contract ownership to finalOwner', async () => { | ||
| await expect(AddressDictator.connect(signer).returnOwnership()).to.not.be | ||
| .reverted | ||
| }) | ||
|
|
||
| it('should revert when called by non-owner', async () => { | ||
| await expect( | ||
| AddressDictator.connect(otherSigner).returnOwnership() | ||
| ).to.be.revertedWith('AddressDictator: only callable by finalOwner') | ||
| }) | ||
| }) | ||
| }) |
76 changes: 76 additions & 0 deletions
76
packages/contracts/test/contracts/L1/deployment/ChugSplashDictator.spec..ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* External Imports */ | ||
| import { ethers } from 'hardhat' | ||
| import { Contract, Signer, ContractFactory } from 'ethers' | ||
|
|
||
| /* Internal Imports */ | ||
| import { expect } from '../../../setup' | ||
|
|
||
| describe('ChugSplashDictator', () => { | ||
| let signer: Signer | ||
| let otherSigner: Signer | ||
| let signerAddress: string | ||
|
|
||
| let Factory__L1ChugSplashProxy: ContractFactory | ||
| let Factory__ChugSplashDictator: ContractFactory | ||
| before(async () => { | ||
| ;[signer, otherSigner] = await ethers.getSigners() | ||
|
|
||
| Factory__L1ChugSplashProxy = await ethers.getContractFactory( | ||
| 'L1ChugSplashProxy' | ||
| ) | ||
|
|
||
| Factory__ChugSplashDictator = await ethers.getContractFactory( | ||
| 'ChugSplashDictator' | ||
| ) | ||
|
|
||
| signerAddress = await signer.getAddress() | ||
| }) | ||
|
|
||
| let L1ChugSplashProxy: Contract | ||
| let ChugSplashDictator: Contract | ||
| beforeEach(async () => { | ||
| L1ChugSplashProxy = await Factory__L1ChugSplashProxy.connect(signer).deploy( | ||
| signerAddress | ||
| ) | ||
|
|
||
| ChugSplashDictator = await Factory__ChugSplashDictator.connect( | ||
| signer | ||
| ).deploy( | ||
| L1ChugSplashProxy.address, | ||
| signerAddress, | ||
| ethers.utils.keccak256('0x1111'), | ||
| ethers.utils.keccak256('0x1234'), | ||
| ethers.utils.keccak256('0x5678'), | ||
| ethers.utils.keccak256('0x1234'), | ||
| ethers.utils.keccak256('0x1234') | ||
| ) | ||
|
|
||
| await L1ChugSplashProxy.connect(signer).setOwner(ChugSplashDictator.address) | ||
| }) | ||
|
|
||
| describe('doActions', () => { | ||
| it('should revert when sent wrong code', async () => { | ||
| await expect(ChugSplashDictator.doActions('0x2222')).to.be.revertedWith( | ||
| 'ChugSplashDictator: Incorrect code hash.' | ||
| ) | ||
| }) | ||
|
|
||
| it('should set the proxy code, storage & owner', async () => { | ||
| await expect(ChugSplashDictator.connect(signer).doActions('0x1111')).to | ||
| .not.be.reverted | ||
| }) | ||
| }) | ||
|
|
||
| describe('returnOwnership', () => { | ||
| it('should transfer contractc ownership to finalOwner', async () => { | ||
| await expect(ChugSplashDictator.connect(signer).returnOwnership()).to.not | ||
| .be.reverted | ||
| }) | ||
|
|
||
| it('should revert when called by non-owner', async () => { | ||
| await expect( | ||
| ChugSplashDictator.connect(otherSigner).returnOwnership() | ||
| ).to.be.revertedWith('ChugSplashDictator: only callable by finalOwner') | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.