generated from 0xJuancito/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
14-GatekeeperTwo.spec.ts
32 lines (25 loc) · 1009 Bytes
/
14-GatekeeperTwo.spec.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 { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect } from "chai";
import { Contract } from "ethers";
import { ethers } from "hardhat";
const CONTRACT_NAME = "GatekeeperTwo";
const ATTACKER_NAME = "GatekeeperTwoAttacker";
describe(CONTRACT_NAME, () => {
let _owner: SignerWithAddress;
let attacker: SignerWithAddress;
let contract: Contract;
let attackerContract: Contract;
beforeEach(async () => {
[_owner, attacker] = await ethers.getSigners();
const factory = await ethers.getContractFactory(CONTRACT_NAME);
contract = await factory.deploy();
await contract.deployed();
contract = contract.connect(attacker);
});
it("Solves the challenge", async () => {
const attackerFactory = await ethers.getContractFactory(ATTACKER_NAME);
attackerContract = await attackerFactory.connect(attacker).deploy(contract.address);
await attackerContract.deployed();
expect(await contract.entrant()).to.eq(attacker.address);
});
});