@@ -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 , STRK_IN_FRIS , STRK_TOKEN_ADDRESS };
78use staking :: errors :: {GenericError , InternalError };
89use staking :: flow_test :: utils :: MainnetClassHashes :: {
@@ -7064,6 +7065,52 @@ pub(crate) impl GetStakersAfterUpgradeFlowImpl of FlowTrait<GetStakersAfterUpgra
70647065 }
70657066}
70667067
7068+ /// Flow:
7069+ /// Stake
7070+ /// Upgrade
7071+ /// Attempt attest (fail)
7072+ /// Advance epoch
7073+ /// Attempt attest - test rewards
7074+ #[derive(Drop , Copy )]
7075+ pub (crate ) struct AttestAfterUpgradeFlow {
7076+ pub (crate ) staker : Option <Staker >,
7077+ }
7078+ pub (crate ) impl AttestAfterUpgradeFlowImpl of FlowTrait <AttestAfterUpgradeFlow > {
7079+ fn setup_v2 (ref self : AttestAfterUpgradeFlow , ref system : SystemState ) {
7080+ let amount = system . staking. get_min_stake ();
7081+ let staker = system . new_staker (: amount );
7082+ system . stake (: staker , : amount , pool_enabled : false , commission : 200 );
7083+
7084+ system . set_staker_for_migration (staker_address : staker . staker. address);
7085+ self . staker = Option :: Some (staker );
7086+ }
7087+
7088+ #[feature(" safe_dispatcher" )]
7089+ fn test (self : AttestAfterUpgradeFlow , ref system : SystemState ) {
7090+ let staker = self . staker. unwrap ();
7091+ let attestation_safe = system . attestation. unwrap (). safe_dispatcher ();
7092+
7093+ cheat_caller_address_once (
7094+ contract_address : system . attestation. unwrap (). address,
7095+ caller_address : staker . operational. address,
7096+ );
7097+ let result = attestation_safe . attest (block_hash : Zero :: zero ());
7098+ assert_panic_with_error (: result , expected_error : " Index out of bounds" );
7099+
7100+ system . advance_epoch ();
7101+ system . advance_block_into_attestation_window (: staker );
7102+ system . attest (: staker );
7103+
7104+ let rewards = system . staker_claim_rewards (: staker );
7105+ let (expected_rewards , _ ) = calculate_staker_strk_rewards_v2 (
7106+ staker_info : system . staker_info_v1 (: staker ),
7107+ staking_contract : system . staking. address,
7108+ minting_curve_contract : system . minting_curve. address,
7109+ );
7110+ assert! (rewards == expected_rewards );
7111+ }
7112+ }
7113+
70677114/// Flow:
70687115/// Add tokens A and B
70697116/// Enable token B
0 commit comments