Skip to content

Commit e317c66

Browse files
committed
Fix tests error handling (avoid TX_OVERRIDES_BUG)
1 parent 7c41212 commit e317c66

3 files changed

Lines changed: 6 additions & 49 deletions

File tree

src/optimism/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
11
export * from '@chainlink/optimism-utils'
2-
3-
// TODO: Fix ERROR { "reason":"cannot estimate gas; transaction may fail or may require manual gas limit","code":"UNPREDICTABLE_GAS_LIMIT" }
4-
export const TX_OVERRIDES_BUG: any = {
5-
gasLimit: 8_999_999,
6-
}

test/helpers/index.ts

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ export const functionID = (fnSignature: string) => {
4343
* @param contract The contract with the actual abi to check the expected exposed methods and getters against.
4444
* @param expectedPublic The expected public exposed methods and getters to match against the actual abi.
4545
*/
46-
export function publicAbi(
47-
contract: ethers.Contract | ethers.ContractFactory,
48-
expectedPublic: string[],
49-
) {
46+
export function publicAbi(contract: ethers.Contract | ethers.ContractFactory, expectedPublic: string[]) {
5047
const actualPublic = []
5148
for (const method of contract.interface.fragments) {
5249
if (method.type === 'function') {
@@ -64,34 +61,3 @@ export function publicAbi(
6461
assert.isAtLeast(index, 0, `#${method} is expected to be public`)
6562
}
6663
}
67-
68-
/**
69-
* Check that an evm transaction fails
70-
*
71-
* @param action The asynchronous action to execute, which should cause an evm revert.
72-
*/
73-
export async function txRevert(action: (() => Promise<any>) | Promise<any>) {
74-
try {
75-
if (typeof action === 'function') {
76-
await action()
77-
} else {
78-
await action
79-
}
80-
} catch (e) {
81-
assert(e.message, 'Expected an error to contain a message')
82-
83-
const ERROR_MESSAGES = ['transaction failed']
84-
const hasErrored = ERROR_MESSAGES.some((msg) => e.message.includes(msg))
85-
86-
assert(
87-
hasErrored,
88-
`expected following error message to include ${ERROR_MESSAGES.join(' or ')}. Got: "${
89-
e.message
90-
}"`,
91-
)
92-
return
93-
}
94-
95-
const err = undefined
96-
assert.exists(err, 'Expected an error to be raised')
97-
}

test/v0.7/bridge/token/LinkTokenChild.test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,8 @@ describe(`LinkTokenChild ${Versions.v0_7}`, () => {
188188
})
189189

190190
it('can NOT mint without access (gateway role)', async () => {
191-
const mintTx = await l2Token.mint(oe.l2Wallet.address, 100, optimism.TX_OVERRIDES_BUG)
192-
// TODO: fetch revert reason
193-
// revert: 'No access'
194-
await h.txRevert(mintTx.wait())
191+
const mintTx = l2Token.mint(oe.l2Wallet.address, 100)
192+
await expect(mintTx).to.be.revertedWith('No access')
195193
})
196194

197195
it('owner can migrate to a new gateway', async () => {
@@ -201,7 +199,7 @@ describe(`LinkTokenChild ${Versions.v0_7}`, () => {
201199
const addAccessTx1 = await l2Token.addAccess(owner.address)
202200
await addAccessTx1.wait()
203201
// Mint some tokens as owner/gateway
204-
const mintTx1 = await l2Token.mint(owner.address, 100, optimism.TX_OVERRIDES_BUG)
202+
const mintTx1 = await l2Token.mint(owner.address, 100)
205203
await mintTx1.wait()
206204
// Assert state
207205
expect(await l2Token.balanceOf(owner.address)).to.be.equal(100)
@@ -219,10 +217,8 @@ describe(`LinkTokenChild ${Versions.v0_7}`, () => {
219217
const removeAccessTx = await l2Token.removeAccess(owner.address)
220218
await removeAccessTx.wait()
221219
// Owner mint fails
222-
const mintTx = await l2Token.mint(owner.address, 100, optimism.TX_OVERRIDES_BUG)
223-
// TODO: fetch revert reason
224-
// revert: 'No access'
225-
await h.txRevert(mintTx.wait())
220+
const mintTx = l2Token.mint(owner.address, 100)
221+
await expect(mintTx).to.be.revertedWith('No access')
226222
})
227223
})
228224
})

0 commit comments

Comments
 (0)