forked from NeokingdomDAO/whitelabel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntegrationInternalMarketRedemptionController.ts
94 lines (80 loc) · 3.14 KB
/
IntegrationInternalMarketRedemptionController.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
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
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import chai from "chai";
import chaiAsPromised from "chai-as-promised";
import { solidity } from "ethereum-waffle";
import { parseEther } from "ethers/lib/utils";
import { ethers, network } from "hardhat";
import {
GovernanceToken,
InternalMarket,
RedemptionController,
ShareholderRegistry,
Voting,
} from "../typechain";
import { DEPLOY_SEQUENCE, generateDeployContext } from "../lib";
import { NeokingdomDAOMemory } from "../lib/environment/memory";
import { Address, DAOConfig } from "../lib/internal/types";
import { SETUP_MOCK_SEQUENCE } from "../lib/sequence/deploy";
import { timeTravel } from "./utils/evm";
import { setupDAO } from "./utils/setup";
chai.use(solidity);
chai.use(chaiAsPromised);
const { expect } = chai;
const e = (v: number) => parseEther(v.toString());
describe("Integration", async () => {
let snapshotId: string;
let voting: Voting;
let internalMarket: InternalMarket;
let redemptionController: RedemptionController;
let governanceToken: GovernanceToken;
let shareholderRegistry: ShareholderRegistry;
let managingBoardStatus: string;
let contributorStatus: string;
let investorStatus: string;
let deployer: SignerWithAddress;
let board: SignerWithAddress;
let reserve: SignerWithAddress;
let contributor: SignerWithAddress;
let investor: SignerWithAddress;
let trader: SignerWithAddress;
before(async () => {
[deployer, reserve, board, contributor, investor, trader] =
await ethers.getSigners();
const neokingdom = await setupDAO(deployer, reserve);
({
governanceToken,
shareholderRegistry,
internalMarket,
redemptionController,
} = await neokingdom.loadContracts());
managingBoardStatus = await shareholderRegistry.MANAGING_BOARD_STATUS();
contributorStatus = await shareholderRegistry.CONTRIBUTOR_STATUS();
investorStatus = await shareholderRegistry.INVESTOR_STATUS();
await shareholderRegistry.mint(board.address, e(1));
await shareholderRegistry.mint(contributor.address, e(1));
await shareholderRegistry.mint(investor.address, e(1));
await shareholderRegistry.setStatus(managingBoardStatus, board.address);
await shareholderRegistry.setStatus(contributorStatus, contributor.address);
await shareholderRegistry.setStatus(investorStatus, investor.address);
});
beforeEach(async () => {
snapshotId = await network.provider.send("evm_snapshot");
});
afterEach(async () => {
await network.provider.send("evm_revert", [snapshotId]);
});
it("An investor should not be able to redeem tokens if promoted to contributor", async () => {
// Investor gets 100 tokens for investing
await governanceToken.mint(investor.address, e(100));
// Investor gets promoted to contributor
await shareholderRegistry.setStatus(contributorStatus, investor.address);
await governanceToken
.connect(investor)
.approve(internalMarket.address, e(100));
await internalMarket.connect(investor).makeOffer(e(100));
await timeTravel(60, true);
expect(
await redemptionController.redeemableBalance(investor.address)
).equal(e(0));
});
});