Skip to content

Commit

Permalink
fix: remove filter that was restricting the amount of epochs to 21
Browse files Browse the repository at this point in the history
  • Loading branch information
nseguias committed Aug 16, 2024
1 parent 8a74779 commit bf28bfb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion integration-tests/tests/common/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl TestingSuite {
unbonding_period: 1u64,
growth_rate: Decimal::one(),
bonding_assets: vec![AMPWHALE.to_string(), BWHALE.to_string()],
grace_period: 21,
grace_period: 101,
epoch_manager_addr,
};

Expand Down
26 changes: 15 additions & 11 deletions integration-tests/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ fn epic_test() {
result.unwrap();
})
// create 20 more epochs, should not let alice claim any rewards
.add_epochs(20)
.add_epochs(100)
.query_current_epoch(|result| {
assert_eq!(result.unwrap().epoch.id, 22);
assert_eq!(result.unwrap().epoch.id, 102);
})
.query_claimable_reward_buckets(Some(&alice), |response| {
assert!(response.unwrap().1.is_empty());
})
// create 1 more epoch should let alice claim 19_000 uwhale from the initial setup
.add_epochs(1)
.query_current_epoch(|result| {
assert_eq!(result.unwrap().epoch.id, 23);
assert_eq!(result.unwrap().epoch.id, 103);
})
.query_claimable_reward_buckets(Some(&alice), |response| {
assert_eq!(response.unwrap().1[0].available, coins(19_000, "uwhale"));
Expand Down Expand Up @@ -100,7 +100,7 @@ fn epic_test() {
.add_one_epoch()
// check we're on epoch 24
.query_current_epoch(|result| {
assert_eq!(result.unwrap().epoch.id, 24);
assert_eq!(result.unwrap().epoch.id, 104);
})
.swap(
carol.clone(),
Expand Down Expand Up @@ -164,6 +164,12 @@ fn epic_test() {
.query_claimable_reward_buckets(Some(&bob), |response| {
println!("{:?}", response.unwrap().1);
});

// check we're on epoch 200
suite.add_epochs(93);
suite.query_current_epoch(|result| {
assert_eq!(result.unwrap().epoch.id, 200);
});
}

proptest! {
Expand Down Expand Up @@ -222,10 +228,14 @@ proptest! {

let current_rewards = Rc::new(RefCell::new(0));
let bonded_amounts = Rc::new(RefCell::new(HashMap::<Addr, HashMap<String, u128>>::new()));
// simple counter that increments every time a user unbonds
let unbond_id_counter = Rc::new(RefCell::new(0));
// user => (bonded_token, unbond_id_counter) => epoch
let unbonding_amounts = Rc::new(RefCell::new(HashMap::<Addr, HashMap<(String, u64), u64>>::new()));
// (user, epoch) => bool
let claimable_rewards = Rc::new(RefCell::new(HashMap::<(Addr, u64), bool>::new()));
let available_pools = suite.pool_identifiers.clone();
// list of the users that claimed in the current epoch (either by executing claim or bond/unbond with pending rewards)
let claimed = Rc::new(RefCell::new(HashSet::new()));

let mut swaps_in_epoch = false;
Expand All @@ -235,10 +245,6 @@ proptest! {
suite.query_current_epoch(|response| {
current_epoch = response.unwrap().epoch.id;
});
// TODO: >>> remove this once
if current_epoch > 121 {
break;
}

match action {
Action::Swap(user, from_token, to_token, amount) => {
Expand Down Expand Up @@ -297,6 +303,7 @@ proptest! {
for (user, token_amounts) in bonded_amounts.iter() {
if token_amounts.values().any(|&amount| amount > 0) {
claimable_rewards.borrow_mut().insert((user.clone(), current_epoch), true);
//
}
}
} else {
Expand Down Expand Up @@ -343,7 +350,6 @@ proptest! {
}

suite.query_bonding_rewards(user.to_string(), |response| {
// >>> TODO: MAKE SURE THE CONTRACT IS UPDATING STATE CORRECTLY AFTER BONDING WITH PENDING REWARDS
let contract_rewards = response.unwrap().1.rewards;
let has_contract_rewards = !contract_rewards.is_empty();

Expand Down Expand Up @@ -465,8 +471,6 @@ proptest! {
})
.unwrap_or_default();

println!(">>> user_unbonds: {:?}", user_unbonds);

if !user_unbonds.is_empty() {
println!(">>> [{current_epoch}] [{user}] WITHDRAW [{} {}]", user_unbonds.len(), token.split('/').nth(2).unwrap());

Expand Down

0 comments on commit bf28bfb

Please sign in to comment.