Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb committed Aug 6, 2024
1 parent 3461ae5 commit 22b218e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 503 deletions.
10 changes: 10 additions & 0 deletions contracts/stake_rewards/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ impl StakingRewardsTrait for StakingRewards {
sender.require_auth();

let config = get_config(&env);
// only Staking contract which deployed this one can call this method
config.staking_contract.require_auth();

let mut distribution = get_distribution(&env, &config.reward_token);
let last_stake = stakes.stakes.last().unwrap();
Expand Down Expand Up @@ -182,6 +184,8 @@ impl StakingRewardsTrait for StakingRewards {
sender.require_auth();

let config = get_config(&env);
// only Staking contract which deployed this one can call this method
config.staking_contract.require_auth();

// check for rewards and withdraw them
let found_rewards: WithdrawableRewardResponse =
Expand Down Expand Up @@ -217,6 +221,8 @@ impl StakingRewardsTrait for StakingRewards {

fn distribute_rewards(env: Env, total_staked_amount: i128) {
let config = get_config(&env);
// only Staking contract which deployed this one can call this method
config.staking_contract.require_auth();

let calc_power_result = calc_power(
&config,
Expand Down Expand Up @@ -276,6 +282,8 @@ impl StakingRewardsTrait for StakingRewards {
fn withdraw_rewards(env: Env, sender: Address, stakes: BondingInfo) {
env.events().publish(("withdraw_rewards", "user"), &sender);
let config = get_config(&env);
// only Staking contract which deployed this one can call this method
config.staking_contract.require_auth();

// get distribution data for the given reward
let mut distribution = get_distribution(&env, &config.reward_token);
Expand Down Expand Up @@ -327,6 +335,8 @@ impl StakingRewardsTrait for StakingRewards {
admin.require_auth();

let config = get_config(&env);
// only Staking contract which deployed this one can call this method
config.staking_contract.require_auth();

// Load previous reward curve; it must exist if the distribution exists
// In case of first time funding, it will be a constant 0 curve
Expand Down
2 changes: 1 addition & 1 deletion contracts/stake_rewards/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mod bond;
mod distribution;
// mod distribution;
mod setup;
Loading

0 comments on commit 22b218e

Please sign in to comment.