-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy pathconfiguration.test.ts
134 lines (105 loc) · 5.06 KB
/
configuration.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
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
import { expect } from 'chai'
import { constants } from 'ethers'
import { Curation } from '../../build/types/Curation'
import { defaults } from '../lib/deployment'
import { NetworkFixture } from '../lib/fixtures'
import { getAccounts, toBN, Account, randomAddress } from '../lib/testHelpers'
const { AddressZero } = constants
const MAX_PPM = 1000000
describe('Curation:Config', () => {
let me: Account
let governor: Account
let fixture: NetworkFixture
let curation: Curation
before(async function () {
;[me, governor] = await getAccounts()
fixture = new NetworkFixture()
;({ curation } = await fixture.load(governor.signer))
})
beforeEach(async function () {
await fixture.setUp()
})
afterEach(async function () {
await fixture.tearDown()
})
describe('defaultReserveRatio', function () {
it('should set `defaultReserveRatio`', async function () {
// Set right in the constructor
expect(await curation.defaultReserveRatio()).eq(defaults.curation.reserveRatio)
// Can set if allowed
const newValue = toBN('100')
await curation.connect(governor.signer).setDefaultReserveRatio(newValue)
expect(await curation.defaultReserveRatio()).eq(newValue)
})
it('reject set `defaultReserveRatio` if out of bounds', async function () {
const tx1 = curation.connect(governor.signer).setDefaultReserveRatio(0)
await expect(tx1).revertedWith('Default reserve ratio must be > 0')
const tx2 = curation.connect(governor.signer).setDefaultReserveRatio(MAX_PPM + 1)
await expect(tx2).revertedWith('Default reserve ratio cannot be higher than MAX_PPM')
})
it('reject set `defaultReserveRatio` if not allowed', async function () {
const tx = curation.connect(me.signer).setDefaultReserveRatio(defaults.curation.reserveRatio)
await expect(tx).revertedWith('Only Controller governor')
})
})
describe('minimumCurationDeposit', function () {
it('should set `minimumCurationDeposit`', async function () {
// Set right in the constructor
expect(await curation.minimumCurationDeposit()).eq(defaults.curation.minimumCurationDeposit)
// Can set if allowed
const newValue = toBN('100')
await curation.connect(governor.signer).setMinimumCurationDeposit(newValue)
expect(await curation.minimumCurationDeposit()).eq(newValue)
})
it('reject set `minimumCurationDeposit` if out of bounds', async function () {
const tx = curation.connect(governor.signer).setMinimumCurationDeposit(0)
await expect(tx).revertedWith('Minimum curation deposit cannot be 0')
})
it('reject set `minimumCurationDeposit` if not allowed', async function () {
const tx = curation
.connect(me.signer)
.setMinimumCurationDeposit(defaults.curation.minimumCurationDeposit)
await expect(tx).revertedWith('Only Controller governor')
})
it('should get `minimumCurationDeposit`', async function () {
expect(await curation.minimumCurationDeposit()).eq(defaults.curation.minimumCurationDeposit)
})
})
describe('curationTaxPercentage', function () {
it('should set `curationTaxPercentage`', async function () {
const curationTaxPercentage = defaults.curation.curationTaxPercentage
// Set new value
await curation.connect(governor.signer).setCurationTaxPercentage(0)
await curation.connect(governor.signer).setCurationTaxPercentage(curationTaxPercentage)
})
it('reject set `curationTaxPercentage` if out of bounds', async function () {
const tx = curation.connect(governor.signer).setCurationTaxPercentage(MAX_PPM + 1)
await expect(tx).revertedWith('Curation tax percentage must be below or equal to MAX_PPM')
})
it('reject set `curationTaxPercentage` if not allowed', async function () {
const tx = curation.connect(me.signer).setCurationTaxPercentage(0)
await expect(tx).revertedWith('Only Controller governor')
})
})
describe('curationTokenMaster', function () {
it('should set `curationTokenMaster`', async function () {
const newCurationTokenMaster = curation.address
await curation.connect(governor.signer).setCurationTokenMaster(newCurationTokenMaster)
})
it('reject set `curationTokenMaster` to empty value', async function () {
const newCurationTokenMaster = AddressZero
const tx = curation.connect(governor.signer).setCurationTokenMaster(newCurationTokenMaster)
await expect(tx).revertedWith('Token master must be non-empty')
})
it('reject set `curationTokenMaster` to non-contract', async function () {
const newCurationTokenMaster = randomAddress()
const tx = curation.connect(governor.signer).setCurationTokenMaster(newCurationTokenMaster)
await expect(tx).revertedWith('Token master must be a contract')
})
it('reject set `curationTokenMaster` if not allowed', async function () {
const newCurationTokenMaster = curation.address
const tx = curation.connect(me.signer).setCurationTokenMaster(newCurationTokenMaster)
await expect(tx).revertedWith('Only Controller governor')
})
})
})