@@ -567,22 +567,23 @@ contract('UFragmentsPolicy:Rebase', async function (accounts) {
567567} ) ;
568568
569569contract ( 'UFragmentsPolicy:Rebase' , async function ( accounts ) {
570- let rbTime , rbWindow , minRebaseTimeIntervalSec , now , prevRebaseTime , nextRebaseTime ,
571- timeToWait ;
570+ let rbTime , rbWindow , minRebaseTimeIntervalSec , now , prevRebaseTime , nextRebaseWindowOpenTime ,
571+ timeToWait , lastRebaseTimestamp ;
572572
573573 beforeEach ( 'setup UFragmentsPolicy contract' , async function ( ) {
574574 await setupContracts ( ) ;
575+ await uFragmentsPolicy . setRebaseTimingParameters ( 86400 , 72000 , 900 ) ;
575576 rbTime = await uFragmentsPolicy . rebaseWindowOffsetSec . call ( ) ;
576577 rbWindow = await uFragmentsPolicy . rebaseWindowLengthSec . call ( ) ;
577578 minRebaseTimeIntervalSec = await uFragmentsPolicy . minRebaseTimeIntervalSec . call ( ) ;
578579 now = new BigNumber ( await chain . currentTime ( ) ) ;
579580 prevRebaseTime = now . minus ( now . mod ( minRebaseTimeIntervalSec ) ) . plus ( rbTime ) ;
580- nextRebaseTime = prevRebaseTime . plus ( minRebaseTimeIntervalSec ) ;
581+ nextRebaseWindowOpenTime = prevRebaseTime . plus ( minRebaseTimeIntervalSec ) ;
581582 } ) ;
582583
583584 describe ( 'when its 5s after the rebase window closes' , function ( ) {
584585 it ( 'should fail' , async function ( ) {
585- timeToWait = nextRebaseTime . minus ( now ) . plus ( rbWindow ) . plus ( 5 ) ;
586+ timeToWait = nextRebaseWindowOpenTime . minus ( now ) . plus ( rbWindow ) . plus ( 5 ) ;
586587 await chain . waitForSomeTime ( timeToWait . toNumber ( ) ) ;
587588 await mockExternalData ( INITIAL_RATE , INITIAL_CPI , 1000 ) ;
588589 expect ( await uFragmentsPolicy . inRebaseWindow . call ( ) ) . to . be . false ;
@@ -594,7 +595,7 @@ contract('UFragmentsPolicy:Rebase', async function (accounts) {
594595
595596 describe ( 'when its 5s before the rebase window opens' , function ( ) {
596597 it ( 'should fail' , async function ( ) {
597- timeToWait = nextRebaseTime . minus ( now ) . minus ( 5 ) ;
598+ timeToWait = nextRebaseWindowOpenTime . minus ( now ) . minus ( 5 ) ;
598599 await chain . waitForSomeTime ( timeToWait . toNumber ( ) ) ;
599600 await mockExternalData ( INITIAL_RATE , INITIAL_CPI , 1000 ) ;
600601 expect ( await uFragmentsPolicy . inRebaseWindow . call ( ) ) . to . be . false ;
@@ -606,25 +607,29 @@ contract('UFragmentsPolicy:Rebase', async function (accounts) {
606607
607608 describe ( 'when its 5s after the rebase window opens' , function ( ) {
608609 it ( 'should NOT fail' , async function ( ) {
609- timeToWait = nextRebaseTime . minus ( now ) . plus ( 5 ) ;
610+ timeToWait = nextRebaseWindowOpenTime . minus ( now ) . plus ( 5 ) ;
610611 await chain . waitForSomeTime ( timeToWait . toNumber ( ) ) ;
611612 await mockExternalData ( INITIAL_RATE , INITIAL_CPI , 1000 ) ;
612613 expect ( await uFragmentsPolicy . inRebaseWindow . call ( ) ) . to . be . true ;
613614 expect (
614615 await chain . isEthException ( uFragmentsPolicy . rebase ( ) )
615616 ) . to . be . false ;
617+ lastRebaseTimestamp = await uFragmentsPolicy . lastRebaseTimestampSec . call ( ) ;
618+ expect ( lastRebaseTimestamp . eq ( nextRebaseWindowOpenTime ) ) . to . be . true ;
616619 } ) ;
617620 } ) ;
618621
619622 describe ( 'when its 5s before the rebase window closes' , function ( ) {
620623 it ( 'should NOT fail' , async function ( ) {
621- timeToWait = nextRebaseTime . minus ( now ) . plus ( rbWindow ) . minus ( 5 ) ;
624+ timeToWait = nextRebaseWindowOpenTime . minus ( now ) . plus ( rbWindow ) . minus ( 5 ) ;
622625 await chain . waitForSomeTime ( timeToWait . toNumber ( ) ) ;
623626 await mockExternalData ( INITIAL_RATE , INITIAL_CPI , 1000 ) ;
624627 expect ( await uFragmentsPolicy . inRebaseWindow . call ( ) ) . to . be . true ;
625628 expect (
626629 await chain . isEthException ( uFragmentsPolicy . rebase ( ) )
627630 ) . to . be . false ;
631+ lastRebaseTimestamp = await uFragmentsPolicy . lastRebaseTimestampSec . call ( ) ;
632+ expect ( lastRebaseTimestamp . eq ( nextRebaseWindowOpenTime ) ) . to . be . true ;
628633 } ) ;
629634 } ) ;
630635} ) ;
0 commit comments