@@ -190,12 +190,14 @@ fn test_coinbase_moving_prices() {
190
190
SubnetAlphaIn :: < Test > :: insert ( netuid, 1_000_000 ) ;
191
191
SubnetMechanism :: < Test > :: insert ( netuid, 1 ) ;
192
192
SubnetMovingPrice :: < Test > :: insert ( netuid, I96F32 :: from_num ( 1 ) ) ;
193
+ NetworkRegisteredAt :: < Test > :: insert ( netuid, 1 ) ;
194
+
193
195
// Updating the moving price keeps it the same.
194
196
assert_eq ! (
195
197
SubtensorModule :: get_moving_alpha_price( netuid) ,
196
198
I96F32 :: from_num( 1 )
197
199
) ;
198
- // Skip some blocks so that EMA price is now slowed down
200
+ // Skip some blocks so that EMA price is not slowed down
199
201
System :: set_block_number ( 7_200_000 ) ;
200
202
201
203
SubtensorModule :: update_moving_price ( netuid) ;
@@ -209,21 +211,23 @@ fn test_coinbase_moving_prices() {
209
211
SubnetMovingAlpha :: < Test > :: set ( I96F32 :: from_num ( 1.0 ) ) ;
210
212
// Run moving 1 times.
211
213
SubtensorModule :: update_moving_price ( netuid) ;
212
- // Assert price is == 100% of the real price.
213
- assert ! ( I96F32 :: from_num( 1.0 ) - SubtensorModule :: get_moving_alpha_price( netuid) < 0.001 ) ;
214
+ // Assert price is ~ 100% of the real price.
215
+ assert ! ( I96F32 :: from_num( 1.0 ) - SubtensorModule :: get_moving_alpha_price( netuid) < 0.05 ) ;
214
216
// Set price to zero.
215
217
SubnetMovingPrice :: < Test > :: insert ( netuid, I96F32 :: from_num ( 0 ) ) ;
216
218
SubnetMovingAlpha :: < Test > :: set ( I96F32 :: from_num ( 0.1 ) ) ;
217
- // Run moving 6 times.
218
- SubtensorModule :: update_moving_price ( netuid) ;
219
- SubtensorModule :: update_moving_price ( netuid) ;
220
- SubtensorModule :: update_moving_price ( netuid) ;
221
- SubtensorModule :: update_moving_price ( netuid) ;
222
- SubtensorModule :: update_moving_price ( netuid) ;
223
- SubtensorModule :: update_moving_price ( netuid) ;
219
+
220
+ // EMA price 14 days after registration
221
+ System :: set_block_number ( 7_200 * 14 ) ;
222
+
223
+ // Run moving 14 times.
224
+ for _ in 0 ..14 {
225
+ SubtensorModule :: update_moving_price ( netuid) ;
226
+ }
227
+
224
228
// Assert price is > 50% of the real price.
225
229
assert ! (
226
- ( I96F32 :: from_num( 0.468559 ) - SubtensorModule :: get_moving_alpha_price( netuid) ) . abs( )
230
+ ( I96F32 :: from_num( 0.512325 ) - SubtensorModule :: get_moving_alpha_price( netuid) ) . abs( )
227
231
< 0.001
228
232
) ;
229
233
} ) ;
@@ -269,7 +273,7 @@ fn test_update_moving_price_after_time() {
269
273
SubnetMovingPrice :: < Test > :: insert ( netuid, I96F32 :: from_num ( 0 ) ) ;
270
274
271
275
// Registered long time ago
272
- System :: set_block_number ( 7_200_500 ) ;
276
+ System :: set_block_number ( 72_000_500 ) ;
273
277
NetworkRegisteredAt :: < Test > :: insert ( netuid, 500 ) ;
274
278
275
279
SubtensorModule :: update_moving_price ( netuid) ;
0 commit comments