@@ -143,6 +143,11 @@ fn test_coinbase_tao_issuance_different_prices() {
143
143
} ) ;
144
144
}
145
145
146
+ // Test moving price updates with different alpha values.
147
+ // This test verifies that:
148
+ // - Moving price stays constant when alpha is 1.0
149
+ // - Moving price converges to real price at expected rate with alpha 0.1
150
+ // - Moving price updates correctly over multiple iterations
146
151
// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_coinbase_moving_prices --exact --show-output --nocapture
147
152
#[ test]
148
153
fn test_coinbase_moving_prices ( ) {
@@ -181,5 +186,66 @@ fn test_coinbase_moving_prices() {
181
186
} ) ;
182
187
}
183
188
189
+ // Test basic alpha issuance in coinbase mechanism.
190
+ // This test verifies that:
191
+ // - Alpha issuance is initialized to 0 for new subnets
192
+ // - Alpha issuance is split evenly between subnets during coinbase
193
+ // - Each subnet receives the expected fraction of total emission
194
+ // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_coinbase_alpha_issuance --exact --show-output --nocapture
195
+ #[ test]
196
+ fn test_coinbase_alpha_issuance_base ( ) {
197
+ new_test_ext ( 1 ) . execute_with ( || {
198
+ let netuid1: u16 = 1 ;
199
+ let netuid2: u16 = 2 ;
200
+ let emission: u64 = 1_000_000 ;
201
+ add_network ( netuid1, 1 , 0 ) ;
202
+ add_network ( netuid2, 1 , 0 ) ;
203
+ // Set up prices 1 and 1
204
+ SubnetTAO :: < Test > :: insert ( netuid1, 1_000_000 ) ;
205
+ SubnetAlphaIn :: < Test > :: insert ( netuid1, 1_000_000 ) ;
206
+ SubnetTAO :: < Test > :: insert ( netuid2, 1_000_000 ) ;
207
+ SubnetAlphaIn :: < Test > :: insert ( netuid2, 1_000_000 ) ;
208
+ // Check initial
209
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid1 ) , 0 ) ;
210
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid2 ) , 0 ) ;
211
+ SubtensorModule :: run_coinbase ( I96F32 :: from_num ( emission ) ) ;
212
+ // tao_in = 500_000
213
+ // alpha_in = 500_000/price = 500_000
214
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid1 ) , emission/2 ) ;
215
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid2 ) , emission/2 ) ;
216
+ } ) ;
217
+ }
218
+
219
+ // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_coinbase_alpha_issuance_different --exact --show-output --nocapture
220
+ #[ test]
221
+ fn test_coinbase_alpha_issuance_different ( ) {
222
+ new_test_ext ( 1 ) . execute_with ( || {
223
+ let netuid1: u16 = 1 ;
224
+ let netuid2: u16 = 2 ;
225
+ let emission: u64 = 1_000_000 ;
226
+ add_network ( netuid1, 1 , 0 ) ;
227
+ add_network ( netuid2, 1 , 0 ) ;
228
+ // Make subnets dynamic.
229
+ SubnetMechanism :: < Test > :: insert ( netuid1, 1 ) ;
230
+ SubnetMechanism :: < Test > :: insert ( netuid2, 1 ) ;
231
+ // Setup prices 1 and 1
232
+ let initial: u64 = 1_000_000 ;
233
+ SubnetTAO :: < Test > :: insert ( netuid1, initial) ;
234
+ SubnetAlphaIn :: < Test > :: insert ( netuid1, initial) ;
235
+ SubnetTAO :: < Test > :: insert ( netuid2, initial) ;
236
+ SubnetAlphaIn :: < Test > :: insert ( netuid2, initial) ;
237
+ // Set subnet prices.
238
+ SubnetMovingPrice :: < Test > :: insert ( netuid1, I96F32 :: from_num ( 1 ) ) ;
239
+ SubnetMovingPrice :: < Test > :: insert ( netuid2, I96F32 :: from_num ( 2 ) ) ;
240
+ // Run coinbase
241
+ SubtensorModule :: run_coinbase ( I96F32 :: from_num ( emission ) ) ;
242
+ // tao_in = 333_333
243
+ // alpha_in = 333_333/price = 333_333 + initial
244
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid1 ) , initial + emission/3 ) ;
245
+ // tao_in = 666_666
246
+ // alpha_in = 666_666/price = 666_666 + initial
247
+ assert_eq ! ( SubnetAlphaIn :: <Test >:: get( netuid2 ) , initial + emission/3 + emission/3 ) ;
248
+ } ) ;
249
+ }
184
250
185
251
0 commit comments