Newer
Older
prefix + 19,
prefix + 21,
prefix + 23,
);
System::set_block_number(1);
Session::check_rotate_session(System::block_number());
// For manual inspection
println!("Validators are {:?}", Session::validators());
println!("Validators are {:#?}",
Session::validators()
.iter()
.map(|v| (v.clone(), Staking::stakers(v+1)))
.collect::<Vec<(u64, Exposure<u64, u64>)>>()
);
// Each exposure => total == own + sum(others)
// aside from some error, stake must be divided correctly
let individual_expo_sum: u128 = Session::validators()
.iter()
.map(|v| Staking::stakers(v+1))
.fold(0u128, |s, v| if v.others.len() > 0 { s + v.others[0].value as u128 } else { s });
990000000000000000 - individual_expo_sum < 100,
format!(
"Nominator stake = {} / SUM(individual expo) = {} / diff = {}",
990000000000000000u64,
individual_expo_sum,
990000000000000000 - individual_expo_sum
)
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
#[test]
fn phragmen_large_scale_test_2() {
with_externalities(&mut ExtBuilder::default()
.nominate(false)
.minimum_validator_count(1)
.validator_count(2)
.build(),
|| {
let _ = Staking::chill(Origin::signed(10));
let _ = Staking::chill(Origin::signed(20));
let nom_budget: u64 = 1_000_000_000_000_000_000;
let c_budget: u64 = 4_000_000;
bond_validator(2, c_budget as u64);
bond_validator(4, c_budget as u64);
bond_nominator(50, nom_budget, vec![3, 5]);
System::set_block_number(1);
Session::check_rotate_session(System::block_number());
// Each exposure => total == own + sum(others)
check_exposure_all();
assert_total_expo(3, nom_budget / 2 + c_budget);
assert_total_expo(5, nom_budget / 2 + c_budget);