Skip to content

Commit

Permalink
Merge pull request #373 from securesecrets/itsHaseebSaeed-LiquidityBook
Browse files Browse the repository at this point in the history
Added admin auth
  • Loading branch information
itsHaseebSaeed authored Nov 3, 2023
2 parents 3898b52 + 1406d6c commit f6213ed
Show file tree
Hide file tree
Showing 53 changed files with 1,169 additions and 724 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn end_reward_pool_after_end() {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -239,6 +240,7 @@ fn end_reward_pool_after_end() {
height: 1,
time: Timestamp::from_seconds(end_period.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// Claim rewards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn end_reward_pool_after_end() {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -239,6 +240,7 @@ fn end_reward_pool_after_end() {
height: 1,
time: Timestamp::from_seconds(end_period.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// End reward pool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn end_reward_pool_after_end() {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -267,6 +268,7 @@ fn end_reward_pool_after_end() {
height: 1,
time: Timestamp::from_seconds(end_period.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// End reward pool
Expand Down Expand Up @@ -357,6 +359,7 @@ fn end_reward_pool_after_end() {
height: 1,
time: Timestamp::from_seconds(second_reward_end.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// Check queries work
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn end_reward_pool_before_end_claimed() {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -240,6 +241,7 @@ fn end_reward_pool_before_end_claimed() {
height: 1,
time: Timestamp::from_seconds(mid_period.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// Claim rewards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn end_reward_pool_before_end_unclaimed() {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -240,6 +241,7 @@ fn end_reward_pool_before_end_unclaimed() {
height: 1,
time: Timestamp::from_seconds(mid_period.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// End reward pool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn end_reward_pool_before_start() {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down
5 changes: 5 additions & 0 deletions contracts/basic_staking/tests/multi_staker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn multi_staker_single_pool(
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -252,6 +253,7 @@ fn multi_staker_single_pool(
height: 1,
time: Timestamp::from_seconds(reward_start.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

for user in staking_users.iter() {
Expand Down Expand Up @@ -287,6 +289,7 @@ fn multi_staker_single_pool(
height: 2,
time: Timestamp::from_seconds((reward_start.u128() + reward_duration.u128() / 2) as u64),
chain_id: "chain_id".to_string(),
random: None,
});

for (user, reward) in staking_users
Expand Down Expand Up @@ -326,6 +329,7 @@ fn multi_staker_single_pool(
height: 3,
time: Timestamp::from_seconds(reward_end.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

for ((user, amount), reward) in staking_users
Expand Down Expand Up @@ -424,6 +428,7 @@ fn multi_staker_single_pool(
height: 10,
time: Timestamp::from_seconds((reward_end + unbond_period).u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

for ((user, stake_amount), reward) in staking_users
Expand Down
1 change: 1 addition & 0 deletions contracts/basic_staking/tests/non_admin_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn non_admin_access() {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down
5 changes: 5 additions & 0 deletions contracts/basic_staking/tests/non_stake_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn non_stake_rewards(
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -290,6 +291,7 @@ fn non_stake_rewards(
height: 1,
time: Timestamp::from_seconds(reward_start.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// No rewards should be pending
Expand Down Expand Up @@ -323,6 +325,7 @@ fn non_stake_rewards(
height: 2,
time: Timestamp::from_seconds((reward_start.u128() + reward_duration.u128() / 2) as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// Half-ish rewards should be pending
Expand Down Expand Up @@ -362,6 +365,7 @@ fn non_stake_rewards(
height: 3,
time: Timestamp::from_seconds(reward_end.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// All rewards should be pending
Expand Down Expand Up @@ -464,6 +468,7 @@ fn non_stake_rewards(
height: 10,
time: Timestamp::from_seconds((reward_end + unbond_period).u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

basic_staking::ExecuteMsg::Withdraw {
Expand Down
5 changes: 5 additions & 0 deletions contracts/basic_staking/tests/single_staker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn single_staker_single_pool(
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -293,6 +294,7 @@ fn single_staker_single_pool(
height: 1,
time: Timestamp::from_seconds(reward_start.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// No rewards should be pending
Expand Down Expand Up @@ -326,6 +328,7 @@ fn single_staker_single_pool(
height: 2,
time: Timestamp::from_seconds((reward_start.u128() + reward_duration.u128() / 2) as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// Half-ish rewards should be pending
Expand Down Expand Up @@ -365,6 +368,7 @@ fn single_staker_single_pool(
height: 3,
time: Timestamp::from_seconds(reward_end.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// All rewards should be pending
Expand Down Expand Up @@ -467,6 +471,7 @@ fn single_staker_single_pool(
height: 10,
time: Timestamp::from_seconds((reward_end + unbond_period).u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

basic_staking::ExecuteMsg::Withdraw {
Expand Down
5 changes: 5 additions & 0 deletions contracts/basic_staking/tests/single_staker_compounding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn single_staker_compounding(
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -241,6 +242,7 @@ fn single_staker_compounding(
height: 1,
time: Timestamp::from_seconds(reward_start.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// No rewards should be pending
Expand Down Expand Up @@ -274,6 +276,7 @@ fn single_staker_compounding(
height: 2,
time: Timestamp::from_seconds((reward_start.u128() + reward_duration.u128() / 2) as u64),
chain_id: "chain_id".to_string(),
random: None,
});

let expected_mid_rewards = reward_amount / Uint128::new(2);
Expand Down Expand Up @@ -379,6 +382,7 @@ fn single_staker_compounding(
height: 3,
time: Timestamp::from_seconds(reward_end.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

let current_rewards: Uint128;
Expand Down Expand Up @@ -486,6 +490,7 @@ fn single_staker_compounding(
height: 10,
time: Timestamp::from_seconds((reward_end + unbond_period).u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

basic_staking::ExecuteMsg::Withdraw {
Expand Down
5 changes: 5 additions & 0 deletions contracts/basic_staking/tests/stake_0_total_bug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn stake_0_total_bug(
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -220,6 +221,7 @@ fn stake_0_total_bug(
height: 1,
time: Timestamp::from_seconds(reward_start.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// No rewards should be pending
Expand Down Expand Up @@ -253,6 +255,7 @@ fn stake_0_total_bug(
height: 2,
time: Timestamp::from_seconds((reward_start.u128() + reward_duration.u128() / 2) as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// Half-ish rewards should be pending
Expand Down Expand Up @@ -287,6 +290,7 @@ fn stake_0_total_bug(
height: 3,
time: Timestamp::from_seconds(reward_end.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// All rewards should be pending
Expand Down Expand Up @@ -378,6 +382,7 @@ fn stake_0_total_bug(
height: 10,
time: Timestamp::from_seconds((reward_end + unbond_period).u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

basic_staking::ExecuteMsg::Withdraw {
Expand Down
3 changes: 3 additions & 0 deletions contracts/basic_staking/tests/transfer_stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ fn transfer_stake(stake_amount: Uint128, transfer_amount: Uint128) {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

// init block time for predictable behavior
app.set_block(BlockInfo {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -202,6 +204,7 @@ fn transfer_stake(stake_amount: Uint128, transfer_amount: Uint128) {
height: 1,
time: Timestamp::from_seconds(reward_end.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// Transfer should fail, not on whitelist
Expand Down
3 changes: 3 additions & 0 deletions contracts/basic_staking/tests/transfer_stake_compound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ fn transfer_stake(stake_amount: Uint128, transfer_amount: Uint128) {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

// init block time for predictable behavior
app.set_block(BlockInfo {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -202,6 +204,7 @@ fn transfer_stake(stake_amount: Uint128, transfer_amount: Uint128) {
height: 1,
time: Timestamp::from_seconds(reward_end.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

// Transfer should fail, not on whitelist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn transfer_stake(stake_amount: Uint128, transfer_amount: Uint128) {
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down
3 changes: 3 additions & 0 deletions contracts/basic_staking/tests/unbonding_withdrawals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fn unbonding_withdrawals(
height: 1,
time: Timestamp::from_seconds(0),
chain_id: "chain_id".to_string(),
random: None,
});

let viewing_key = "unguessable".to_string();
Expand Down Expand Up @@ -147,6 +148,7 @@ fn unbonding_withdrawals(
height: 1,
time: Timestamp::from_seconds(now),
chain_id: "chain_id".to_string(),
random: None,
});

// Perform each unbonding
Expand Down Expand Up @@ -198,6 +200,7 @@ fn unbonding_withdrawals(
height: 10,
time: Timestamp::from_seconds(now + unbond_period.u128() as u64),
chain_id: "chain_id".to_string(),
random: None,
});

let mut withdrawn_ids = vec![];
Expand Down
Loading

0 comments on commit f6213ed

Please sign in to comment.