@@ -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 :: {
@@ -7197,6 +7198,55 @@ pub(crate) impl GetStakersAfterUpgradeFlowImpl of FlowTrait<GetStakersAfterUpgra
71977198 }
71987199}
71997200
7201+ /// Flow:
7202+ /// Stake
7203+ /// Upgrade
7204+ /// Attempt attest - fail
7205+ /// Advance epoch
7206+ /// Attest - test rewards
7207+ #[derive(Drop , Copy )]
7208+ pub (crate ) struct AttestAfterUpgradeFlow {
7209+ pub (crate ) staker : Option <Staker >,
7210+ }
7211+ pub (crate ) impl AttestAfterUpgradeFlowImpl of FlowTrait <AttestAfterUpgradeFlow > {
7212+ fn setup_v2 (ref self : AttestAfterUpgradeFlow , ref system : SystemState ) {
7213+ let amount = system . staking. get_min_stake ();
7214+ let staker = system . new_staker (: amount );
7215+ system . stake (: staker , : amount , pool_enabled : false , commission : 200 );
7216+
7217+ system . set_staker_for_migration (staker_address : staker . staker. address);
7218+ self . staker = Option :: Some (staker );
7219+ }
7220+
7221+ #[feature(" safe_dispatcher" )]
7222+ fn test (self : AttestAfterUpgradeFlow , ref system : SystemState ) {
7223+ let staker = self . staker. unwrap ();
7224+ let attestation_safe = system . attestation. unwrap (). safe_dispatcher ();
7225+
7226+ cheat_caller_address_once (
7227+ contract_address : system . attestation. unwrap (). address,
7228+ caller_address : staker . operational. address,
7229+ );
7230+ let result = attestation_safe . attest (block_hash : Zero :: zero ());
7231+ // This error is due to the staker trace having no entry for the previous epoch.
7232+ // Had the staker been initialized in V3, the error would have been
7233+ // ATTEST_WITH_ZERO_BALANCE.
7234+ assert_panic_with_error (: result , expected_error : " Index out of bounds" );
7235+
7236+ system . advance_epoch ();
7237+ system . advance_block_into_attestation_window (: staker );
7238+ system . attest (: staker );
7239+
7240+ let rewards = system . staker_claim_rewards (: staker );
7241+ let (expected_rewards , _ ) = calculate_staker_strk_rewards_v2 (
7242+ staker_info : system . staker_info_v1 (: staker ),
7243+ staking_contract : system . staking. address,
7244+ minting_curve_contract : system . minting_curve. address,
7245+ );
7246+ assert! (rewards == expected_rewards );
7247+ }
7248+ }
7249+
72007250/// Flow:
72017251/// Add tokens A and B
72027252/// Enable token B
0 commit comments