@@ -152,6 +152,40 @@ contract('Market validation Mechanism', function(accounts) {
152
152
assert . equal ( 0 , await mvm . getCurrentPeriodIndex . call ( ) ) ;
153
153
} ) ;
154
154
155
+ it ( 'can call getAccumulatedDistributionPercentage only before it has finished' , async function ( ) {
156
+ const token = await LifToken . new ( { from : accounts [ 0 ] } ) ,
157
+ start = latestTime ( ) + 10 ,
158
+ mvm = await LifMarketValidationMechanism . new ( token . address , start ,
159
+ 100 , 24 , accounts [ 1 ] , { from : accounts [ 0 ] } ) ;
160
+
161
+ await mvm . calculateDistributionPeriods ( ) ;
162
+
163
+ try {
164
+ await mvm . getAccumulatedDistributionPercentage . call ( ) ;
165
+ assert ( false , 'should have thrown because we are before MVM start timestamp' ) ;
166
+ } catch ( e ) {
167
+ assert ( help . isInvalidOpcodeEx ( e ) ) ;
168
+ }
169
+
170
+ await increaseTimeTestRPCTo ( start ) ;
171
+ assert . equal ( 0 , parseInt ( await mvm . getAccumulatedDistributionPercentage . call ( ) ) ) ;
172
+
173
+ await increaseTimeTestRPCTo ( start + 100 ) ;
174
+ // 18 comes from distributionDeltas in next test, also 99 in next assertion
175
+ assert . equal ( 18 , parseInt ( await mvm . getAccumulatedDistributionPercentage . call ( ) ) ) ;
176
+
177
+ await increaseTimeTestRPCTo ( start + 200 ) ;
178
+ assert . equal ( 18 + 99 , parseInt ( await mvm . getAccumulatedDistributionPercentage . call ( ) ) ) ;
179
+
180
+ await increaseTimeTestRPCTo ( start + 100 * 24 ) ;
181
+ try {
182
+ await mvm . getAccumulatedDistributionPercentage . call ( ) ;
183
+ assert ( false , 'should have thrown because we are past the MVM lifetime' ) ;
184
+ } catch ( e ) {
185
+ assert ( help . isInvalidOpcodeEx ( e ) ) ;
186
+ }
187
+ } ) ;
188
+
155
189
it ( 'Create 24 months MM' , async function ( ) {
156
190
const mmInitialBalance = 20000000 ;
157
191
const totalTokenSupply = 100 ;
0 commit comments