-
Notifications
You must be signed in to change notification settings - Fork 9
/
TokenomicsProxy.js
53 lines (43 loc) · 2.04 KB
/
TokenomicsProxy.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
/*global describe, beforeEach, it, context*/
const { ethers } = require("hardhat");
const { expect } = require("chai");
describe("TokenomicsProxy", async () => {
const AddressZero = "0x" + "0".repeat(40);
let TokenomicsProxy;
let tokenomicsProxy;
let mockTokenomics;
let tokenomics;
let proxyData;
// These should not be in beforeEach.
beforeEach(async () => {
const MockTokenomics = await ethers.getContractFactory("MockTokenomics");
mockTokenomics = await MockTokenomics.deploy();
await mockTokenomics.deployed();
proxyData = mockTokenomics.interface.encodeFunctionData("initialize", []);
TokenomicsProxy = await ethers.getContractFactory("TokenomicsProxy");
tokenomicsProxy = await TokenomicsProxy.deploy(mockTokenomics.address, proxyData);
await tokenomicsProxy.deployed();
tokenomics = await ethers.getContractAt("MockTokenomics", tokenomicsProxy.address);
});
context("Initialization", async function () {
it("Incorrect initialization parameters", async function () {
// Try to initialize with the zero master copy address
await expect(
TokenomicsProxy.deploy(AddressZero, proxyData)
).to.be.revertedWithCustomError(tokenomicsProxy, "ZeroTokenomicsAddress");
// Try to initialize with the zero data
await expect(
TokenomicsProxy.deploy(mockTokenomics.address, "0x")
).to.be.revertedWithCustomError(tokenomicsProxy, "ZeroTokenomicsData");
});
it("Checking the implementation address", async function () {
expect(await tokenomics.tokenomicsImplementation()).to.equal(mockTokenomics.address);
});
it("Should fail if the initialization is reverted", async function () {
const proxyData = mockTokenomics.interface.encodeFunctionData("simulateFailure", []);
await expect(
TokenomicsProxy.deploy(mockTokenomics.address, proxyData)
).to.be.reverted;
});
});
});