|
2 | 2 | use super::mock::*;
|
3 | 3 |
|
4 | 4 | use crate::*;
|
| 5 | +use alloc::collections::BTreeMap; |
5 | 6 | use approx::assert_abs_diff_eq;
|
6 | 7 | use frame_support::assert_ok;
|
7 | 8 | use sp_core::U256;
|
@@ -1439,3 +1440,51 @@ fn test_get_root_children_drain_with_half_take() {
|
1439 | 1440 | // );
|
1440 | 1441 | // });
|
1441 | 1442 | // }
|
| 1443 | + |
| 1444 | +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_incentive_to_subnet_owner_is_burned --exact --show-output --nocapture |
| 1445 | +#[test] |
| 1446 | +fn test_incentive_to_subnet_owner_is_burned() { |
| 1447 | + new_test_ext(1).execute_with(|| { |
| 1448 | + let subnet_owner_ck = U256::from(0); |
| 1449 | + let subnet_owner_hk = U256::from(1); |
| 1450 | + |
| 1451 | + let other_ck = U256::from(2); |
| 1452 | + let other_hk = U256::from(3); |
| 1453 | + |
| 1454 | + let netuid = add_dynamic_network(&subnet_owner_hk, &subnet_owner_ck); |
| 1455 | + |
| 1456 | + let pending_tao: u64 = 1_000_000_000; |
| 1457 | + let owner_cut: u64 = 0; |
| 1458 | + let mut incentives: BTreeMap<U256, u64> = BTreeMap::new(); |
| 1459 | + let mut dividends: BTreeMap<U256, I96F32> = BTreeMap::new(); |
| 1460 | + |
| 1461 | + // Give incentive to other_hk |
| 1462 | + incentives.insert(other_hk, 10_000_000); |
| 1463 | + |
| 1464 | + // Give incentives to subnet_owner_hk |
| 1465 | + incentives.insert(subnet_owner_hk, 10_000_000); |
| 1466 | + |
| 1467 | + // Verify stake before |
| 1468 | + let subnet_owner_stake_before = |
| 1469 | + SubtensorModule::get_stake_for_hotkey_on_subnet(&subnet_owner_hk, netuid); |
| 1470 | + assert_eq!(subnet_owner_stake_before, 0); |
| 1471 | + let other_stake_before = SubtensorModule::get_stake_for_hotkey_on_subnet(&other_hk, netuid); |
| 1472 | + assert_eq!(other_stake_before, 0); |
| 1473 | + |
| 1474 | + // Distribute dividends and incentives |
| 1475 | + SubtensorModule::distribute_dividends_and_incentives( |
| 1476 | + netuid, |
| 1477 | + pending_tao, |
| 1478 | + owner_cut, |
| 1479 | + incentives, |
| 1480 | + dividends, |
| 1481 | + ); |
| 1482 | + |
| 1483 | + // Verify stake after |
| 1484 | + let subnet_owner_stake_after = |
| 1485 | + SubtensorModule::get_stake_for_hotkey_on_subnet(&subnet_owner_hk, netuid); |
| 1486 | + assert_eq!(subnet_owner_stake_after, 0); |
| 1487 | + let other_stake_after = SubtensorModule::get_stake_for_hotkey_on_subnet(&other_hk, netuid); |
| 1488 | + assert!(other_stake_after > 0); |
| 1489 | + }); |
| 1490 | +} |
0 commit comments