generated from 0xJuancito/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
05-Token.spec.ts
31 lines (24 loc) · 919 Bytes
/
05-Token.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
import { TransactionResponse } from "@ethersproject/providers";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect } from "chai";
import { Contract, Wallet } from "ethers";
import { ethers } from "hardhat";
const CONTRACT_NAME = "Token";
describe(CONTRACT_NAME, () => {
let _owner: SignerWithAddress;
let attacker: SignerWithAddress;
let contract: Contract;
let tx: TransactionResponse;
beforeEach(async () => {
[attacker] = await ethers.getSigners();
const factory = await ethers.getContractFactory(CONTRACT_NAME);
contract = await factory.deploy(20);
await contract.deployed();
contract = contract.connect(attacker);
});
it("Solves the challenge", async () => {
tx = await contract.transfer(Wallet.createRandom().address, 21);
await tx.wait();
expect(await contract.balanceOf(attacker.address)).to.be.greaterThan(20);
});
});