Skip to content

test: fix race condition in BridgeEscrow tests #730

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
merged 1 commit into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/gateway/bridgeEscrow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ describe('BridgeEscrow', () => {
describe('approveAll', function () {
it('cannot be called by someone other than the governor', async function () {
const tx = bridgeEscrow.connect(tokenReceiver.signer).approveAll(spender.address)
expect(tx).to.be.revertedWith('Caller must be Controller governor')
await expect(tx).revertedWith('Caller must be Controller governor')
})
it('allows a spender to transfer GRT held by the contract', async function () {
expect(await grt.allowance(bridgeEscrow.address, spender.address)).eq(0)
const tx = grt
.connect(spender.signer)
.transferFrom(bridgeEscrow.address, tokenReceiver.address, nTokens)
expect(tx).to.be.revertedWith('ERC20: transfer amount exceeds allowance')
await expect(tx).revertedWith('ERC20: transfer amount exceeds allowance')
await bridgeEscrow.connect(governor.signer).approveAll(spender.address)
expect(
await grt
await expect(
grt
.connect(spender.signer)
.transferFrom(bridgeEscrow.address, tokenReceiver.address, nTokens),
).to.emit(grt, 'Transfer')
Expand All @@ -62,7 +62,7 @@ describe('BridgeEscrow', () => {
describe('revokeAll', function () {
it('cannot be called by someone other than the governor', async function () {
const tx = bridgeEscrow.connect(tokenReceiver.signer).revokeAll(spender.address)
expect(tx).to.be.revertedWith('Caller must be Controller governor')
await expect(tx).revertedWith('Caller must be Controller governor')
})
it("revokes a spender's permission to transfer GRT held by the contract", async function () {
await bridgeEscrow.connect(governor.signer).approveAll(spender.address)
Expand All @@ -71,7 +71,7 @@ describe('BridgeEscrow', () => {
const tx = grt
.connect(spender.signer)
.transferFrom(bridgeEscrow.address, tokenReceiver.address, BigNumber.from('1'))
expect(tx).to.be.revertedWith('ERC20: transfer amount exceeds allowance')
await expect(tx).revertedWith('ERC20: transfer amount exceeds allowance')
})
})
})