@@ -3,6 +3,7 @@ use core::num::traits::Zero;
33use core :: num :: traits :: ops :: pow :: Pow ;
44use snforge_std :: {Token , TokenImpl , get_class_hash, start_cheat_block_number_global};
55use staking :: attestation :: attestation :: Attestation :: MIN_ATTESTATION_WINDOW ;
6+ use staking :: attestation :: interface :: IAttestationSafeDispatcherTrait ;
67use staking :: constants :: {ALPHA , ALPHA_DENOMINATOR , K , STRK_IN_FRIS , STRK_TOKEN_ADDRESS };
78use staking :: errors :: {GenericError , InternalError };
89use staking :: flow_test :: utils :: MainnetClassHashes :: {
@@ -7102,6 +7103,52 @@ pub(crate) impl GetStakersAfterUpgradeFlowImpl of FlowTrait<GetStakersAfterUpgra
71027103 }
71037104}
71047105
7106+ /// Flow:
7107+ /// Stake
7108+ /// Upgrade
7109+ /// Attempt attest (fail)
7110+ /// Advance epoch
7111+ /// Attempt attest - test rewards
7112+ #[derive(Drop , Copy )]
7113+ pub (crate ) struct AttestAfterUpgradeFlow {
7114+ pub (crate ) staker : Option <Staker >,
7115+ }
7116+ pub (crate ) impl AttestAfterUpgradeFlowImpl of FlowTrait <AttestAfterUpgradeFlow > {
7117+ fn setup_v2 (ref self : AttestAfterUpgradeFlow , ref system : SystemState ) {
7118+ let amount = system . staking. get_min_stake ();
7119+ let staker = system . new_staker (: amount );
7120+ system . stake (: staker , : amount , pool_enabled : false , commission : 200 );
7121+
7122+ system . set_staker_for_migration (staker_address : staker . staker. address);
7123+ self . staker = Option :: Some (staker );
7124+ }
7125+
7126+ #[feature(" safe_dispatcher" )]
7127+ fn test (self : AttestAfterUpgradeFlow , ref system : SystemState ) {
7128+ let staker = self . staker. unwrap ();
7129+ let attestation_safe = system . attestation. unwrap (). safe_dispatcher ();
7130+
7131+ cheat_caller_address_once (
7132+ contract_address : system . attestation. unwrap (). address,
7133+ caller_address : staker . operational. address,
7134+ );
7135+ let result = attestation_safe . attest (block_hash : Zero :: zero ());
7136+ assert_panic_with_error (: result , expected_error : " Index out of bounds" );
7137+
7138+ system . advance_epoch ();
7139+ system . advance_block_into_attestation_window (: staker );
7140+ system . attest (: staker );
7141+
7142+ let rewards = system . staker_claim_rewards (: staker );
7143+ let (expected_rewards , _ ) = calculate_staker_strk_rewards_v2 (
7144+ staker_info : system . staker_info_v1 (: staker ),
7145+ staking_contract : system . staking. address,
7146+ minting_curve_contract : system . minting_curve. address,
7147+ );
7148+ assert! (rewards == expected_rewards );
7149+ }
7150+ }
7151+
71057152/// Flow:
71067153/// Add tokens A and B
71077154/// Enable token B
0 commit comments