@@ -1976,117 +1976,6 @@ mod tests {
19761976 check_flag ( StakeFlags :: empty ( ) , 0 ) ;
19771977 }
19781978
1979- #[ cfg( test) ]
1980- #[ allow( deprecated) ]
1981- mod delegation_prop_tests {
1982- use {
1983- super :: * ,
1984- crate :: {
1985- stake_history:: { StakeHistory , StakeHistoryEntry } ,
1986- ulp:: max_ulp_tolerance,
1987- } ,
1988- proptest:: prelude:: * ,
1989- solana_pubkey:: Pubkey ,
1990- } ;
1991-
1992- prop_compose ! {
1993- fn arbitrary_delegation( ) (
1994- // This tests is bounded to the range where `f64` can represent every integer exactly.
1995- // Beyond this, integer math and float math diverge considerably.
1996- // This case is covered in `warmup_cooldown_allowance.rs`.
1997- stake in 0u64 ..=( 1u64 << 53 ) - 1 ,
1998- activation_epoch in 0u64 ..=50 ,
1999- deactivation_offset in 0u64 ..=50 ,
2000- ) -> Delegation {
2001- let deactivation_epoch = activation_epoch. saturating_add( deactivation_offset) ;
2002-
2003- Delegation {
2004- voter_pubkey: Pubkey :: new_unique( ) ,
2005- stake,
2006- activation_epoch,
2007- deactivation_epoch,
2008- ..Delegation :: default ( )
2009- }
2010- }
2011- }
2012-
2013- prop_compose ! {
2014- fn arbitrary_stake_history( max_epoch: Epoch ) (
2015- entries in prop:: collection:: vec(
2016- (
2017- 0u64 ..=max_epoch,
2018- 0u64 ..=1_000_000_000_000 , // effective
2019- 0u64 ..=1_000_000_000_000 , // activating
2020- 0u64 ..=1_000_000_000_000 , // deactivating
2021- ) ,
2022- 0 ..=( ( max_epoch + 1 ) as usize ) ,
2023- )
2024- ) -> StakeHistory {
2025- let mut history = StakeHistory :: default ( ) ;
2026- for ( epoch, effective, activating, deactivating) in entries {
2027- history. add(
2028- epoch,
2029- StakeHistoryEntry {
2030- effective,
2031- activating,
2032- deactivating,
2033- } ,
2034- ) ;
2035- }
2036- history
2037- }
2038- }
2039-
2040- proptest ! {
2041- #![ proptest_config( ProptestConfig :: with_cases( 10_000 ) ) ]
2042-
2043- #[ test]
2044- fn delegation_stake_matches_legacy_within_tolerance(
2045- delegation in arbitrary_delegation( ) ,
2046- target_epoch in 0u64 ..=50 ,
2047- new_rate_activation_epoch_option in prop:: option:: of( 0u64 ..=50 ) ,
2048- stake_history in arbitrary_stake_history( 50 ) ,
2049- ) {
2050- let new_stake = delegation. stake_v2(
2051- target_epoch,
2052- & stake_history,
2053- new_rate_activation_epoch_option,
2054- ) ;
2055- let legacy_stake = delegation. stake(
2056- target_epoch,
2057- & stake_history,
2058- new_rate_activation_epoch_option,
2059- ) ;
2060-
2061- // neither path should ever exceed the delegated amount.
2062- prop_assert!( new_stake <= delegation. stake) ;
2063- prop_assert!( legacy_stake <= delegation. stake) ;
2064-
2065- // If the delegation has no stake, both must be zero.
2066- if delegation. stake == 0 {
2067- prop_assert_eq!( new_stake, 0 ) ;
2068- prop_assert_eq!( legacy_stake, 0 ) ;
2069- } else {
2070- // Compare with a ULP-based tolerance to account for float vs integer math.
2071- let diff = new_stake. abs_diff( legacy_stake) ;
2072- let tolerance = max_ulp_tolerance( new_stake, legacy_stake) ;
2073-
2074- prop_assert!(
2075- diff <= tolerance,
2076- "stake mismatch: new={}, legacy={}, diff={}, tol={}, delegation={:?}, target_epoch={}, new_rate_activation_epoch_option={:?}" ,
2077- new_stake,
2078- legacy_stake,
2079- diff,
2080- tolerance,
2081- delegation,
2082- target_epoch,
2083- new_rate_activation_epoch_option,
2084- ) ;
2085- }
2086- }
2087- }
2088- }
2089-
20901979 mod deprecated {
20911980 use {
20921981 super :: * ,
@@ -2237,7 +2126,7 @@ mod tests {
22372126
22382127 let serialized_data = borsh:: to_vec ( & legacy_delegation) . unwrap ( ) ;
22392128
2240- // Deserialize into the NEW Delegation struct
2129+ // Deserialize into the new ` Delegation` struct
22412130 let new_delegation = Delegation :: try_from_slice ( & serialized_data) . unwrap ( ) ;
22422131
22432132 // Assert that the fields are identical
0 commit comments