Skip to content

Commit d8d009b

Browse files
committed
test(L1GraphTokenGateway): remove redundant awaits and combine two event assertions
1 parent fb6b277 commit d8d009b

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

test/gateway/l1GraphTokenGateway.test.ts

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ describe('L1GraphTokenGateway', () => {
241241
it('can be paused and unpaused by the governor', async function () {
242242
let tx = l1GraphTokenGateway.connect(governor.signer).setPaused(false)
243243
await expect(tx).emit(l1GraphTokenGateway, 'PauseChanged').withArgs(false)
244-
await expect(await l1GraphTokenGateway.paused()).eq(false)
244+
expect(await l1GraphTokenGateway.paused()).eq(false)
245245
tx = l1GraphTokenGateway.connect(governor.signer).setPaused(true)
246246
await expect(tx).emit(l1GraphTokenGateway, 'PauseChanged').withArgs(true)
247-
await expect(await l1GraphTokenGateway.paused()).eq(true)
247+
expect(await l1GraphTokenGateway.paused()).eq(true)
248248
})
249249
describe('setPauseGuardian', function () {
250250
it('cannot be called by someone other than governor', async function () {
@@ -265,10 +265,10 @@ describe('L1GraphTokenGateway', () => {
265265
await l1GraphTokenGateway.connect(governor.signer).setPauseGuardian(pauseGuardian.address)
266266
let tx = l1GraphTokenGateway.connect(pauseGuardian.signer).setPaused(false)
267267
await expect(tx).emit(l1GraphTokenGateway, 'PauseChanged').withArgs(false)
268-
await expect(await l1GraphTokenGateway.paused()).eq(false)
268+
expect(await l1GraphTokenGateway.paused()).eq(false)
269269
tx = l1GraphTokenGateway.connect(pauseGuardian.signer).setPaused(true)
270270
await expect(tx).emit(l1GraphTokenGateway, 'PauseChanged').withArgs(true)
271-
await expect(await l1GraphTokenGateway.paused()).eq(true)
271+
expect(await l1GraphTokenGateway.paused()).eq(true)
272272
})
273273
})
274274
})
@@ -361,8 +361,8 @@ describe('L1GraphTokenGateway', () => {
361361
)
362362
const escrowBalance = await grt.balanceOf(bridgeEscrow.address)
363363
const senderBalance = await grt.balanceOf(tokenSender.address)
364-
await expect(escrowBalance).eq(toGRT('10'))
365-
await expect(senderBalance).eq(toGRT('990'))
364+
expect(escrowBalance).eq(toGRT('10'))
365+
expect(senderBalance).eq(toGRT('990'))
366366
}
367367
before(async function () {
368368
await fixture.configureL1Bridge(
@@ -431,12 +431,12 @@ describe('L1GraphTokenGateway', () => {
431431
.emit(l1GraphTokenGateway, 'L2MintAllowanceUpdated')
432432
.withArgs(toGRT('0'), issuancePerBlock, issuanceUpdatedAtBlock)
433433
// Now the mint allowance should be issuancePerBlock * 3
434-
await expect(
434+
expect(
435435
await l1GraphTokenGateway.accumulatedL2MintAllowanceAtBlock(await latestBlock()),
436436
).to.eq(issuancePerBlock.mul(3))
437-
await expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(0)
438-
await expect(await l1GraphTokenGateway.l2MintAllowancePerBlock()).to.eq(issuancePerBlock)
439-
await expect(await l1GraphTokenGateway.lastL2MintAllowanceUpdateBlock()).to.eq(
437+
expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(0)
438+
expect(await l1GraphTokenGateway.l2MintAllowancePerBlock()).to.eq(issuancePerBlock)
439+
expect(await l1GraphTokenGateway.lastL2MintAllowanceUpdateBlock()).to.eq(
440440
issuanceUpdatedAtBlock,
441441
)
442442

@@ -455,14 +455,14 @@ describe('L1GraphTokenGateway', () => {
455455
.emit(l1GraphTokenGateway, 'L2MintAllowanceUpdated')
456456
.withArgs(expectedAccumulatedSnapshot, newIssuancePerBlock, newIssuanceUpdatedAtBlock)
457457

458-
await expect(
458+
expect(
459459
await l1GraphTokenGateway.accumulatedL2MintAllowanceAtBlock(await latestBlock()),
460460
).to.eq(expectedAccumulatedSnapshot.add(newIssuancePerBlock.mul(2)))
461-
await expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(
461+
expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(
462462
expectedAccumulatedSnapshot,
463463
)
464-
await expect(await l1GraphTokenGateway.l2MintAllowancePerBlock()).to.eq(newIssuancePerBlock)
465-
await expect(await l1GraphTokenGateway.lastL2MintAllowanceUpdateBlock()).to.eq(
464+
expect(await l1GraphTokenGateway.l2MintAllowancePerBlock()).to.eq(newIssuancePerBlock)
465+
expect(await l1GraphTokenGateway.lastL2MintAllowanceUpdateBlock()).to.eq(
466466
newIssuanceUpdatedAtBlock,
467467
)
468468
})
@@ -504,14 +504,12 @@ describe('L1GraphTokenGateway', () => {
504504
.emit(l1GraphTokenGateway, 'L2MintAllowanceUpdated')
505505
.withArgs(snapshotValue, issuancePerBlock, issuanceUpdatedAtBlock)
506506
// Now the mint allowance should be 10 + issuancePerBlock * 3
507-
await expect(
507+
expect(
508508
await l1GraphTokenGateway.accumulatedL2MintAllowanceAtBlock(await latestBlock()),
509509
).to.eq(snapshotValue.add(issuancePerBlock.mul(3)))
510-
await expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(
511-
snapshotValue,
512-
)
513-
await expect(await l1GraphTokenGateway.l2MintAllowancePerBlock()).to.eq(issuancePerBlock)
514-
await expect(await l1GraphTokenGateway.lastL2MintAllowanceUpdateBlock()).to.eq(
510+
expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(snapshotValue)
511+
expect(await l1GraphTokenGateway.l2MintAllowancePerBlock()).to.eq(issuancePerBlock)
512+
expect(await l1GraphTokenGateway.lastL2MintAllowanceUpdateBlock()).to.eq(
515513
issuanceUpdatedAtBlock,
516514
)
517515

@@ -532,14 +530,14 @@ describe('L1GraphTokenGateway', () => {
532530
.emit(l1GraphTokenGateway, 'L2MintAllowanceUpdated')
533531
.withArgs(newSnapshotValue, newIssuancePerBlock, newIssuanceUpdatedAtBlock)
534532

535-
await expect(
533+
expect(
536534
await l1GraphTokenGateway.accumulatedL2MintAllowanceAtBlock(await latestBlock()),
537535
).to.eq(newSnapshotValue.add(newIssuancePerBlock.mul(2)))
538-
await expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(
536+
expect(await l1GraphTokenGateway.accumulatedL2MintAllowanceSnapshot()).to.eq(
539537
newSnapshotValue,
540538
)
541-
await expect(await l1GraphTokenGateway.l2MintAllowancePerBlock()).to.eq(newIssuancePerBlock)
542-
await expect(await l1GraphTokenGateway.lastL2MintAllowanceUpdateBlock()).to.eq(
539+
expect(await l1GraphTokenGateway.l2MintAllowancePerBlock()).to.eq(newIssuancePerBlock)
540+
expect(await l1GraphTokenGateway.lastL2MintAllowanceUpdateBlock()).to.eq(
543541
newIssuanceUpdatedAtBlock,
544542
)
545543
})
@@ -792,8 +790,8 @@ describe('L1GraphTokenGateway', () => {
792790
.withArgs(grt.address, l2Receiver.address, tokenSender.address, toBN('0'), toGRT('8'))
793791
const escrowBalance = await grt.balanceOf(bridgeEscrow.address)
794792
const senderBalance = await grt.balanceOf(tokenSender.address)
795-
await expect(escrowBalance).eq(toGRT('2'))
796-
await expect(senderBalance).eq(toGRT('998'))
793+
expect(escrowBalance).eq(toGRT('2'))
794+
expect(senderBalance).eq(toGRT('998'))
797795
})
798796
it('mints tokens up to the L2 mint allowance', async function () {
799797
await grt.connect(tokenSender.signer).approve(l1GraphTokenGateway.address, toGRT('10'))
@@ -838,16 +836,17 @@ describe('L1GraphTokenGateway', () => {
838836
await expect(tx)
839837
.emit(l1GraphTokenGateway, 'WithdrawalFinalized')
840838
.withArgs(grt.address, l2Receiver.address, tokenSender.address, toBN('0'), toGRT('18'))
841-
await expect(tx).emit(l1GraphTokenGateway, 'TokensMintedFromL2').withArgs(toGRT('8'))
842-
await expect(await l1GraphTokenGateway.totalMintedFromL2()).to.eq(toGRT('8'))
843-
await expect(
839+
.emit(l1GraphTokenGateway, 'TokensMintedFromL2')
840+
.withArgs(toGRT('8'))
841+
expect(await l1GraphTokenGateway.totalMintedFromL2()).to.eq(toGRT('8'))
842+
expect(
844843
await l1GraphTokenGateway.accumulatedL2MintAllowanceAtBlock(await latestBlock()),
845844
).to.eq(toGRT('8'))
846845

847846
const escrowBalance = await grt.balanceOf(bridgeEscrow.address)
848847
const senderBalance = await grt.balanceOf(tokenSender.address)
849-
await expect(escrowBalance).eq(toGRT('0'))
850-
await expect(senderBalance).eq(toGRT('1008'))
848+
expect(escrowBalance).eq(toGRT('0'))
849+
expect(senderBalance).eq(toGRT('1008'))
851850
})
852851
it('reverts if the amount to mint is over the allowance', async function () {
853852
await grt.connect(tokenSender.signer).approve(l1GraphTokenGateway.address, toGRT('10'))

0 commit comments

Comments
 (0)