-
Notifications
You must be signed in to change notification settings - Fork 0
/
pesto-hill.js
50 lines (38 loc) · 1.24 KB
/
pesto-hill.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
39
40
41
42
43
44
45
46
47
48
49
50
const { ethers } = require("hardhat");
const { expect } = require("chai");
const {
anyValue,
reverted,
} = require("@nomicfoundation/hardhat-chai-matchers/");
const challengeName = "Pesto-Hill Challenge";
describe(challengeName, function () {
let alice, bob;
const INITIAL_BRIBE = ethers.utils.parseEther("1");
before(async function () {
/** SETUP SCENARIO - DON'T CHANGE ANYTHING HERE */
[alice, bob] = await ethers.getSigners();
const PestoHill = await ethers.getContractFactory("PestoHill", alice);
this.PestoHill = await PestoHill.deploy(alice.address, {
value: INITIAL_BRIBE,
});
expect(await this.PestoHill.bribe()).to.equal(INITIAL_BRIBE);
});
it("Exploit", async function () {
/** CODE YOUR EXPLOIT HERE */
});
after(async function () {
/** SUCCESS CONDITIONS */
// Alice tries to reclaim the ownership...
var bribe = await this.PestoHill.bribe();
await expect(
alice.sendTransaction({
to: this.PestoHill.address,
value: bribe,
})
).to.be.reverted;
bribe = await this.PestoHill.bribe();
if (expect(await this.PestoHill.atTheTop()).not.to.equal(alice.address)) {
console.log(`You have passed the ${challengeName}.`);
}
});
});