Created
January 16, 2021 13:50
-
-
Save zaryab2000/1287ed3ab8dd1046d3e0581190cea7d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ether, balance } = require('@openzeppelin/test-helpers'); | |
const { accounts, contract } = require('@openzeppelin/test-environment'); | |
const SideEntranceLenderPool = contract.fromArtifact('SideEntranceLenderPool'); | |
const SideEntranceAttacker = contract.fromArtifact('SideEntranceAttacker'); | |
const { expect } = require('chai'); | |
describe('[Challenge] Side entrance', function () { | |
const [deployer, attacker, ...otherAccounts] = accounts; | |
const ETHER_IN_POOL = ether('1000'); | |
before(async function () { | |
/** SETUP SCENARIO */ | |
this.pool = await SideEntranceLenderPool.new({ from: deployer }); | |
await this.pool.deposit({ from: deployer, value: ETHER_IN_POOL }); | |
this.attackerInitialEthBalance = await balance.current(attacker); | |
expect( | |
await balance.current(this.pool.address) | |
).to.be.bignumber.equal(ETHER_IN_POOL); | |
}); | |
it('Exploit', async function () { | |
/** YOUR EXPLOIT GOES HERE */ | |
}); | |
after(async function () { | |
/** SUCCESS CONDITIONS */ | |
expect( | |
await balance.current(this.pool.address) | |
).to.be.bignumber.equal('0'); | |
// Not checking exactly how much is the final balance of the attacker, | |
// because it'll depend on how much gas the attacker spends in the attack | |
// If there were no gas costs, it would be balance before attack + ETHER_IN_POOL | |
expect( | |
await balance.current(attacker) | |
).to.be.bignumber.gt(this.attackerInitialEthBalance); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment