Skip to content

Commit

Permalink
fix tests awaits
Browse files Browse the repository at this point in the history
  • Loading branch information
bulbozaur committed Feb 13, 2023
1 parent c7021c5 commit 4786bea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions test/0.4.24/lido.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ contract('Lido', ([appManager, , , , , , , , , , , , user1, user2, user3, nobody
})

it('reverts if lido locator address is ZERO', async () => {
assertRevert(app.finalizeUpgrade_v2(ZERO_ADDRESS, eip712StETH.address), 'LIDO_LOCATOR_ZERO_ADDRESS')
await assertRevert(app.finalizeUpgrade_v2(ZERO_ADDRESS, eip712StETH.address), 'LIDO_LOCATOR_ZERO_ADDRESS')
})

it('reverts if eip712StETH address is ZERO', async () => {
assertRevert(app.finalizeUpgrade_v2(lidoLocator.address, ZERO_ADDRESS), 'EIP712_STETH_ZERO_ADDRESS')
await assertRevert(app.finalizeUpgrade_v2(lidoLocator.address, ZERO_ADDRESS), 'EIP712_STETH_ZERO_ADDRESS')
})
})

Expand Down Expand Up @@ -435,14 +435,14 @@ contract('Lido', ([appManager, , , , , , , , , , , , user1, user2, user3, nobody
await app.setELRewardsWithdrawalLimit(initialValue, { from: voting })

// unable to receive execution layer rewards from arbitrary account
assertRevert(app.receiveELRewards({ from: user1, value: ETH(1) }), 'EXECUTION_LAYER_REAWARDS_VAULT_ONLY')
await assertRevert(app.receiveELRewards({ from: user1, value: ETH(1) }), 'EXECUTION_LAYER_REWARDS_VAULT_ONLY')
})
})
})

describe('receiveELRewards()', async () => {
it('unable to receive eth from arbitrary account', async () => {
assertRevert(app.receiveELRewards({ from: nobody, value: ETH(1) }), 'EXECUTION_LAYER_REAWARDS_VAULT_ONLY')
await assertRevert(app.receiveELRewards({ from: nobody, value: ETH(1) }), 'EXECUTION_LAYER_REWARDS_VAULT_ONLY')
})

it('event work', async () => {
Expand All @@ -461,7 +461,7 @@ contract('Lido', ([appManager, , , , , , , , , , , , user1, user2, user3, nobody

describe('receiveStakingRouterRemainder()', async () => {
it('unable to receive eth from arbitrary account', async () => {
assertRevert(app.receiveStakingRouterDepositRemainder({ from: nobody, value: ETH(1) }))
await assertRevert(app.receiveStakingRouterDepositRemainder({ from: nobody, value: ETH(1) }))
})

it('event work', async () => {
Expand Down
6 changes: 3 additions & 3 deletions test/0.4.24/staking-limit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ contract('StakingLimits', ([account1]) => {

maxStakeLimit = 5
maxStakeLimitGrowthBlocks = 6
assertRevert(limits.setStakingLimit(slot, maxStakeLimit, maxStakeLimitGrowthBlocks), 'TOO_LARGE_LIMIT_INCREASE')
await assertRevert(limits.setStakingLimit(slot, maxStakeLimit, maxStakeLimitGrowthBlocks), 'TOO_LARGE_LIMIT_INCREASE')
})

it('stake limit reverts on large values', async () => {
let maxStakeLimit = toBN(2).pow(toBN(96))
let maxStakeLimitIncreasePerBlock = 1
const slot = await limits.setStorageStakeLimitStruct(0, 0, 0, 0)
assertRevert(limits.setStakingLimit(slot, maxStakeLimit, maxStakeLimitIncreasePerBlock), 'TOO_LARGE_MAX_STAKE_LIMIT')
await assertRevert(limits.setStakingLimit(slot, maxStakeLimit, maxStakeLimitIncreasePerBlock), 'TOO_LARGE_MAX_STAKE_LIMIT')

maxStakeLimit = toBN(2).mul(toBN(10).pow(toBN(18)))
maxStakeLimitIncreasePerBlock = toBN(10)
assertRevert(limits.setStakingLimit(slot, maxStakeLimit, maxStakeLimitIncreasePerBlock), `TOO_SMALL_LIMIT_INCREASE`)
await assertRevert(limits.setStakingLimit(slot, maxStakeLimit, maxStakeLimitIncreasePerBlock), `TOO_SMALL_LIMIT_INCREASE`)
})

it('check update calculate stake limit with different blocks', async () => {
Expand Down
10 changes: 5 additions & 5 deletions test/0.8.9/lido-exec-layer-rewards-vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ contract('LidoExecutionLayerRewardsVault', ([deployer, anotherAccount]) => {
})

it(`can't recover zero ERC20 amount`, async () => {
assertRevert(elRewardsVault.recoverERC20(mockERC20Token.address, bn(0)), `ZERO_RECOVERY_AMOUNT`)
await assertRevert(elRewardsVault.recoverERC20(mockERC20Token.address, bn(0)), `ZERO_RECOVERY_AMOUNT`)
})

it(`can't recover zero-address ERC20`, async () => {
assertRevert(elRewardsVault.recoverERC20(ZERO_ADDRESS, bn(10)))
await assertRevert(elRewardsVault.recoverERC20(ZERO_ADDRESS, bn(10)))
})

it(`can't recover stETH by recoverERC20`, async () => {
Expand Down Expand Up @@ -138,11 +138,11 @@ contract('LidoExecutionLayerRewardsVault', ([deployer, anotherAccount]) => {
})

// balance is zero already, have to be reverted
assertRevert(elRewardsVault.recoverERC20(mockERC20Token.address, bn(1), { from: deployer }), `ERC20: transfer amount exceeds balance`)
await assertRevert(elRewardsVault.recoverERC20(mockERC20Token.address, bn(1), { from: deployer }), `ERC20: transfer amount exceeds balance`)
})

it(`can't recover zero-address ERC721(NFT)`, async () => {
assertRevert(elRewardsVault.recoverERC721(ZERO_ADDRESS, 0))
await assertRevert(elRewardsVault.recoverERC721(ZERO_ADDRESS, 0))
})

it(`recover some accidentally sent NFTs`, async () => {
Expand All @@ -160,7 +160,7 @@ contract('LidoExecutionLayerRewardsVault', ([deployer, anotherAccount]) => {
assertEvent(receiptNfc2, `ERC721Recovered`, { expectedArgs: { requestedBy: anotherAccount, token: mockNFT.address, tokenId: nft2 } })

// but nft1 recovery should revert
assertRevert(elRewardsVault.recoverERC721(mockNFT.address, nft1), `ERC721: transfer caller is not owner nor approved`)
await assertRevert(elRewardsVault.recoverERC721(mockNFT.address, nft1), `ERC721: transfer caller is not owner nor approved`)

// send nft1 to elRewardsVault and recover it
await mockNFT.transferFrom(anotherAccount, elRewardsVault.address, nft1, { from: anotherAccount })
Expand Down

0 comments on commit 4786bea

Please sign in to comment.