@@ -91,11 +91,55 @@ describe('MedianOracle:pushReport', async function () {
9191 it ( 'should only push from authorized source' , async function ( ) {
9292 await expect ( oracle . connect ( A ) . pushReport ( payload ) ) . to . be . reverted
9393 } )
94- it ( 'should fail if reportDelaySec did not pass since the previous push' , async function ( ) {
94+
95+ it ( 'should pass if reportDelaySec did not pass since the previous push, but previous report non-existent' , async function ( ) {
96+ await oracle . addProvider ( await A . getAddress ( ) )
97+ await oracle . connect ( A ) . pushReport ( payload )
98+ await oracle . connect ( A ) . pushReport ( payload )
99+ } )
100+
101+ it ( 'should pass if reportDelaySec did pass since the previous push, and previous report non-existent' , async function ( ) {
95102 await oracle . addProvider ( await A . getAddress ( ) )
96103 await oracle . connect ( A ) . pushReport ( payload )
104+ await increaseTime ( 20 )
105+ await oracle . connect ( A ) . pushReport ( payload )
106+ } )
107+
108+ it ( 'should pass if reportDelaySec did pass since the previous push, but previous report expired' , async function ( ) {
109+ await oracle . addProvider ( await A . getAddress ( ) )
110+ await oracle . connect ( A ) . pushReport ( payload )
111+ await increaseTime ( 70 )
112+ await oracle . connect ( A ) . pushReport ( payload )
113+ await oracle . connect ( A ) . pushReport ( payload )
114+ } )
115+
116+ it ( 'should pass if reportDelaySec did pass since the previous push, and previous report expired' , async function ( ) {
117+ await oracle . addProvider ( await A . getAddress ( ) )
118+ await oracle . connect ( A ) . pushReport ( payload )
119+ await increaseTime ( 70 )
120+ await oracle . connect ( A ) . pushReport ( payload )
121+ await increaseTime ( 20 )
122+ await oracle . connect ( A ) . pushReport ( payload )
123+ } )
124+
125+ it ( 'should fail if reportDelaySec did not pass since the previous push, and previous report not expired' , async function ( ) {
126+ await oracle . addProvider ( await A . getAddress ( ) )
127+ await oracle . connect ( A ) . pushReport ( payload )
128+ await increaseTime ( 20 )
129+ await oracle . connect ( A ) . pushReport ( payload )
130+ await expect ( oracle . connect ( A ) . pushReport ( payload ) ) . to . be . reverted
131+ } )
132+
133+ it ( 'should pass if reportDelaySec did pass since the previous push, and previous report not expired' , async function ( ) {
134+ await oracle . addProvider ( await A . getAddress ( ) )
135+ await oracle . connect ( A ) . pushReport ( payload )
136+ await increaseTime ( 20 )
137+ await oracle . connect ( A ) . pushReport ( payload )
138+ await increaseTime ( 20 )
139+ await oracle . connect ( A ) . pushReport ( payload )
97140 await expect ( oracle . connect ( A ) . pushReport ( payload ) ) . to . be . reverted
98141 } )
142+
99143 it ( 'should emit ProviderReportPushed message' , async function ( ) {
100144 oracle . addProvider ( await A . getAddress ( ) )
101145 const tx = await oracle . connect ( A ) . pushReport ( payload )
0 commit comments