generated from nicobevilacqua/hardhat-solidity-typescript-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-CarMarket.test.ts
46 lines (34 loc) · 1.34 KB
/
03-CarMarket.test.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
41
42
43
44
45
46
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { expect } from 'chai';
import { Contract } from 'ethers';
import { ethers } from 'hardhat';
describe('CarMarket', () => {
let token: Contract;
let market: Contract;
let factory: Contract;
let attacker: SignerWithAddress;
let deployer: SignerWithAddress;
before(async () => {
[attacker, deployer] = await ethers.getSigners();
token = await (await ethers.getContractFactory('CarToken', deployer)).deploy();
await token.deployed();
market = await (await ethers.getContractFactory('CarMarket', deployer)).deploy(token.address);
await market.deployed();
factory = await (
await ethers.getContractFactory('CarFactory', deployer)
).deploy(market.address, token.address);
await factory.deployed();
await (await market.setCarFactory(factory.address)).wait();
await (await token.priviledgedMint(market.address, ethers.utils.parseEther('100000'))).wait();
await (await token.priviledgedMint(factory.address, ethers.utils.parseEther('100000'))).wait();
token = token.connect(attacker);
market = market.connect(attacker);
factory = factory.connect(attacker);
});
it('attack', async () => {
/**
* YOUR CODE HERE
*/
expect((await market.getCarCount(attacker.address)).gt(2)).to.be.true;
});
});