Skip to content

Commit

Permalink
chore: add 4 test coins (#6565)
Browse files Browse the repository at this point in the history
Description
---
Change protocol pre mine to include 4 utxos for testing
  • Loading branch information
SWvheerden authored Sep 16, 2024
1 parent d48a15c commit 8728c4e
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions base_layer/core/src/blocks/pre_mine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ pub struct UpfrontRelease {
pub percentage: u64,
/// The number of tokens it has to be divided into
pub number_of_tokens: u64,
/// This is a tuple of custom valued upfront tokens (Tari value, block_height)
pub custom_upfront_tokens: Vec<(u64, u64)>,
}

fn get_expected_payout_period_blocks(network: Network) -> u64 {
Expand Down Expand Up @@ -145,6 +147,8 @@ pub fn get_tokenomics_pre_mine_unlock_schedule(network: Network) -> UnlockSchedu
upfront_release: Some(UpfrontRelease {
percentage: 40,
number_of_tokens: 20,
// 129,600 = 720 (blocks per day) * 30 (days per month) * 6 (months)
custom_upfront_tokens: vec![(1, 0), (1, 0), (1, 129_600), (1, 129_600)],
}),
expected_payout_period_blocks: get_expected_payout_period_blocks(network),
}),
Expand Down Expand Up @@ -252,6 +256,16 @@ pub fn create_pre_mine_output_values(schedule: UnlockSchedule) -> Result<Vec<Pre
beneficiary: apportionment.beneficiary.clone(),
});
}
for (value, maturity) in upfront_release.custom_upfront_tokens {
let utxo_value = value * 1_000_000;
tokens_value -= utxo_value;
values_with_maturity.push(PreMineItem {
value: MicroMinotari::from(utxo_value),
maturity,
fail_safe_height: schedule.expected_payout_period_blocks,
beneficiary: apportionment.beneficiary.clone(),
});
}
let monthly_tokens = tokens_value / schedule.monthly_fraction_denominator;
let mut total_tokens = 0;
let mut maturity = 0;
Expand Down Expand Up @@ -560,7 +574,8 @@ mod test {
monthly_fraction_denominator: 48,
upfront_release: Some(UpfrontRelease {
percentage: 40,
number_of_tokens: 20
number_of_tokens: 20,
custom_upfront_tokens: vec![(1, 0), (1, 0), (1, 129_600), (1, 129_600)],
}),
expected_payout_period_blocks,
}),
Expand Down Expand Up @@ -671,13 +686,13 @@ mod test {
.filter(|item| item.beneficiary == "protocol" && item.maturity == 0)
.map(|item| item.value)
.sum::<MicroMinotari>();
assert_eq!(protocol_tokens_at_start, MicroMinotari::from(756_000_000 * 1_000_000));
assert_eq!(protocol_tokens_at_start, MicroMinotari::from(756_000_002 * 1_000_000));
let all_tokens_at_start = pre_mine_items
.iter()
.filter(|item| item.maturity == 0)
.map(|item| item.value)
.sum::<MicroMinotari>();
assert_eq!(all_tokens_at_start, MicroMinotari::from(756_000_000 * 1_000_000));
assert_eq!(all_tokens_at_start, MicroMinotari::from(756_000_002 * 1_000_000));
let community_tokens = pre_mine_items
.iter()
.filter(|item| item.beneficiary == "community")
Expand Down

0 comments on commit 8728c4e

Please sign in to comment.