Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bulbozaur committed Feb 13, 2023
1 parent 89ad4cc commit 69da980
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 48 deletions.
6 changes: 3 additions & 3 deletions test/0.4.24/helpers/dao.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ class AragonDAO {

async createPermission(entityAddress, app, permissionName) {
const permission = await app[permissionName]()
return this.acl.createPermission(entityAddress, app.address, permission, this.appManager, {
return await this.acl.createPermission(entityAddress, app.address, permission, this.appManager, {
from: this.appManager
})
}

async grantPermission(entityAddress, app, permissionName) {
const permission = await app[permissionName]()
return this.acl.grantPermission(entityAddress, app.address, permission, { from: this.appManager })
return await this.acl.grantPermission(entityAddress, app.address, permission, { from: this.appManager })
}

async hasPermission(entity, app, permissionName) {
const permission = await app[permissionName]()
return this.acl.hasPermission(entity, app.address, permission)
return await this.acl.hasPermission(entity, app.address, permission)
}
}

Expand Down
7 changes: 3 additions & 4 deletions test/0.4.24/lido.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,6 @@ contract('Lido', ([appManager, , , , , , , , , , , , user1, user2, user3, nobody
expectedIsStakingPaused,
expectedIsStakingLimited
) => {
assert((await app.isStakingPaused()) === false)
currentStakeLimit = await app.getCurrentStakeLimit()
assertBn(currentStakeLimit, expectedCurrentStakeLimit)

Expand Down Expand Up @@ -771,7 +770,7 @@ contract('Lido', ([appManager, , , , , , , , , , , , user1, user2, user3, nobody
await assertRevert(app.pauseStaking(), 'APP_AUTH_FAILED')
receipt = await app.pauseStaking({ from: voting })
assertEvent(receipt, 'StakingPaused')
verifyStakeLimitState(bn(0), bn(0), bn(0), true, false)
await verifyStakeLimitState(bn(0), bn(0), bn(0), true, false)

await assertRevert(web3.eth.sendTransaction({ to: app.address, from: user2, value: ETH(2) }), `STAKING_PAUSED`)
await assertRevert(app.submit(ZERO_ADDRESS, { from: user2, value: ETH(2) }), `STAKING_PAUSED`)
Expand Down Expand Up @@ -1368,7 +1367,7 @@ contract('Lido', ([appManager, , , , , , , , , , , , user1, user2, user3, nobody

// Adding a key & setting staking limit will help
await operators.addSigningKeys(0, 1, pad('0x0003', 48), pad('0x01', 96), { from: voting })
operators.setNodeOperatorStakingLimit(0, 3, { from: voting })
await operators.setNodeOperatorStakingLimit(0, 3, { from: voting })

await web3.eth.sendTransaction({ to: app.address, from: user3, value: ETH(1) })
await app.methods['deposit(uint256,uint256,bytes)'](MAX_DEPOSITS, CURATED_MODULE_ID, CALLDATA, { from: depositor })
Expand Down Expand Up @@ -1494,7 +1493,7 @@ contract('Lido', ([appManager, , , , , , , , , , , , user1, user2, user3, nobody

// Adding a key & setting staking limit will help
await operators.addSigningKeys(0, 1, pad('0x0003', 48), pad('0x01', 96), { from: voting })
operators.setNodeOperatorStakingLimit(0, 3, { from: voting })
await operators.setNodeOperatorStakingLimit(0, 3, { from: voting })

await web3.eth.sendTransaction({ to: app.address, from: user3, value: ETH(1) })
await app.methods['deposit(uint256,uint256,bytes)'](MAX_DEPOSITS, CURATED_MODULE_ID, CALLDATA, { from: depositor })
Expand Down
34 changes: 17 additions & 17 deletions test/0.4.24/lidoHandleOracleReport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>
it('report BcnValidators:0 BcnBalance:0 = no rewards', async () => {
console.log(consensus.address, oracle.address)
await pushOracleReport(consensus, oracle, 0, 0)
checkStat({ depositedValidators: 0, beaconValidators: 0, beaconBalance: ETH(0) })
await checkStat({ depositedValidators: 0, beaconValidators: 0, beaconBalance: ETH(0) })
assertBn(await app.getBufferedEther(), ETH(0))
assertBn(await app.getTotalPooledEther(), ETH(0))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -58,7 +58,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>

it('report BcnValidators:1 = revert', async () => {
await assertRevert(pushOracleReport(consensus, oracle, 1, 0), 'REPORTED_MORE_DEPOSITED')
checkStat({ depositedValidators: 0, beaconValidators: 0, beaconBalance: ETH(0) })
await checkStat({ depositedValidators: 0, beaconValidators: 0, beaconBalance: ETH(0) })
assertBn(await app.getBufferedEther(), ETH(0))
assertBn(await app.getTotalPooledEther(), ETH(0))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -69,14 +69,14 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>
context('with depositedVals=0, beaconVals=0, bcnBal=0, bufferedEth=12', async () => {
it('report BcnValidators:0 BcnBalance:0 = no rewards', async () => {
await pushOracleReport(consensus, oracle, 0, 0)
checkStat({ depositedValidators: 0, beaconValidators: 0, beaconBalance: ETH(0) })
await checkStat({ depositedValidators: 0, beaconValidators: 0, beaconBalance: ETH(0) })
assertBn(await app.getBufferedEther(), ETH(12))
assertBn(await app.getTotalPooledEther(), ETH(12))
// assert.equal(await app.distributeFeeCalled(), false)
// assertBn(await app.totalRewards(), 0)

await assertRevert(pushOracleReport(consensus, oracle, 1, 0), 'REPORTED_MORE_DEPOSITED')
checkStat({ depositedValidators: 0, beaconValidators: 0, beaconBalance: ETH(0) })
await checkStat({ depositedValidators: 0, beaconValidators: 0, beaconBalance: ETH(0) })
assertBn(await app.getBufferedEther(), ETH(12))
assertBn(await app.getTotalPooledEther(), ETH(12))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -86,14 +86,14 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>

context('with depositedVals=1, beaconVals=0, bcnBal=0, bufferedEth=3', async () => {
it('initial state before report', async () => {
checkStat({ depositedValidators: 1, beaconValidators: 0, beaconBalance: ETH(0) })
await checkStat({ depositedValidators: 1, beaconValidators: 0, beaconBalance: ETH(0) })
assertBn(await app.getBufferedEther(), ETH(3))
assertBn(await app.getTotalPooledEther(), ETH(35))
})

it('report BcnValidators:0 BcnBalance:0 = no rewards', async () => {
await pushOracleReport(consensus, oracle, 0, 0)
checkStat({ depositedValidators: 1, beaconValidators: 0, beaconBalance: ETH(0) })
await checkStat({ depositedValidators: 1, beaconValidators: 0, beaconBalance: ETH(0) })
assertBn(await app.getBufferedEther(), ETH(3))
assertBn(await app.getTotalPooledEther(), ETH(35))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -105,7 +105,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>
pushOracleReport(consensus, oracle, 2, ETH(65)),
'REPORTED_MORE_DEPOSITED'
)
checkStat({ depositedValidators: 1, beaconValidators: 0, beaconBalance: ETH(0) })
await checkStat({ depositedValidators: 1, beaconValidators: 0, beaconBalance: ETH(0) })
assertBn(await app.getBufferedEther(), ETH(3))
assertBn(await app.getTotalPooledEther(), ETH(35))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -114,7 +114,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>

it('report BcnValidators:1 BcnBalance:31 = no rewards', async () => {
await pushOracleReport(consensus, oracle, 1, ETH(31))
checkStat({ depositedValidators: 1, beaconValidators: 1, beaconBalance: ETH(31) })
await checkStat({ depositedValidators: 1, beaconValidators: 1, beaconBalance: ETH(31) })
assertBn(await app.getBufferedEther(), ETH(3))
assertBn(await app.getTotalPooledEther(), ETH(34))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -123,7 +123,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>

it('report BcnValidators:1 BcnBalance:32 = no rewards', async () => {
await pushOracleReport(consensus, oracle, 1, ETH(32))
checkStat({ depositedValidators: 1, beaconValidators: 1, beaconBalance: ETH(32) })
await checkStat({ depositedValidators: 1, beaconValidators: 1, beaconBalance: ETH(32) })
assertBn(await app.getBufferedEther(), ETH(3))
assertBn(await app.getTotalPooledEther(), ETH(35))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -141,14 +141,14 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>
})

it('initial state before report', async () => {
checkStat({ depositedValidators: 2, beaconValidators: 1, beaconBalance: ETH(30) })
await checkStat({ depositedValidators: 2, beaconValidators: 1, beaconBalance: ETH(30) })
assertBn(await app.getBufferedEther(), ETH(5))
assertBn(await app.getTotalPooledEther(), ETH(67))
})

it('report BcnValidators:1 BcnBalance:0 = no rewards', async () => {
await pushOracleReport(consensus, oracle, 1, 0)
checkStat({ depositedValidators: 2, beaconValidators: 1, beaconBalance: ETH(0) })
await checkStat({ depositedValidators: 2, beaconValidators: 1, beaconBalance: ETH(0) })
assertBn(await app.getBufferedEther(), ETH(5))
assertBn(await app.getTotalPooledEther(), ETH(37))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -157,7 +157,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>

it('report BcnValidators:1 BcnBalance:1 = no rewards', async () => {
await pushOracleReport({epochId: 100, clValidators: 1, clBalance: ETH(1)})
checkStat({ depositedValidators: 2, beaconValidators: 1, beaconBalance: ETH(1) })
await checkStat({ depositedValidators: 2, beaconValidators: 1, beaconBalance: ETH(1) })
assertBn(await app.getBufferedEther(), ETH(5))
assertBn(await app.getTotalPooledEther(), ETH(38))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -166,7 +166,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>

it('report BcnValidators:2 BcnBalance:62 = no reward', async () => {
await pushOracleReport({epochId: 100, clValidators: 2, clBalance: ETH(62)})
checkStat({ depositedValidators: 2, beaconValidators: 2, beaconBalance: ETH(62) })
await checkStat({ depositedValidators: 2, beaconValidators: 2, beaconBalance: ETH(62) })
assertBn(await app.getBufferedEther(), ETH(5))
assertBn(await app.getTotalPooledEther(), ETH(67))
// assert.equal(await app.distributeFeeCalled(), false)
Expand All @@ -175,7 +175,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>

it('report BcnValidators:1 BcnBalance:31 = reward:1', async () => {
await pushOracleReport({epochId: 100, clValidators: 2, clBalance: ETH(63)})
checkStat({ depositedValidators: 2, beaconValidators: 2, beaconBalance: ETH(63) })
await checkStat({ depositedValidators: 2, beaconValidators: 2, beaconBalance: ETH(63) })
assertBn(await app.getBufferedEther(), ETH(5))
assertBn(await app.getTotalPooledEther(), ETH(68))
// assert.equal(await app.distributeFeeCalled(), true)
Expand All @@ -184,7 +184,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>

it('report BcnValidators:2 BcnBalance:63 = reward:1', async () => {
await pushOracleReport({epochId: 100, clValidators: 2, clBalance: ETH(63)})
checkStat({ depositedValidators: 2, beaconValidators: 2, beaconBalance: ETH(63) })
await checkStat({ depositedValidators: 2, beaconValidators: 2, beaconBalance: ETH(63) })
assertBn(await app.getBufferedEther(), ETH(5))
assertBn(await app.getTotalPooledEther(), ETH(68))
// assert.equal(await app.distributeFeeCalled(), true)
Expand All @@ -196,7 +196,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>
pushOracleReport({epochId: 110, clValidators: 3, clBalance: ETH(65)}),
'REPORTED_MORE_DEPOSITED'
)
checkStat({ depositedValidators: 2, beaconValidators: 1, beaconBalance: ETH(30) })
await checkStat({ depositedValidators: 2, beaconValidators: 1, beaconBalance: ETH(30) })
assertBn(await app.getBufferedEther(), ETH(5))
assertBn(await app.getTotalPooledEther(), ETH(67))
// assert.equal(await app.distributeFeeCalled(), false)
Expand Down Expand Up @@ -228,7 +228,7 @@ contract.skip('Lido: handleOracleReport', ([appManager, stranger, depositor]) =>
'REPORTED_LESS_VALIDATORS'
)
// values stay intact
checkStat({ depositedValidators: 5, beaconValidators: 4, beaconBalance: ETH(1) })
await checkStat({ depositedValidators: 5, beaconValidators: 4, beaconBalance: ETH(1) })
assertBn(await app.getBufferedEther(), ETH(0))
assertBn(await app.getTotalPooledEther(), ETH(33))
// assert.equal(await app.distributeFeeCalled(), false)
Expand Down
6 changes: 3 additions & 3 deletions test/0.4.24/node-operators-registry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ contract('NodeOperatorsRegistry', ([appManager, voting, user1, user2, user3, nob
{ stoppedValidators: exitedValidatorsKeysCountBefore },
{ exitedSigningKeysCount: exitedSigningKeysCountBefore }
] = await Promise.all([
await app.getNodeOperator(firstNodeOperatorId, false),
app.getNodeOperator(firstNodeOperatorId, false),
app.testing_getTotalSigningKeysStats()
])
assert(newExitedValidatorsCount < exitedValidatorsKeysCountBefore.toNumber())
Expand All @@ -1344,7 +1344,7 @@ contract('NodeOperatorsRegistry', ([appManager, voting, user1, user2, user3, nob
{ stoppedValidators: exitedValidatorsKeysCountBefore },
{ exitedSigningKeysCount: exitedSigningKeysCountBefore }
] = await Promise.all([
await app.getNodeOperator(firstNodeOperatorId, false),
app.getNodeOperator(firstNodeOperatorId, false),
app.testing_getTotalSigningKeysStats()
])
assert(newExitedValidatorsCount > exitedValidatorsKeysCountBefore.toNumber())
Expand Down Expand Up @@ -1494,7 +1494,7 @@ contract('NodeOperatorsRegistry', ([appManager, voting, user1, user2, user3, nob
// invalidated all keys before the test to remove all unused keys of node operators
await app.onWithdrawalCredentialsChanged({ from: voting })
// the second invalidation must not invalidate keys
const receipt = app.onWithdrawalCredentialsChanged({ from: voting })
const receipt = await app.onWithdrawalCredentialsChanged({ from: voting })
const nonceBefore = await app.getNonce()
assert.notEmits(receipt, 'NodeOperatorTotalKeysTrimmed')
const nonceAfter = await app.getNonce()
Expand Down
6 changes: 3 additions & 3 deletions test/0.4.24/steth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ contract('StETH', ([_, __, user1, user2, user3, nobody]) => {
})

it(`transfers works with no pooled ehter, balances aren't changed`, async () => {
stEth.transfer(user1, tokens(1), { from: user2 })
stEth.transfer(user2, tokens(100), { from: user3 })
stEth.transfer(user3, tokens(1000), { from: user1 })
await stEth.transfer(user1, tokens(1), { from: user2 })
await stEth.transfer(user2, tokens(100), { from: user3 })
await stEth.transfer(user3, tokens(1000), { from: user1 })

assertBn(await stEth.balanceOf(user1), tokens(0))
assertBn(await stEth.balanceOf(user2), tokens(0))
Expand Down
12 changes: 6 additions & 6 deletions test/0.8.9/deposit-security-module.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ contract('DepositSecurityModule', ([owner, stranger, guardian]) => {
for (let i = 0; i < numBlocksToMine; ++i) {
await network.provider.send('evm_mine')
}
return web3.eth.getBlock('latest')
return await web3.eth.getBlock('latest')
}

describe('depositBufferedEther', () => {
Expand Down Expand Up @@ -970,7 +970,7 @@ contract('DepositSecurityModule', ([owner, stranger, guardian]) => {
assert.isTrue((await depositSecurityModule.getGuardianQuorum()) > 0, 'invariant failed: quorum > 0')

const lastDepositBlockNumber = await web3.eth.getBlockNumber()
stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await waitBlocks(2 * MIN_DEPOSIT_BLOCK_DISTANCE)

const currentBlockNumber = await web3.eth.getBlockNumber()
Expand All @@ -984,7 +984,7 @@ contract('DepositSecurityModule', ([owner, stranger, guardian]) => {
assert.isTrue((await depositSecurityModule.getGuardianQuorum()) > 0, 'invariant failed: quorum > 0')

const lastDepositBlockNumber = await web3.eth.getBlockNumber()
stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
const latestBlock = await waitBlocks(2 * MIN_DEPOSIT_BLOCK_DISTANCE)

const minDepositBlockDistance = await depositSecurityModule.getMinDepositBlockDistance()
Expand All @@ -1003,7 +1003,7 @@ contract('DepositSecurityModule', ([owner, stranger, guardian]) => {
assert.equal(await stakingRouterMock.getStakingModuleIsDepositsPaused(STAKING_MODULE), false, 'invariant failed: isPaused')

const lastDepositBlockNumber = await web3.eth.getBlockNumber()
stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await waitBlocks(2 * MIN_DEPOSIT_BLOCK_DISTANCE)

const currentBlockNumber = await web3.eth.getBlockNumber()
Expand All @@ -1021,7 +1021,7 @@ contract('DepositSecurityModule', ([owner, stranger, guardian]) => {
assert.equal(await stakingRouterMock.getStakingModuleIsDepositsPaused(STAKING_MODULE), false, 'invariant failed: isPaused')

const lastDepositBlockNumber = await web3.eth.getBlockNumber()
stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await waitBlocks(Math.floor(MIN_DEPOSIT_BLOCK_DISTANCE / 2))

const currentBlockNumber = await web3.eth.getBlockNumber()
Expand All @@ -1036,7 +1036,7 @@ contract('DepositSecurityModule', ([owner, stranger, guardian]) => {
assert.isTrue((await depositSecurityModule.getGuardianQuorum()) > 0, 'invariant failed: quorum > 0')

const lastDepositBlockNumber = await web3.eth.getBlockNumber()
stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await stakingRouterMock.setStakingModuleLastDepositBlock(lastDepositBlockNumber)
await waitBlocks(2 * MIN_DEPOSIT_BLOCK_DISTANCE)

const currentBlockNumber = await web3.eth.getBlockNumber()
Expand Down
2 changes: 1 addition & 1 deletion test/0.8.9/oracle-daemon-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ contract('OracleDaemonConfig', async ([deployer, manager, stranger]) => {

it('deployer cannot unset a defaultValue', async () => {
await config.set(defaultKey, defaultValue, { from: manager })
assert.revertsOZAccessControl(
await assert.revertsOZAccessControl(
config.unset(defaultKey, { from: deployer }),
deployer,
`CONFIG_MANAGER_ROLE`
Expand Down
2 changes: 1 addition & 1 deletion test/0.8.9/oracle/accounting-oracle-access-control.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract('AccountingOracle', ([admin, account1, account2, member1, member2, stra

oracle = deployed.oracle
consensus = deployed.consensus
mockLido = deploy.mockLido
mockLido = deployed.mockLido
}

context('deploying', () => {
Expand Down
8 changes: 4 additions & 4 deletions test/0.8.9/withdrawal-queue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ contract('WithdrawalQueue', ([owner, stranger, daoAgent, user]) => {
await steth.mintShares(user, shares(1))
await steth.approve(withdrawalQueue.address, StETH(300), { from: user })

impersonate(ethers.provider, steth.address)
snapshot.make();
await impersonate(ethers.provider, steth.address)
await snapshot.make();
})

afterEach(async () => {
Expand Down Expand Up @@ -771,12 +771,12 @@ contract('WithdrawalQueue', ([owner, stranger, daoAgent, user]) => {
})

it("One can't change someone else's request", async () => {
await assert.reverts(withdrawalQueue.transferFrom(user, owner, requestId, { from: stranger }),
await assert.reverts(withdrawalQueue.transferFrom(user, owner, requestId, { from: stranger }),
`NotOwnerOrApproved("${stranger}")`)
})

it("One can't pass zero owner", async () => {
await assert.reverts(withdrawalQueue.transferFrom(user, ZERO_ADDRESS, requestId, { from: user }),
await assert.reverts(withdrawalQueue.transferFrom(user, ZERO_ADDRESS, requestId, { from: user }),
'TransferToZeroAddress()')
})

Expand Down
Loading

0 comments on commit 69da980

Please sign in to comment.