-
Notifications
You must be signed in to change notification settings - Fork 0
/
side-entrance.challenge.js
38 lines (29 loc) · 1.39 KB
/
side-entrance.challenge.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const { ethers } = require('hardhat');
const { expect } = require('chai');
const { setBalance } = require('@nomicfoundation/hardhat-network-helpers');
describe('[Challenge] Side entrance', function () {
let deployer, player;
let pool;
const ETHER_IN_POOL = 1000n * 10n ** 18n;
const PLAYER_INITIAL_ETH_BALANCE = 1n * 10n ** 18n;
before(async function () {
/** SETUP SCENARIO - NO NEED TO CHANGE ANYTHING HERE */
[deployer, player] = await ethers.getSigners();
// Deploy pool and fund it
pool = await (await ethers.getContractFactory('SideEntranceLenderPool', deployer)).deploy();
await pool.deposit({ value: ETHER_IN_POOL });
expect(await ethers.provider.getBalance(pool.address)).to.equal(ETHER_IN_POOL);
// Player starts with limited ETH in balance
await setBalance(player.address, PLAYER_INITIAL_ETH_BALANCE);
expect(await ethers.provider.getBalance(player.address)).to.eq(PLAYER_INITIAL_ETH_BALANCE);
});
it('Execution', async function () {
/** CODE YOUR SOLUTION HERE */
});
after(async function () {
/** SUCCESS CONDITIONS - NO NEED TO CHANGE ANYTHING HERE */
// Player took all ETH from the pool
expect(await ethers.provider.getBalance(pool.address)).to.be.equal(0);
expect(await ethers.provider.getBalance(player.address)).to.be.gt(ETHER_IN_POOL);
});
});