@@ -2,6 +2,7 @@ const UFragmentsPolicy = artifacts.require('UFragmentsPolicy.sol');
22const MockUFragments = artifacts . require ( 'MockUFragments.sol' ) ;
33const MockOracle = artifacts . require ( 'MockOracle.sol' ) ;
44const RebaseCallerContract = artifacts . require ( 'RebaseCallerContract.sol' ) ;
5+ const ConstructorRebaseCallerContract = artifacts . require ( 'ConstructorRebaseCallerContract.sol' ) ;
56
67const encodeCall = require ( 'zos-lib/lib/helpers/encodeCall' ) . default ;
78const BigNumber = web3 . BigNumber ;
@@ -13,7 +14,7 @@ require('chai')
1314 . use ( require ( 'chai-bignumber' ) ( BigNumber ) )
1415 . should ( ) ;
1516
16- let uFragmentsPolicy , mockUFragments , mockMarketOracle , mockCpiOracle , rebaseCallerContract ;
17+ let uFragmentsPolicy , mockUFragments , mockMarketOracle , mockCpiOracle ;
1718let r , prevEpoch , prevTime ;
1819let deployer , user ;
1920
@@ -46,7 +47,6 @@ async function setupContracts () {
4647 } ) ;
4748 await uFragmentsPolicy . setMarketOracle ( mockMarketOracle . address ) ;
4849 await uFragmentsPolicy . setCpiOracle ( mockCpiOracle . address ) ;
49- rebaseCallerContract = await RebaseCallerContract . new ( uFragmentsPolicy . address ) ;
5050}
5151
5252async function setupContractsWithOpenRebaseWindow ( ) {
@@ -271,7 +271,7 @@ contract('UFragments:setRebaseTimingParameters:accessControl', function (account
271271} ) ;
272272
273273contract ( 'UFragmentsPolicy:Rebase:accessControl' , async function ( accounts ) {
274- before ( 'setup UFragmentsPolicy contract' , async function ( ) {
274+ beforeEach ( 'setup UFragmentsPolicy contract' , async function ( ) {
275275 await setupContractsWithOpenRebaseWindow ( ) ;
276276 await mockExternalData ( INITIAL_RATE_30P_MORE , INITIAL_CPI , 1000 , true ) ;
277277 await chain . waitForSomeTime ( 60 ) ;
@@ -286,9 +286,18 @@ contract('UFragmentsPolicy:Rebase:accessControl', async function (accounts) {
286286 } ) ;
287287
288288 describe ( 'when rebase called by a contract' , function ( ) {
289+ it ( 'should fail' , async function ( ) {
290+ const rebaseCallerContract = await RebaseCallerContract . new ( ) ;
291+ expect (
292+ await chain . isEthException ( rebaseCallerContract . callRebase ( uFragmentsPolicy . address ) )
293+ ) . to . be . true ;
294+ } ) ;
295+ } ) ;
296+
297+ describe ( 'when rebase called by a contract which is being constructed' , function ( ) {
289298 it ( 'should fail' , async function ( ) {
290299 expect (
291- await chain . isEthException ( rebaseCallerContract . callRebase ( ) )
300+ await chain . isEthException ( ConstructorRebaseCallerContract . new ( uFragmentsPolicy . address ) )
292301 ) . to . be . true ;
293302 } ) ;
294303 } ) ;
0 commit comments