/
owner.test.js
206 lines (174 loc) · 10.8 KB
/
owner.test.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
const { expect } = require('chai');
const { ethers } = require('hardhat');
const { CONFIG, DISCOUNT, getBigNumber } = require('../scripts/utils');
const ERC20 = require('../data/ERC20.json');
describe('Ownablee', function () {
before(async function () {
this.VabbleDAOFactory = await ethers.getContractFactory('VabbleDAO');
this.UniHelperFactory = await ethers.getContractFactory('UniHelper');
this.StakingPoolFactory = await ethers.getContractFactory('StakingPool');
this.VoteFactory = await ethers.getContractFactory('Vote');
this.PropertyFactory = await ethers.getContractFactory('Property');
this.FactoryFilmNFTFactory = await ethers.getContractFactory('FactoryFilmNFT');
this.FactoryTierNFTFactory = await ethers.getContractFactory('FactoryTierNFT');
this.FactorySubNFTFactory = await ethers.getContractFactory('FactorySubNFT');
this.OwnableFactory = await ethers.getContractFactory('Ownablee');
this.SubscriptionFactory = await ethers.getContractFactory('Subscription');
this.signers = await ethers.getSigners();
this.auditor = this.signers[0];
this.newAuditor = this.signers[1];
this.studio1 = this.signers[2];
this.studio2 = this.signers[3];
this.studio3 = this.signers[4];
this.customer1 = this.signers[5];
this.customer2 = this.signers[6];
this.customer3 = this.signers[7];
});
beforeEach(async function () {
this.vabToken = new ethers.Contract(CONFIG.mumbai.vabToken, JSON.stringify(ERC20), ethers.provider);
this.EXM = new ethers.Contract(CONFIG.mumbai.exmAddress, JSON.stringify(ERC20), ethers.provider);
this.USDC = new ethers.Contract(CONFIG.mumbai.usdcAdress, JSON.stringify(ERC20), ethers.provider);
this.Ownablee = await (await this.OwnableFactory.deploy(
CONFIG.daoWalletAddress, this.vabToken.address, this.USDC.address, this.auditor.address
)).deployed();
this.UniHelper = await (await this.UniHelperFactory.deploy(
CONFIG.mumbai.uniswap.factory, CONFIG.mumbai.uniswap.router, CONFIG.mumbai.sushiswap.factory, CONFIG.mumbai.sushiswap.router
)).deployed();
this.StakingPool = await (await this.StakingPoolFactory.deploy(this.Ownablee.address)).deployed();
this.Vote = await (await this.VoteFactory.deploy(this.Ownablee.address)).deployed();
this.Property = await (
await this.PropertyFactory.deploy(
this.Ownablee.address,
this.UniHelper.address,
this.Vote.address,
this.StakingPool.address
)
).deployed();
this.FilmNFT = await (
await this.FactoryFilmNFTFactory.deploy(this.Ownablee.address, this.UniHelper.address)
).deployed();
this.SubNFT = await (
await this.FactorySubNFTFactory.deploy(this.Ownablee.address, this.UniHelper.address)
).deployed();
this.VabbleDAO = await (
await this.VabbleDAOFactory.deploy(
this.Ownablee.address,
this.UniHelper.address,
this.Vote.address,
this.StakingPool.address,
this.Property.address,
this.FilmNFT.address
)
).deployed();
this.TierNFT = await (
await this.FactoryTierNFTFactory.deploy(
this.Ownablee.address, // Ownablee contract
this.VabbleDAO.address
)
).deployed();
this.Subscription = await (
await this.SubscriptionFactory.deploy(
this.Ownablee.address,
this.UniHelper.address,
this.Property.address,
[DISCOUNT.month3, DISCOUNT.month6, DISCOUNT.month12]
)
).deployed();
await this.FilmNFT.connect(this.auditor).initializeFactory(
this.VabbleDAO.address,
this.StakingPool.address,
this.Property.address,
{from: this.auditor.address}
);
// ====== VAB
// Transfering VAB token to user1, 2, 3
await this.vabToken.connect(this.auditor).transfer(this.customer1.address, getBigNumber(50000000), {from: this.auditor.address});
await this.vabToken.connect(this.auditor).transfer(this.customer2.address, getBigNumber(50000000), {from: this.auditor.address});
await this.vabToken.connect(this.auditor).transfer(this.customer3.address, getBigNumber(500000), {from: this.auditor.address});
// Transfering VAB token to studio1, 2, 3
await this.vabToken.connect(this.auditor).transfer(this.studio1.address, getBigNumber(5000000), {from: this.auditor.address});
await this.vabToken.connect(this.auditor).transfer(this.studio2.address, getBigNumber(5000000), {from: this.auditor.address});
await this.vabToken.connect(this.auditor).transfer(this.studio3.address, getBigNumber(5000000), {from: this.auditor.address});
// Approve to transfer VAB token for each user, studio to DAO, StakingPool
await this.vabToken.connect(this.customer1).approve(this.VabbleDAO.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer2).approve(this.VabbleDAO.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer3).approve(this.VabbleDAO.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer1).approve(this.SubNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer2).approve(this.SubNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer3).approve(this.SubNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer1).approve(this.StakingPool.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer2).approve(this.StakingPool.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer3).approve(this.StakingPool.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer1).approve(this.FilmNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer2).approve(this.FilmNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer3).approve(this.FilmNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer1).approve(this.Subscription.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer2).approve(this.Subscription.address, getBigNumber(100000000));
await this.vabToken.connect(this.customer3).approve(this.Subscription.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio1).approve(this.VabbleDAO.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio2).approve(this.VabbleDAO.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio3).approve(this.VabbleDAO.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio1).approve(this.SubNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio2).approve(this.SubNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio3).approve(this.SubNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio1).approve(this.StakingPool.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio2).approve(this.StakingPool.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio3).approve(this.StakingPool.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio1).approve(this.FilmNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio2).approve(this.FilmNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio3).approve(this.FilmNFT.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio1).approve(this.Subscription.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio2).approve(this.Subscription.address, getBigNumber(100000000));
await this.vabToken.connect(this.studio3).approve(this.Subscription.address, getBigNumber(100000000));
// Initialize StakingPool
await this.StakingPool.connect(this.auditor).initializePool(
this.VabbleDAO.address,
this.Property.address,
this.Vote.address,
{from: this.auditor.address}
)
// Staking VAB token
await this.StakingPool.connect(this.customer1).stakeVAB(getBigNumber(40000000), {from: this.customer1.address})
await this.StakingPool.connect(this.customer2).stakeVAB(getBigNumber(40000000), {from: this.customer2.address})
await this.StakingPool.connect(this.customer3).stakeVAB(getBigNumber(300), {from: this.customer3.address})
await this.StakingPool.connect(this.studio1).stakeVAB(getBigNumber(300), {from: this.studio1.address})
await this.StakingPool.connect(this.studio2).stakeVAB(getBigNumber(300), {from: this.studio2.address})
await this.StakingPool.connect(this.studio3).stakeVAB(getBigNumber(300), {from: this.studio3.address})
// Confirm auditor
expect(await this.Ownablee.auditor()).to.be.equal(this.auditor.address);
this.events = [];
});
it('Transfer ownership', async function () {
// Auditor is contract deployer
expect(await this.Ownablee.auditor()).to.be.equal(this.auditor.address);
// Transfer auditor to new address
await this.Ownablee.transferAuditor(this.newAuditor.address);
expect(await this.Ownablee.auditor()).to.be.equal(this.newAuditor.address);
});
it('Test of addDepositAsset', async function () {
// Add deposit asset
const assetList = [CONFIG.addressZero, CONFIG.mumbai.usdcAdress, CONFIG.mumbai.vabToken, CONFIG.mumbai.daiAddress, CONFIG.mumbai.exmAddress]
await this.Ownablee.addDepositAsset(assetList);
// Check if assetList added as deposit asset
expect(await this.Ownablee.isDepositAsset(assetList[0])).to.be.true;
expect(await this.Ownablee.isDepositAsset(assetList[1])).to.be.true;
expect(await this.Ownablee.isDepositAsset(assetList[2])).to.be.true;
expect(await this.Ownablee.isDepositAsset(assetList[3])).to.be.true;
let depositAssets = await this.Ownablee.getDepositAssetList();
expect(depositAssets.length).to.be.equal(assetList.length);
// Remove deposit asset
const removeList = [CONFIG.addressZero, CONFIG.mumbai.usdcAdress]
await this.Ownablee.removeDepositAsset(removeList);
// Check if assetList added as deposit asset
depositAssets = await this.Ownablee.getDepositAssetList();
expect(depositAssets.length).to.be.equal(assetList.length - removeList.length);
console.log('=====asset list-0::', depositAssets[0], depositAssets[1], depositAssets[2])
expect(depositAssets[0]).to.be.equal(CONFIG.mumbai.exmAddress);
expect(depositAssets[1]).to.be.equal(CONFIG.mumbai.daiAddress);
expect(depositAssets[2]).to.be.equal(CONFIG.mumbai.vabToken);
const assetList1 = [CONFIG.addressZero]
await this.Ownablee.addDepositAsset(assetList1);
depositAssets = await this.Ownablee.getDepositAssetList();
console.log('=====asset list-1::', depositAssets)
});
});