@@ -136,63 +136,4 @@ describe('Mempool Backend Config', () => {
136
136
expect ( config . EXTERNAL_DATA_SERVER ) . toStrictEqual ( fixture . EXTERNAL_DATA_SERVER ) ;
137
137
} ) ;
138
138
} ) ;
139
-
140
- test ( 'should calculate Difficulty Adjustments properly' , ( ) => {
141
- jest . isolateModules ( ( ) => {
142
- const { calcDifficultyAdjustment } = jest . requireActual ( '../api/difficulty-adjustment' ) ;
143
- const dt = dtString => Math . floor ( new Date ( dtString ) . getTime ( ) / 1000 ) ;
144
- const vectors = [
145
- [ // Vector 1
146
- [ // Inputs
147
- dt ( '2022-08-18T11:07:00.000Z' ) , // Last DA time (in seconds)
148
- dt ( '2022-08-19T14:03:53.000Z' ) , // Current time (now) (in seconds)
149
- 750134 , // Current block height
150
- 0.6280047707459726 , // Previous retarget % (Passed through)
151
- 'mainnet' , // Network (if testnet, next value is non-zero)
152
- 0 , // If not testnet, not used
153
- ] ,
154
- { // Expected Result
155
- progressPercent : 9.027777777777777 ,
156
- difficultyChange : 12.562233927411782 ,
157
- estimatedRetargetDate : 1661895424692 ,
158
- remainingBlocks : 1834 ,
159
- remainingTime : 977591692 ,
160
- previousRetarget : 0.6280047707459726 ,
161
- nextRetargetHeight : 751968 ,
162
- timeAvg : 533038 ,
163
- timeOffset : 0 ,
164
- } ,
165
- ] ,
166
- [ // Vector 2 (testnet)
167
- [ // Inputs
168
- dt ( '2022-08-18T11:07:00.000Z' ) , // Last DA time (in seconds)
169
- dt ( '2022-08-19T14:03:53.000Z' ) , // Current time (now) (in seconds)
170
- 750134 , // Current block height
171
- 0.6280047707459726 , // Previous retarget % (Passed through)
172
- 'testnet' , // Network
173
- dt ( '2022-08-19T13:52:46.000Z' ) , // Latest block timestamp in seconds
174
- ] ,
175
- { // Expected Result is same other than timeOffset
176
- progressPercent : 9.027777777777777 ,
177
- difficultyChange : 12.562233927411782 ,
178
- estimatedRetargetDate : 1661895424692 ,
179
- remainingBlocks : 1834 ,
180
- remainingTime : 977591692 ,
181
- previousRetarget : 0.6280047707459726 ,
182
- nextRetargetHeight : 751968 ,
183
- timeAvg : 533038 ,
184
- timeOffset : - 667000 , // 11 min 7 seconds since last block (testnet only)
185
- // If we add time avg to abs(timeOffset) it makes exactly 1200000 ms, or 20 minutes
186
- } ,
187
- ] ,
188
- ] as [ [ number , number , number , number , string , number ] , any ] [ ] ;
189
-
190
- for ( const vector of vectors ) {
191
- const result = calcDifficultyAdjustment ( ...vector [ 0 ] ) ;
192
- // previousRetarget is passed through untouched
193
- expect ( result . previousRetarget ) . toStrictEqual ( vector [ 0 ] [ 3 ] ) ;
194
- expect ( result ) . toStrictEqual ( vector [ 1 ] ) ;
195
- }
196
- } ) ;
197
- } ) ;
198
139
} ) ;
0 commit comments